claude-p-agent-spawn-timeout
Skill0 starsChanged 46 days agoMITView on GitHub
Use when a `claude -p` invocation running inside a time-boxed launchd/cron job produces an empty or truncated artifact / times out, even though the task looks small — check whether the prompt caused Claude to spawn an internal subagent (Task/Agent tool) to explore many files, which can silently blow past the wrapper's timeout budget.
In this repository2 other files it gives its agents.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Check the prompt text for phrasing that invites broad exploration (e.g.
- Very specific: line 14
Add --disallowedTools Agent (or the CLI's current equivalent flag/tool name) to the claude -p invocation to block internal subagent …
- Distinctive: line 24
Run the job's exact command by hand.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Procedure
- Reproduce manually: run the exact
claude -p "..."command by hand withtime, without the launchd/timeout wrapper, and watch wall-clock duration. - Check the prompt text for phrasing that invites broad exploration (e.g. "read the raw N days of files", "look through all logs") — this is exactly the kind of instruction that makes Claude launch an internal subagent (Task tool) to search/read, which has unpredictable duration.
- Fix by doing both:
- Add
--disallowedTools Agent(or the CLI's current equivalent flag/tool name) to theclaude -pinvocation to block internal subagent spawning. - Bound the read scope explicitly in the prompt itself (e.g. "read at most 20 files") so the direct (non-agent) read also stays fast.
- Add
- Re-kick the job once by hand and confirm it finishes well inside the timeout with exit 0 and a non-empty, correctly sized artifact.
Pitfalls
- The
timeout Nwrapper kills the whole process with no diagnostic — logs just show an empty/missing artifact, which looks like a quota or API failure but usually isn't. Rule out subagent spawning first before chasing quota/network theories. - Confirm the exact disallow-tool flag name/spelling matches the installed CLI version; a stale flag name silently no-ops instead of erroring.
- Bounding file count in the prompt alone is not sufficient if the prompt still implies "explore" — Claude may still spawn a subagent for a small-looking task. Block the tool explicitly.
Verification
- Run the job's exact command by hand; confirm completion time is well under the timeout, exit 0, and the output artifact is non-empty with plausible size/content.
- Re-trigger the scheduled job (or wait for its next slot) and confirm the WARN/empty-output no longer appears in its log.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

