Choose a pattern
Each snippet below is a short codemode call from the main chat, not a long-lived script. After any restart, reconcile
status with saved task IDs persisted via the codemode store before launching more subagents.
Classify-and-act
Triage input with a read-only subagent, validate the returned label in the main session, then dispatch the right specialist:status for an existing action subagent before launching another, and verify the fix against the original report.
Fan-out-and-synthesize
Split a broad review into one parallel batch so related results stay grouped:Adversarial verification
Give a fresh read-only subagent the acceptance criteria and candidate, without the author’s conclusion, and ask for a failing input:Generate-and-filter
Ask fresh read-only subagents to inspect the implementation and propose concrete candidate cases, then filter every candidate with one deterministic check in codemode:Tournament
Compare competing approaches on identical fixtures with pre-agreed scoring and tie-breaking rules, and isolate edits in named worktrees:Loop-until-done
Run the project’s verification command in the main session between bounded repair rounds. Pass a foregroundwait budget suited to your test suite, and handle the string return value in case the command yields to a background shell:
bash exceeds its foreground observation budget (10 seconds by default), it yields to the background and returns a plain status string instead of structured output. Passing a larger budgetMs and checking typeof check === "string" avoids crashing on slower suites.
Start a new repair round only after the previous subagent settles, and stop on refusal, missing prerequisites, or approval gates. On restart, inspect the checkout and re-run the check before spending another round.
Stacked slices
Start each dependent slice from the exact verified commit of the previous slice:worker defaults to context: "fork", each slice sees the main chat’s verified decisions unless you pass context: "fresh". Verify each slice against its base and run full integration checks at the tip; run independent slices in parallel instead.
Before you delegate
Keep every subagent prompt self-contained so it does not rely on unspoken context:- Objective and deliverable. Name the decision or change that depends on the output, exact files to inspect, edit boundaries, and expected output shape (
file:linecitations, output file, or verified commit). - Done criteria. Name observable outcomes and proof checks rather than effort. Distinguish “checked and found nothing” from “could not verify,” and re-run key checks in your main session (Verification and evidence).
- Stop conditions. Set attempt caps, missing-prerequisite halts, and user-approval gates (API breaks, migrations, publishing) upfront. On a failed check, pass the exact observed failure to the next attempt rather than broadening scope.
- Fit and isolation. Confirm a single direct command wouldn’t be faster; give writers distinct worktrees or disjoint files; pass file paths rather than raw transcripts; store task IDs and commit SHAs so restarts reconcile before repeating side effects.