spawn
Squad — parallel subagent dispatcher
This is a rare-case tool. Worktrees and parallel dispatch are overhead. Use squad only when the goal is genuinely big AND splits into clearly independent pieces, each substantial on its own. For ordinary work, refuse with "this doesn't need squad — do it directly."
For one big task that splits cleanly into N≥2 independent pieces. Run them in parallel; cherry-pick the results.
Squad is fan-out, not a pipeline. No dependencies, no ordering, no resume. If pieces depend on each other, merge them or do it yourself.
You already know the Agent tool, git, and worktrees. This is the contract.
Flow
-
Decompose the goal into N≥2 sibling tasks with disjoint writable files.
-
Plan: emit the task list as JSON in chat — this lets you mechanically verify the constraints. Refuse if N<2 or any two tasks share a path in
files.[ {"title": "...", "files": ["..."], "tools": ["..."], "type": "fork|named", "profile": "...", "validate": "..."} ] -
Checkpoint (skip on
--yes): print the JSON plan, askproceed? [y / abort]. -
Dispatch in the assistant turn that responds to the user's
y. Make all Agent tool calls in parallel within that turn. Don't take other actions between approval and dispatch — that's how the plan stays bound to the approval. -
Integrate: create
squad/<id>/integrationfrom the original HEAD, cherry-pick eachdonechild's branch in plan order. -
Cleanup: remove each picked task's source worktree and branch. Tasks that weren't picked keep theirs for inspection.
-
End: print the hand-off line.
No on-disk state. The conversation is the source of truth.
Dispatch — exact call
Named task:
Agent({
description: <title>,
subagent_type: <profile>,
isolation: "worktree",
prompt: <child prompt>
})
Fork task (requires CLAUDE_CODE_FORK_SUBAGENT=1):
Agent({
description: <title>,
isolation: "worktree",
prompt: <child prompt>
})
isolation: "worktree" makes Claude Code create the worktree itself. Don't pass cwd — there is no such parameter. Each call returns the worktree path and branch when the child commits; record the branch.
Child prompt template
# Objective
<title>
# Boundaries
Edit only these files:
<files>
# Tools
You may use: <tools>. Refuse anything outside the list.
# Validate
Before finishing, run: <validate>
The exit code must be zero. If non-zero, return `blocked`.
# Commit
Commit before finishing. Do not push.
# Final message — JSON only
{
"status": "done | blocked | failed",
"summary": "<1-3 sentences>",
"commits": [{"sha": "<hex>", "subject": "<subject>"}],
"blockers": [{"kind": "missing-dep|conflict|spec-unclear|validation-failed", "detail": "<text>"}]
}
`done` requires non-empty `commits` and empty `blockers`.
Integrate
BASE=$(git rev-parse HEAD)
ID=$(date -u +%Y%m%dT%H%M%SZ)
git branch "squad/$ID/integration" "$BASE"
git switch "squad/$ID/integration"
# For each `done` task in plan order:
git cherry-pick "$BASE..<task.branch>"
On cherry-pick conflict: git cherry-pick --abort, print conflicting paths and the two tasks' titles, stop. Ask the user to resolve manually or merge those tasks into one and rerun.
Tasks with status != done are skipped — their commits stay on Claude-managed branches.
Cleanup
After successful integration, remove each picked task's source worktree and branch:
# For each picked task:
git worktree remove "<task.path>" 2>/dev/null || true
git branch -D "<task.branch>" 2>/dev/null || true
Claude auto-cleans worktrees only when the child made no changes. Worktrees with commits (i.e. all of ours) survive until you remove them — without this step they accumulate across runs.
Tasks that weren't picked (skipped, conflict, failed) keep their worktree + branch so the user can inspect.
End
Integration branch ready: squad/<id>/integration. Run /ship:commit to ship.
Hard rules
- Never push,
--force,--hard,--amend,rebase -i. - Never cherry-pick from a branch you didn't get back from your own Agent dispatch this run.
- Only delete a Claude-managed worktree/branch after you successfully cherry-picked from it. Never touch unpicked ones.
- Retry a child at most once, only when its return JSON is missing or self-contradictory (e.g.
donewith emptycommits). Never retry onblocked/failedwith a valid return — those need user intervention. The retried branch supersedes the original for cherry-pick purposes; leave the original worktree alone. - No automatic conflict resolution.
- Refuse on: dirty parent, missing
CLAUDE_CODE_FORK_SUBAGENT=1, unresolved named profile.
Task
Handle this request: $ARGUMENTS
More from skrrt-sh/skills
pr
Creates or updates GitHub pull requests and GitLab merge requests with the matching CLI. Use when the agent needs to push a branch, open a review request, or write PR or MR text. Always use this skill when the user asks to open a PR, create a pull request, push and open a PR, create a merge request, update PR text, write a PR description, or anything involving pull requests or merge requests. Trigger for phrases like "open a PR", "create a pull request", "push and open a PR", "merge request", "MR on gitlab", "update the PR", or "write PR description".
12resolver
Resolves a cherry-pick conflict during a /squad:spawn run by editing the unmerged files to preserve both children's intent. Invoked by /squad:spawn when --auto-resolve is on; do not invoke directly.
1decompose
Plans a multi-subagent run. Reads the goal, picks a pattern (pipeline, breadth-first, or map-reduce), defines per-child scope with file ownership and a validation command, and writes a task manifest. This is the "plan" step in explore/plan/implement — it produces a manifest and stops. Make sure to use this skill whenever the user asks to split work, plan a fan-out, build a squad manifest, decompose a goal for subagents, break a task into parallel work, plan subagent tasks, or turn a goal into a task manifest — even if they don't say the word "decompose".
1orchestrate
End-to-end squad run. Invokes /squad:decompose, pauses at a single checkpoint, then invokes /squad:spawn. The chained wrapper for explore/plan/implement. Make sure to use this skill whenever the user wants to run the whole pipeline on one goal, plan and fan out end-to-end, orchestrate a multi-agent job, decompose and then spawn in one shot, or run the squad pipeline — even if they don't say the word "orchestrate".
1