Recursive Swarm
by @plgonzalezrx8
Bounded recursive orchestration for complex tasks that are too large for one agent turn but cleanly decompose into a few independent subproblems. Use for mul...
clawhub install recursive-swarmπ About This Skill
name: recursive-swarm description: "Bounded recursive orchestration for complex tasks that are too large for one agent turn but cleanly decompose into a few independent subproblems. Use for multi-angle research, audits, mixed research+synthesis, or coding projects that benefit from explicit planning, task-tree state, artifact folders, and controlled parallel execution. Keep recursion tight: default max depth 2, hard cap 3, preferred fan-out 2-4, and modest concurrency. Use git worktrees only for coding leaves inside git repos. Do not use for simple one-shot tasks, destructive workflows, or open-ended exploration."
Recursive Swarm
Use this skill to turn one large task into a small, bounded task tree with explicit node state, artifacts, merge points, and audit events.
Use this workflow
Use recursive-swarm only when all of these are true:
1. The task is too large or messy for one agent turn. 2. The task has at least 2 meaningful subproblems. 3. The outputs can be merged back into one answer, report, or code result.
Do not recurse for simple reads, one-shot edits, destructive workflows, or open-ended exploration with no clear output contract.
Defaults
events.jsonlcoding leaves inside a git repo when sibling edits benefit from isolationNode types
Assign each node one primary type:
research β extraction, investigation, analysiscoding β implementation, refactor, test workops β shell, system, or environment workflowsbrowser β web/UI automationsynthesis β combine child outputs into one merged resultreview β challenge weak claims, reconcile conflicts, prune bad findingsExecution routing
Route nodes like this:
research, synthesis, review β subagentscoding β ACP sessions by default; use worktrees only when usefulops, browser β direct tools or a narrowly scoped subagent if neededQuiet child execution (default)
For routine child runs, prefer silent child completion + parent-owned final delivery.
That means:
ANNOUNCE_SKIPOnly allow a child announce message to reach the user when:
Do not let every child produce routine completion chatter in the user channel.
Atomic vs composite rule
Treat a node as atomic when one agent run can finish it without meaningful internal planning.
Examples of atomic nodes:
Treat a node as composite when it clearly breaks into independent workstreams.
Examples of composite nodes:
If a child split feels artificial or the merge plan is vague, stop decomposing.
Workflow
1) Initialize the run
Create a run folder with scripts/init_run.py.
Recommended output layout:
runs//
tree.json
events.jsonl
summary.md
nodes/
1/
spec.json
notes.md
result.md
2) Create the root node
Use scripts/upsert_node.py to record the root task and defaults.
Record at minimum:
3) Decompose only when worth it
For each composite node:
Never recurse just to make the tree look smart.
4) Persist state and audit events
Before executing a node:
runningnodes//spec.json nodes//notes.md events.jsonlAfter executing a node:
nodes//result.md completed, failed, or waiting_for_approvalevents.jsonlUse these scripts:
scripts/upsert_node.pyscripts/mark_node.pyscripts/list_ready_nodes.pyscripts/list_events.pyscripts/merge_results.pyscripts/render_tree.py5) Execute leaves
Use scripts/list_ready_nodes.py to identify executable leaves.
Execution guidance:
ANNOUNCE_SKIP during the announce step unless they are blocked or explicitly responsible for final delivery6) Merge upward
When all child nodes under a parent are complete:
result.md, session history, or other saved artifactsscripts/merge_results.py to bundle child file results when applicableresult.mdIf a child was run in quiet mode with ANNOUNCE_SKIP, treat that as normal. Silence is not failure; it just means the parent owns user-facing delivery.
Use type-aware merge behavior:
Do not silently average conflicting child outputs. Bubble disagreements up.
7) Finish with a skeptical pass
For important runs, add one final review node that:
Approval gates
Pause and ask before executing any node that would:
Mark these nodes waiting_for_approval instead of forcing them through.
Worktrees
Do not use git worktrees by default.
Use a worktree only when all of these are true:
codingOtherwise keep the node in normal artifact-folder mode.
Stop conditions
Stop decomposing when any of these is true:
References
Read these only if needed:
references/tree-schema.json β canonical run and node schemareferences/example-run.md β example run layout and sample treereferences/quiet-mode.md β quiet child execution pattern using ANNOUNCE_SKIP