Index of every page on this site: llms.txt
All skills
oaustegard avatar

/dispatching-subagents

@b9eb735
Run it yourself

Chooses how to launch subagents from Claude Code (the Agent tool, a Workflow script, or headless claude -p children) and runs a headless fan-out from one background command. Use for "fan this out to 50 agents", "run these tasks in parallel", "launch subagents for each file", "should I spawn agents or write a workflow", "batch this through Haiku", "run claude -p in parallel", "dispatch a task list without the launches eating my context", or before any launch of more than a handful of subagents, where the launching itself is the cost. Covers the parent-turn cost of each mechanism, concurrency ceilings, what context and tools each child gets, effort control, output contracts, a cost ledger, and resume after interruption.

Use this Skill: https://skilld.dev/gh/oaustegard/claude-skills/dispatching-subagents

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

README.md

≈1.3k tokens on demand. Your agent reads this file only when SKILL.md points to it.

dispatching-subagents

Chooses how to launch subagents from Claude Code, and runs the bulk case from one command.

Claude Code has three ways to start a subagent: the Agent tool, a Workflow script, and a headless claude -p child process. They differ most in what the launching costs the session that does it. Every Agent-tool launch, and every completion notice, is a turn in which the parent re-reads its whole context. On 2026-10-11 a 314-agent build spent about $160–170 of Opus parent turns to dispatch $11.61 of Haiku work. The same tasks through this skill's runner cost one parent call.

Which of these skills do I want?

Several skills in this repo sit close together. Their names alone mislead: given only the names, Haiku, Sonnet and Opus picked the right one for 55–85% of 58 test requests, and the commonest mistake was sending a "run these in parallel" request to orchestrating-agents, since renamed orchestrating-chat-agents for that reason. Given the descriptions, all three picked correctly 173 times out of 174 (experiments/subagent-skill-choice). So Claude routes well; this table is for people.

you want to… skill
run 10+ independent tasks in parallel, decide Agent tool vs Workflow vs claude -p, or stop launches eating your context dispatching-subagents
pick the model or effort level for a subagent, or decide whether to retry or escalate agent-routing
write an Agent or create_session prompt that carries the right part of this conversation delegating-with-context
fan out over the Anthropic API from claude.ai chat, where there is no Agent tool orchestrating-chat-agents
write the script for a workflow you have already opted into workflow-authoring (built in)
run a fixed sequence of steps with retries, gates and resume, with no model judgment between steps flowing
drive a large failing-test backlog to green with a long-running swarm of workers behind a merge gate swarming-to-green
classify or extract per item at volume, with a cheap non-Claude model invoking-gemini
route, triage or rate text with a calibrated probability deciding-with-confidence

They compose. A large fan-out typically uses three: dispatching-subagents to pick the mechanism and run it, agent-routing to pick the model, and delegating-with-context when the children need what this session knows.

The three mechanisms

Agent tool Workflow headless claude -p
parent cost a turn per launch and per completion one call per run one Bash call per run
concurrency 20; a 21st launch errors 2 on a 4-vCPU container RAM-bound, ~210 MB per child; 40 ran clean
child sees the session's tools, MCP connectors, hooks as Agent only what you pass
effort session's level, or an agent type's effort: frontmatter per agent() --effort
needs your opt-in no yes no
cost per child not reported not reported in a ledger

Use the Agent tool when a child needs an MCP connector or this session's context, or when each result decides the next launch. Use Workflow when you have opted in and want a script to enforce phases. Use headless children for everything else at volume: graders, judges, extractors, per-file reviews.

Quick start

S=/mnt/skills/user/dispatching-subagents/scripts/headless_fanout.py
# tasks.jsonl: one {"id", "prompt", "out"} per line; "out" is the JSON file the child writes
python3 $S run tasks.jsonl --work RUN --schema schema.json --dry-run    # check the commands
python3 $S run tasks.jsonl --work RUN --schema schema.json --model haiku --max-usd 5
python3 $S status RUN

Run the second command in the background and end the turn; the completion notice brings you back. A rerun skips finished tasks. Tasks with no tools can return structured output instead of a file: {"id", "prompt", "tools": "", "json_schema": {...}}.

Each child gets a fresh session id, no hooks, no MCP servers, no secret-named environment variables, and --permission-mode dontAsk with an allowlist. A task counts as done only when its output parses and matches the schema. Write permission is spelled Edit(//absolute/path); Write(path) is refused.

Measured

  • 40 concurrent Haiku children: 40/40 ok, 25 s wall clock, 8.7 GB peak RSS.
  • A lean child (custom system prompt, no tools) carries ~1.2K tokens of overhead; the default prompt carries 39K.
  • --effort low gave 0 thinking tokens on a reasoning prompt, --effort high 112–197.
  • In one session the runner drove 747 children (A/B answerers and judges, contradiction checks with web search and repo snapshots) from about a dozen parent calls.

Files

  • SKILL.md: the decision rule, procedures, failure modes and verification, for Claude.
  • scripts/headless_fanout.py: the runner.
  • scripts/test_headless_fanout.py: offline tests against a fake claude binary.
  • references/native-messaging.md: SendMessage and ListAgents between native subagents, moved here from orchestrating-agents.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning5d3 checks · Risk SAFE
  • Gen Agent Trust Hub5d

    This skill facilitates the parallel execution of subagents via the Claude Code CLI. While it implements several high-quality security mitigations—such as stripping sensitive environment variables and isolating subagent sessions—it inherently expands the attack surface for indirect prompt injection by processing task lists and executing subagents autonomously.

  • Socket5d

    1 alert: gptAnomaly

  • Snyk5d

    Risk: LOW · No issues

Signed by skilld at b9eb735. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 weeks ago
metadata
{
  "version": "0.3.0"
}

README badge

README badge for oaustegard/claude-skills/dispatching-subagents