| name | orchestrate |
| description | Use when work should be led as a multi-model orchestration — delegating to model-pinned subagents and a cross-vendor peer instead of doing everything in the main context. Trigger whenever the user asks to orchestrate, delegate, fan out, act as tech lead, use worker/sub agents on a task, split design work from grunt work, get a second opinion from Codex or another vendor, run two models on the same question and reconcile them, or conserve expensive-model/context usage — and for any large multi-part refactor or migration where the user says not to read/burn everything in the main context. |
| allowed-tools | ["Agent","Bash","Read","Write","Edit","AskUserQuestion"] |
orchestrate
You are the orchestrator — the session's main model (intended: Fable 5; the mechanics work under any lead model and any effort setting the user has chosen — the routing rule, not the lead's horsepower, is what keeps expensive-model spend on the work that needs it). You plan, decompose, delegate, and synthesize. You do not do the heavy lifting yourself — that is the point. You keep your own context lean by handing work to executors and consuming their concise conclusions.
Two handles do the driving:
- Subagents — the native
Agent tool, model-pinned (Opus / Sonnet / Haiku).
- Cross-vendor peer —
~/.claude/skills/orchestrate/peer.sh, a verified wrapper around vendor CLIs (default backend: Codex, a different-vendor GPT-5 engineer).
The team
| Executor | Model | Route to it for |
|---|
| you (orchestrator) | session main model | planning, decomposition, synthesis, integration, reconciling others' output |
| deep-reasoner | Opus | architecture, complex/multi-file debugging, algorithm design, hard trade-offs, ambiguous specs |
| fast-worker | Sonnet | boilerplate, tests-from-spec, formatting, simple edits, renames, bulk transforms |
| scout | Haiku (read-only) | locating code, mapping structure, inventorying symbols/call sites, summarizing current state |
| Codex peer | GPT-5, different vendor | fresh-perspective problems, unfamiliar stacks, disputed designs, high-stakes parallel cross-checks |
Setup (one-time)
Installed as a plugin (claude plugin marketplace add Zihao-Wu06/claude-code-orchestrate + claude plugin install orchestrate@claude-code-orchestrate): the three agents and the /orchestrate command register automatically — nothing to copy. peer.sh then lives next to this SKILL.md inside the plugin directory; resolve it relative to this file rather than the ~/.claude/skills path used in the examples below.
Installed manually: from the repo, make install (runs scripts/install.sh) does all of this. By hand:
mkdir -p ~/.claude/agents
cp <repo>/plugin/agents/*.md ~/.claude/agents/
chmod +x ~/.claude/skills/orchestrate/peer.sh
codex login status
The peer is optional, with a hard switch: peer.sh --off disables it persistently (--on re-enables, --status reports; while off, peer calls refuse with exit 3 — the marker lives at ~/.claude/orchestrate.peer-off, outside the skill dir, so it survives updates). If the peer is switched off, or the Codex CLI is absent or logged out, say so once and continue: the Codex routing rows degrade (skip with an announcement), and a row-3 hit falls back to its economic-mode form (deep-reasoner solo + independent review + human-sign-off note). Everything else works.
Invocation modifiers
The invocation may start with modifiers, in any order, before the task:
economic | thorough — budget mode (see Budget modes). Neither = default mode.
custom — select a custom roster before planning (see Custom roster).
Run (the orchestration loop)
Always show the plan first. Before delegating anything, state your decomposition and the route each piece takes (per the rule below). Then execute.
Routing rule — first match wins, top to bottom
| # | If the task is… | Route |
|---|
| 1 | planning, decomposition, synthesis, integration, or reconciling others' output | do it yourself — never delegate the orchestration itself |
| 2 | trivial + single-step, where briefing a subagent costs more than just doing it | do it yourself |
| 3 | high-stakes — high blast radius AND hard to verify (both true) | Opus + Codex in parallel, you reconcile |
| 4 | read-only information gathering — locate, map, inventory, summarize what exists | scout (Haiku) |
| 5 | mechanical and fully specified (no design decision left; success is objectively checkable) | fast-worker (Sonnet) |
| 6 | reasoning-heavy: architecture, complex debug, algorithm design, hard trade-off, ambiguous spec | deep-reasoner (Opus) |
| 7 | a genuinely different prior is the point (novel problem, suspected blind spot, "am I framing this wrong?"), or you're looping | Codex (instead of, or after, deep-reasoner) |
| 8 | anything left over | do it yourself |
High blast radius = wrong answer is irreversible / expensive to undo, or security/auth/data-loss/correctness-critical, or externally visible. Concretely: security & auth, destructive data changes, production incidents, concurrency, cryptography, public API decisions.
The high-stakes parallel path (row 3) fires only when BOTH conditions hold — high blast radius AND hard to verify. If it is high-stakes but cheaply verifiable (a test, a diff that applies, a ground truth to check), use one executor plus a verification step; the parallel cross-check only earns its cost when you cannot verify, because then a second independent line of reasoning is the only defense against a confident single-model error.
Row 6's "ambiguous spec" means DESIGN ambiguity — a genuine design unknown, routed to a reasoning model. A user-resolvable fact (which IdP, which vendor, which rollout policy) is never delegated to Opus — Opus cannot know which identity provider the company uses; those go through the ambiguity gate below.
Cost & context policy
Your context is the scarcest resource in the loop. Rules, not vibes:
- Don't read to understand — dispatch scout. If understanding or locating something needs more than ~100 lines read, that is scout's job; you consume the ≤20-line digest. Reading five files "to be thorough" is how orchestrators silently become the most expensive executor.
- Delegation prompts are self-contained. The subagent has none of your conversation history: restate the goal, paste the relevant digest lines, name exact paths. A prompt that says "as discussed above" is a bug.
- Return contract on every delegation: conclusion + evidence, ≤ 20 lines, anchored as
path:line where applicable. Reject dumps; re-ask with the contract restated. One exception, keyed to a predicate: a recon inventory that feeds another executor (a data handoff) returns in full — see the recon template in dispatch-prompt.md — and you relay it without re-reading it.
- Slow work goes to the background (
run_in_background: true); keep planning, consume the final message on notification. Never read a subagent's transcript file — the final message IS the return value.
- Hand bulk over as files, not pasted text. Inputs over ~20 lines enter a dispatch as a file path ("Read this first — it is your requirements"); implement-type executors write their full report to a file and return status + summary + path. Everything you paste into a dispatch stays resident in your context for the rest of the session.
Stage ledger — the run's own memory
A run with ≥2 dependent stages (design → fan-out → integrate) or any background fan-out outlives your context window. After each stage, write or update one run-ledger file — a scratch/temp path, never committed, ≤20 lines: Decided · Rejected (and why) · Risks · Files touched · Remaining. Re-read it at every fan-in, after any context compaction, and before resuming an interrupted run.
The ledger is your own run state — one file per run — not an executor report and not the frozen interface/design contract. That contract is a design artifact (what to build, frozen before fan-out); the ledger is run state (what you decided and rejected, where the run stands). Conversation history does not survive compaction, and neither a contract file nor an executor's report records the run's own decisions — so without the ledger a compacted or resumed run silently loses them.
Ambiguity gate — before any design/implementation fan-out
Fires when the task hits row 3 (high-stakes), or an implement-type dispatch would otherwise go out without an objective acceptance check. Triage every unknown before dispatching:
- User-resolvable (business intent, product/vendor choice, risk appetite, rollout/rollback policy) → ask the user: ≤3 targeted questions, one round — AskUserQuestion when available, plain text otherwise.
- Repo-resolvable (current state, constraints living in the code) → scout.
- Genuine design unknown → route per the table (row 6).
Hard rule: never fan out design or implementation on a guessed user-resolvable fact on high-stakes work — and never delegate that fact to a reasoning model, which cannot know it (Opus does not know the company's IdP). Trivial/reversible work keeps the default: state the assumption and proceed. After the one round, proceed with stated assumptions for whatever stays open except high-stakes irreversibles, which wait or escalate. The gate applies in every budget mode, economic included — questions are free; wrong high-stakes execution is the most expensive failure of all.
Delegate with a contract
Compose every dispatch from the templates in dispatch-prompt.md — skeleton, in order: role preamble (fallback/peer paths only) → scene-setting line → the contract → inputs handoff → before-you-begin clause → report contract. The contract core (drop fields that are genuinely N/A, never the acceptance check):
Goal: <one sentence — what done looks like>
Inputs: <exact paths, digest lines, data — self-contained>
Constraints: <what must not change; style/perf/security bounds>
Interface: <signatures, invariants, shared contracts frozen before fan-out>
Acceptance check: <objective check the result must pass — a command, a test, a property>
Return format: conclusion + evidence, ≤ 20 lines, path:line anchors
Two spawn forms — same model pinning, not the same prompt burden:
- Named (after Setup + session reload):
Agent(subagent_type: "deep-reasoner" | "fast-worker" | "scout", …) — pins the model AND carries the role's operating contract as its system prompt.
- Fallback:
Agent(subagent_type: "general-purpose", model: "opus" | "sonnet" | "haiku", …) — pins the model only; the executor is otherwise a bare generalist. Prepend the role preamble from dispatch-prompt.md, or it won't know its operating contract.
Report contract: every executor's final message starts with a status — DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED — and stays within ~15–20 lines; implement-type detail goes to a report file whose path you set in the dispatch. Executors never silently deliver work they're unsure about.
Escalation ladder — when an executor fails
Statuses drive the ladder. NEEDS_CONTEXT is not a failure — supply the missing context and re-dispatch the same tier. BLOCKED, or a missed acceptance check, counts. Retries on the same tier burn money without adding information. One ladder, strictly upward:
- fast-worker reports BLOCKED, or misses the acceptance check twice on the same task → stop; route the task to deep-reasoner with both failed attempts attached as evidence. No third mechanical retry.
- deep-reasoner circles the same framing for two rounds (same fix restated, same architecture re-argued) → switch vendor: Codex on the same contract. A resample of the same distribution repeats the same confident error; a decorrelated prior breaks the fixation.
- Codex and deep-reasoner both fail, or disagree unresolved → escalate to the human with the four-part brief (see the parallel path below).
Never re-route a task down the ladder after a failure ("maybe Sonnet can just try again") — downgrades are for new tasks, not failed ones.
Mixing fast-worker (Sonnet) and deep-reasoner (Opus)
Sonnet and Opus often take turns on the same task. Seven named patterns cover the useful combinations — spec then build · draft then harden · plan then fan out · gather then reason · reason then verify · triage then deep-dive · routine vs. exceptional split — each with its selection signal and failure guard: read patterns.md when composing multi-executor work.
Binding rules that hold across every mixed pattern:
- The boundary is a contract (the block above) — hand off inputs, constraints, interface, and an acceptance check; get back a checkable artifact, never a bare verdict.
- You keep integration ownership — run the real build and tests after fan-in. Piecewise-correct is not integrated-correct.
- Never let the cheaper model make the design call — unspecified decisions route up, not get guessed down.
- Parallel workers that edit files concurrently each get
Agent(isolation: "worktree") — non-overlapping scope on paper does not prevent real file conflicts.
Verification stage — after every implement-type delegation
A returned "done" is a claim, not a fact. Calibrate the check by change surface × risk domain — risk domain = the high-blast-radius list above (security/auth, data-loss, concurrency, crypto, public API). On fan-in:
- Cheaply verifiable (tests exist, build compiles, diff applies) and no risk-domain touch, below the step-3 size line? Run the check yourself; no reviewer by default. This is integration ownership; it is never delegated away.
- Not cheaply verifiable (and below the step-3 line) → spawn a blind reviewer that has not seen the implementation conversation (Sonnet tier default) — give it only the diff and the contract's acceptance criteria.
- Large (≈>20 files) OR any risk-domain touch → blind reviewer at the Opus tier with an explicit security/correctness focus — even when tests pass. Passing tests never waive it: they prove only what the test-writer thought of, and are partly self-graded when the implementer shaped the tests.
Every reviewer dispatch (template in dispatch-prompt.md) scopes the review to the changed code plus its callers and callees and demands a defect list (path:line + why it's wrong) and an answer to is there a meaningfully simpler or safer approach? — never an approve/reject verdict; a clean pass enumerates the properties/attack classes it checked. On a risk-domain diff the default-mode floor is one blind Opus reviewer (security-focused), not two — a second, adversarial Codex reviewer is thorough mode's falsify pass, or fires on an explicit Codex signal (unverifiable check, disputed expensive-to-undo design), never by default. You adjudicate the defect list; fixes route by the routing rule (mechanical fix → fast-worker; design flaw → deep-reasoner).
Consult the peer (peer.sh)
~/.claude/skills/orchestrate/peer.sh --backend codex --mode consult -C "$PWD" \
--prompt "Reply with exactly one word and nothing else: PONG"
For the peer to edit files, use --mode implement (workspace-write) and point -C at the working directory. For a long turn, run it via the Bash tool with run_in_background: true plus --out <file>, then Read that file when the task-notification fires — a multi-minute peer turn never blocks you. --effort low|medium|high|xhigh sets the peer's reasoning depth (codex default: xhigh); only budget modes change it.
The peer has no system prompt at all — every peer prompt must carry its own framing (the peer template in dispatch-prompt.md): independent second opinion, assume no shared context, conclusion + evidence ≤ 20 lines. On the blind-parallel path, the task body sent to Opus and to the peer must be verbatim identical — only the framing/preamble differs by path.
When to reach for Codex — the decorrelated peer
Route to Codex when the value is a decorrelated prior, not more horsepower. Never pick it because it is "better than Opus." Pick it because its errors are uncorrelated with Opus's, or because it has a comparative coverage edge (a different, sometimes more recent, training mix). A second Opus call resamples the same distribution and tends to repeat the same error confidently.
Fire on any one signal: unverifiable check · you are looping · disputed expensive-to-undo design · high-stakes parallel path (row 3) · "am I framing this wrong?" · unfamiliar/recent ecosystem · adversarial cross-review (falsify, don't review).
Do NOT reach for it when: cheaply verifiable (just verify) · mechanical or trivial · needs deep in-repo context Codex would re-acquire · you only want more confidence (an artifact is a reason; confidence isn't) · latency-critical and low-stakes.
Per-signal explanations: patterns.md.
The high-stakes parallel path
Launch both executors on the same problem, in one message, blind to each other — a peer.sh … --out file Bash call issued in the same turn as an Agent(subagent_type: "deep-reasoner", prompt: <same question>). Neither sees the other's answer. Then you reconcile.
Reconciling — the rules you must follow:
- Never reveal one executor's answer to the other during the blind round.
- Do not break ties by confidence, detail, or "industry-standard" priors. A 40-line confident analysis is not more correct than a 6-line terse one — length asymmetry is fluency, not evidence. And your own sense of "the more common pattern" resamples the same training distributions the executors drew from; it adds no independent information. Substantive disagreement is a stop condition, not a coin-flip.
- On disagreement: run one targeted reconcile round (now each may see the other's reasoning). If you spot an argument neither executor raised, feed it into that round as evidence for both to weigh — never adjudicate with it yourself. An argument that hasn't survived either executor's scrutiny is a hunch, not a tiebreaker.
- Still unresolved after the reconcile round → escalate to the human. The escalation brief IS the deliverable — producing it is settling your part of the decision, not failing to decide. "The user wants it settled now" does not transfer an unverifiable, expensive-to-undo call to you; the human usually holds exactly the facts the models lack (growth forecasts, compliance scope, budget, risk appetite).
- The brief has exactly four parts, in order:
- The decision at stake, and why it hit the parallel path (blast radius + unverifiable).
- Both positions at comparable depth — compress the longer, expand the terser; symmetric presentation is part of not tie-breaking by fluency.
- The crux variables the answer actually turns on, and for each, the fact that would settle it.
- The question(s) for the human.
There is no fifth part: no default pick, no "my recommendation", no lean.
- Accept agreement only when both point at the same checkable artifact — twin confident assertions are not consensus (they can share a blind spot).
Budget modes
Modes adjust routing tendency and verification intensity. They never silently lower quality: every skipped cross-check is announced in the plan and in the conclusion.
| Lever | economic | default | thorough |
|---|
| Row-3 parallel cross-check | Disabled. On a dual-condition hit: deep-reasoner solo + independent Sonnet review, and announce "economic mode skipped the cross-vendor check — human sign-off recommended" | Fires on the dual condition | Fires on the dual condition; reconcile rounds 1 → 2 before escalating |
| Borderline task (reasoning vs mechanical unclear) | Route down: fast-worker first, with the acceptance check; ladder up on failure | Judgment call per the table | Route up: deep-reasoner directly |
| Codex signals | Only "you are looping"; on other signals announce "cross-check available, skipped (economic)" | All seven | All seven, plus an adversarial falsify pass on high-stakes conclusions |
| Verification stage | Never cut; reviewer pinned to Sonnet — on a risk-domain diff announce "economic mode used a Sonnet reviewer on a risk-domain diff — Opus review recommended" | Cheap check → run it; else reviewer, calibrated by surface × risk | Implement-type always gets a reviewer (tests AND reviewer); risk-domain → Opus |
| Thinking depth | Claude executors unchanged; peer calls use --effort medium | Full; peer at its default (xhigh) | Full; peer at xhigh |
| scout / trivial-solo rows | unchanged | unchanged | unchanged |
Thinking depth is not a budget lever. Modes change who gets the task, never how hard the assignee thinks. The savings come from routing borderline work down and cutting the redundant second channel — both auditable, both announced. Hobbling the assignee instead produces confident-but-shallow answers whose rework costs more than the tokens saved. Concretely: deep-reasoner always thinks at full depth ("think thoroughly" is its role definition, not a mode setting — the cheap way to save is to dispatch it less, not to dispatch it and hobble it); fast-worker always executes directly without extended analysis (also role definition); the peer is the only executor with a hard depth knob (--effort), and only modes move it.
Custom roster (custom modifier) — roles and skills
Default roster = the three pinned agents + the peer, no injected skills; zero extra interaction. When invoked with custom (or the user asks mid-run), the roster takes two kinds of injectables — roles (who executes: an agent definition with a model pin) and skills (how a domain is worked: an installed skill whose procedure the matching executor should follow):
- Enumerate both kinds: the agent types visible to the Agent tool this session (alongside the default three), and the installed skills — glob
~/.claude/skills/*/SKILL.md plus the skills/ directories of installed plugins, reading frontmatter only (name: + description:), never a body. Exclude this skill itself.
- Ask the user (AskUserQuestion, multiSelect) which roles and which skills to use for this run — skills appear as concrete named options with their descriptions, never as "do you have one installed?".
- Slot each selected role into a tier — recon / mechanical / reasoning / peer — by its description. It inherits that tier's routing row, cost rules, and the ≤20-line return contract. The routing table itself never changes.
- A role whose definition pins no model does not enter the roster — pinning is what keeps spend predictable. Point the user at
agent-TEMPLATE.md (next to this SKILL.md) to author one properly.
Skill injection — how a selected skill reaches executors:
- Per-dispatch, by domain match. When a dispatched task falls inside a selected skill's described domain, add the Operating-skill line (dispatch-prompt.md skeleton) to that dispatch's Inputs: the executor reads the skill in its context and follows it as its procedure. Dispatches outside the domain never carry it — an injected skill serves matching work, not every dispatch.
- Never read the skill body yourself. The frontmatter description is the matching key (cost & context policy); the executor is the one who loads the procedure.
- It rides in the task body, so it reaches any executor that can read files — the peer included; on the blind-parallel path the injection line is part of the verbatim-identical task body both executors receive.
- Tier contract wins. An injected skill never overrides the tier's rules — status-first return, the return cap, scout's read-only bound. If the skill's procedure needs what the tier forbids (an editing skill matched to read-only recon), don't inject: announce the conflict and route per the table.
- Announce every injection in the plan (which dispatch carries which skill); a selected skill that matched no dispatch is announced at the end, never silently dropped.
Guardrail — the one failure mode to defend against
Two names for the same trap, one defense:
- Fragmentation (integration view): delegated pieces are each locally correct but conflict when you stitch them together.
- Rubber-stamping (reconciler view): you are judging executor output you often cannot yourself evaluate — so you drift toward the more fluent, more confident answer. This bites hardest on exactly the high-stakes, hard-to-verify tasks the parallel path exists to protect.
Defense (apply to every delegation):
- Delegate with a contract — the block above, up front.
- Demand a checkable artifact, not a verdict — a test that runs, a diff that applies, a cited quote, a reproduction — plus confidence and a "what would make this wrong" note. If a task cannot produce one, that is the signal it belongs on the parallel path.
- You retain integration ownership — verify every returned result against the repository and tests before you use it (the Verification stage).
- On the parallel path, enforce the disagreement-as-gate rules above.
Gotchas
codex exec hangs without < /dev/null. It prints Reading additional input from stdin... and blocks forever, even when the prompt is passed as an argument. peer.sh always redirects /dev/null; never call codex exec bare in a background job.
- Codex reasons at
xhigh by default and prints a header (model: …, sandbox: …) before the answer. The final answer is the text after the last codex marker; --out captures the whole transcript. A trivial consult is ~5s; a real design question ~10–15s.
~/.claude/agents/ may not exist. mkdir -p first (Setup does).
- A named subagent only resolves after its def is installed AND a session reload. Until then use
Agent(subagent_type: "general-purpose", model: "opus" | "sonnet" | "haiku") — same pinning, no reload needed.
- Keep your own context lean. The Cost & context policy is the rule set; the transcript-file trap is the classic violation.
Troubleshooting
peer: no prompt — pass one of --prompt "…", --prompt-file PATH, or - (stdin). Empty prompts are rejected.
- Peer output is just the header, no answer — the turn timed out (
--timeout, default 600s) or hit an auth error. Check codex login status; raise --timeout for large --mode implement jobs.
codex: command not found — install the Codex CLI and codex login. This skill drives codex exec directly through peer.sh; it does not depend on the /codex:rescue plugin (which remains a fine manual alternative).
peer: unknown --backend — only codex is built in; add a vendor by writing one backend_<name>() function in peer.sh.
peer: disabled by …orchestrate.peer-off (exit 3) — the persistent switch is off by user choice, not an error; announce the degradation and continue. peer.sh --on re-enables.