Skip to main content
Give each subagent one concrete deliverable, explicit inputs, clear edit rules, and a verification check. Put conflicting edits in separate worktrees, and run final verification in your main session — a subagent claiming “done” is not proof.

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:
On recovery, check 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:
Synthesize only after every required subagent settles, and reconcile contradictions against source code. On restart, recover results by task ID instead of repeating the whole batch.

Adversarial verification

Give a fresh read-only subagent the acceptance criteria and candidate, without the author’s conclusion, and ask for a failing input:
Verify reported failures in the main session by checking real exit codes before requesting repairs. With multiple reviewers, collect independent verdicts first, then allow one bounded Intercom debate. A reproducible failing case beats a majority vote. For user interfaces, exercise the real interface.

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:
Parse each returned result as data, drop malformed or duplicate entries, and run the real formatter or test harness in your main session to keep only candidates that reproduce a real discrepancy or gap. Returning “none passed” is valid.

Tournament

Compare competing approaches on identical fixtures with pre-agreed scoring and tie-breaking rules, and isolate edits in named worktrees:
worker defaults to context: "fork", so pass context: "fresh" when you want independent attempts without the main chat’s prior reasoning (Fresh vs. forked context). Named worktrees (worktree: { branch }) are permanent and do not symlink node_modules — have competitors install dependencies if needed and remove unused branches/worktrees when the tournament ends.
Record scores, commit SHAs, and round numbers so restarts never double-advance a candidate. Never pick a winner that fails a required check.

Loop-until-done

Run the project’s verification command in the main session between bounded repair rounds. Pass a foreground wait budget suited to your test suite, and handle the string return value in case the command yields to a background shell:
When 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:
Because 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:line citations, 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.
Example self-contained prompt: