From 813e1c6fa4d9c170b1e8f748347cb3bb6e3c97e4 Mon Sep 17 00:00:00 2001 From: NanoClaw User Date: Wed, 25 Mar 2026 22:05:29 +0000 Subject: [PATCH 1/4] fix: improve task scripts agent instructions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reword Task Scripts opening in main template to guide agents toward schedule_task instead of inline bash loops. Add missing Task Scripts section to global template — non-main groups have unrestricted access to schedule_task with script parameter, so omitting instructions just leads to worse patterns. Co-Authored-By: Claude Opus 4.6 (1M context) --- groups/global/CLAUDE.md | 39 +++++++++++++++++++++++++++++++++++++++ groups/main/CLAUDE.md | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/groups/global/CLAUDE.md b/groups/global/CLAUDE.md index c814e39..7018c04 100644 --- a/groups/global/CLAUDE.md +++ b/groups/global/CLAUDE.md @@ -74,3 +74,42 @@ No `##` headings. No `[links](url)`. No `**double stars**`. ### Discord channels (folder starts with `discord_`) Standard Markdown works: `**bold**`, `*italic*`, `[links](url)`, `# headings`. + +--- + +## Task Scripts + +To check or monitor something on a recurring basis, use `schedule_task` — not a bash loop. This way the check survives container restarts and doesn't block other messages. If the user only needs to know when a condition changes, add a `script` to avoid unnecessary wake-ups — the script runs first, and you only wake up when there's something to act on. + +### How it works + +1. You provide a bash `script` alongside the `prompt` when scheduling +2. When the task fires, the script runs first (30-second timeout) +3. Script prints JSON to stdout: `{ "wakeAgent": true/false, "data": {...} }` +4. If `wakeAgent: false` — nothing happens, task waits for next run +5. If `wakeAgent: true` — you wake up and receive the script's data + prompt + +### Always test your script first + +Before scheduling, run the script in your sandbox to verify it works: + +```bash +bash -c 'node --input-type=module -e " + const r = await fetch(\"https://api.github.com/repos/owner/repo/pulls?state=open\"); + const prs = await r.json(); + console.log(JSON.stringify({ wakeAgent: prs.length > 0, data: prs.slice(0, 5) })); +"' +``` + +### When NOT to use scripts + +If a task requires your judgment every time (daily briefings, reminders, reports), skip the script — just use a regular prompt. + +### Frequent task guidance + +If a user wants tasks running more than ~2x daily and a script can't reduce agent wake-ups: + +- Explain that each wake-up uses API credits and risks rate limits +- Suggest restructuring with a script that checks the condition first +- If the user needs an LLM to evaluate data, suggest using an API key with direct Anthropic API calls inside the script +- Help the user find the minimum viable frequency diff --git a/groups/main/CLAUDE.md b/groups/main/CLAUDE.md index 6080427..5e693fa 100644 --- a/groups/main/CLAUDE.md +++ b/groups/main/CLAUDE.md @@ -267,7 +267,7 @@ The task will run in that group's context with access to their files and memory. ## Task Scripts -When scheduling tasks that check a condition before acting (new PRs, website changes, API status), use the `script` parameter. The script runs first — if there's nothing to do, you don't wake up. +To check or monitor something on a recurring basis, use `schedule_task` — not a bash loop. This way the check survives container restarts and doesn't block other messages. If the user only needs to know when a condition changes, add a `script` to avoid unnecessary wake-ups — the script runs first, and you only wake up when there's something to act on. ### How it works From a29ca0835c37ede7ef490e21dda6a6a840bbe4a7 Mon Sep 17 00:00:00 2001 From: NanoClaw User Date: Thu, 26 Mar 2026 11:21:18 +0000 Subject: [PATCH 2/4] fix: rewrite task scripts intro for broader use cases and clarity Broadens the trigger from "check or monitor" to "any recurring task", adds context about API credit usage and account risk for frequent tasks, and prompts the agent to clarify ambiguous requests. Co-Authored-By: Claude Opus 4.6 (1M context) --- groups/global/CLAUDE.md | 2 +- groups/main/CLAUDE.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/groups/global/CLAUDE.md b/groups/global/CLAUDE.md index 7018c04..935578a 100644 --- a/groups/global/CLAUDE.md +++ b/groups/global/CLAUDE.md @@ -79,7 +79,7 @@ Standard Markdown works: `**bold**`, `*italic*`, `[links](url)`, `# headings`. ## Task Scripts -To check or monitor something on a recurring basis, use `schedule_task` — not a bash loop. This way the check survives container restarts and doesn't block other messages. If the user only needs to know when a condition changes, add a `script` to avoid unnecessary wake-ups — the script runs first, and you only wake up when there's something to act on. +For any recurring task, use `schedule_task`. Tasks that wake the agent frequently — especially multiple times a day — consume API credits and can risk account restrictions. If a simple check can determine whether you need to act, add a `script` — it runs first, and you only wake up when the check passes. This keeps agent invocations to a minimum. If it's unclear whether the user wants a response every time or only when something requires attention, ask. ### How it works diff --git a/groups/main/CLAUDE.md b/groups/main/CLAUDE.md index 5e693fa..d3ea5f9 100644 --- a/groups/main/CLAUDE.md +++ b/groups/main/CLAUDE.md @@ -267,7 +267,7 @@ The task will run in that group's context with access to their files and memory. ## Task Scripts -To check or monitor something on a recurring basis, use `schedule_task` — not a bash loop. This way the check survives container restarts and doesn't block other messages. If the user only needs to know when a condition changes, add a `script` to avoid unnecessary wake-ups — the script runs first, and you only wake up when there's something to act on. +For any recurring task, use `schedule_task`. Tasks that wake the agent frequently — especially multiple times a day — consume API credits and can risk account restrictions. If a simple check can determine whether you need to act, add a `script` — it runs first, and you only wake up when the check passes. This keeps agent invocations to a minimum. If it's unclear whether the user wants a response every time or only when something requires attention, ask. ### How it works From eda14f472beaa3e7a94e773bdcafeeacc1612ec6 Mon Sep 17 00:00:00 2001 From: NanoClaw User Date: Thu, 26 Mar 2026 12:37:28 +0000 Subject: [PATCH 3/4] fix: include script field in task snapshot for current_tasks.json The task snapshot mappings in index.ts were omitting the script field, making it appear that scheduled tasks had no script even when one was stored in the database. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.ts b/src/index.ts index 60fe910..bf57823 100644 --- a/src/index.ts +++ b/src/index.ts @@ -329,6 +329,7 @@ async function runAgent( id: t.id, groupFolder: t.group_folder, prompt: t.prompt, + script: t.script || undefined, schedule_type: t.schedule_type, schedule_value: t.schedule_value, status: t.status, @@ -685,6 +686,7 @@ async function main(): Promise { id: t.id, groupFolder: t.group_folder, prompt: t.prompt, + script: t.script || undefined, schedule_type: t.schedule_type, schedule_value: t.schedule_value, status: t.status, From 730ea0d713634edf1abcf16defe887b05a5accc0 Mon Sep 17 00:00:00 2001 From: NanoClaw User Date: Thu, 26 Mar 2026 15:05:53 +0000 Subject: [PATCH 4/4] fix: refine task scripts intro wording Use third-person voice and clearer terminology for the task scripts intro paragraph. Co-Authored-By: Claude Opus 4.6 (1M context) --- groups/global/CLAUDE.md | 2 +- groups/main/CLAUDE.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/groups/global/CLAUDE.md b/groups/global/CLAUDE.md index 935578a..11988bc 100644 --- a/groups/global/CLAUDE.md +++ b/groups/global/CLAUDE.md @@ -79,7 +79,7 @@ Standard Markdown works: `**bold**`, `*italic*`, `[links](url)`, `# headings`. ## Task Scripts -For any recurring task, use `schedule_task`. Tasks that wake the agent frequently — especially multiple times a day — consume API credits and can risk account restrictions. If a simple check can determine whether you need to act, add a `script` — it runs first, and you only wake up when the check passes. This keeps agent invocations to a minimum. If it's unclear whether the user wants a response every time or only when something requires attention, ask. +For any recurring task, use `schedule_task`. Frequent agent invocations — especially multiple times a day — consume API credits and can risk account restrictions. If a simple check can determine whether action is needed, add a `script` — it runs first, and the agent is only called when the check passes. This keeps invocations to a minimum. ### How it works diff --git a/groups/main/CLAUDE.md b/groups/main/CLAUDE.md index d3ea5f9..c901813 100644 --- a/groups/main/CLAUDE.md +++ b/groups/main/CLAUDE.md @@ -267,7 +267,7 @@ The task will run in that group's context with access to their files and memory. ## Task Scripts -For any recurring task, use `schedule_task`. Tasks that wake the agent frequently — especially multiple times a day — consume API credits and can risk account restrictions. If a simple check can determine whether you need to act, add a `script` — it runs first, and you only wake up when the check passes. This keeps agent invocations to a minimum. If it's unclear whether the user wants a response every time or only when something requires attention, ask. +For any recurring task, use `schedule_task`. Frequent agent invocations — especially multiple times a day — consume API credits and can risk account restrictions. If a simple check can determine whether action is needed, add a `script` — it runs first, and the agent is only called when the check passes. This keeps invocations to a minimum. ### How it works