Orchestration playbook
The native workflow-authoring skill owns the script API (meta, agent()/pipeline()/
parallel(), schemas, resume, banned calls). THIS playbook owns what it doesn't: when a
fan-out is worth the money, who pays, which model and which agents the stages run on,
and the patterns that make runs converge.
When to orchestrate (any one of these)
- The work-list has >5 independent items (files to migrate, claims to check, modules to audit).
- A conclusion matters enough that independent adversarial verification could change it.
- The exploration would flood your context but you only need conclusions.
- The user said "thorough", "exhaustive", "all", "audit", "comprehensive".
When NONE hold: one or two Agent-tool subagents, or just do it inline. An orchestrated
trivial task is waste, not rigor.
The opt-in rule (ultracode)
The Workflow tool is opt-in — it can spawn dozens of agents, and the USER decides to pay
for that, not you. You may call it only when one of these holds:
- The user included the keyword "ultracode", or ultracode is on for the session (a
system-reminder confirms either).
- The user asked for orchestration in their own words ("use a workflow", "fan out
agents") — a task that would merely benefit from one does not count.
- A skill or slash command the user invoked tells you to call Workflow (the kit's
/hardmode:paranoid-review, /hardmode:verify-claim, /hardmode:deep-plan,
/hardmode:bug-hunt, /hardmode:increment qualify — the USER invoking the command is the
opt-in for that run; a skill you auto-triggered yourself is not).
Otherwise: use Agent-tool subagents, or briefly describe what a workflow would do and
roughly cost, and tell the user they can say "ultracode" or "use a workflow" to get it.
When a session IS opted in, the default inverts: orchestrate every substantive task,
ONE workflow per phase (understand → design → implement → review), reading each result
before deciding the next phase. Solo work is for conversational turns and trivial
mechanical edits only.
Model and agent policy (enforced)
- Every
agent() call carries an explicit model: 'opus' (default) or 'sonnet'
(cheap mechanical stages). Workflow agents NEVER inherit the session model — the
driver is the most expensive model on the box, and a 20-agent fan-out on an inherited
driver is a cost bug, not thoroughness. If a subtask is too demanding for opus, the
main loop does it inline instead of fanning it out.
- Kit agents are plugin-namespaced:
agentType: 'hardmode:verifier',
'hardmode:scout', 'hardmode:plan-critic', 'hardmode:oracle'. A bare 'verifier'
does not resolve and throws at spawn time — the stage silently returns null.
- Verification stages use
hardmode:verifier; exploratory stages (finders, hunters,
planners, judges, refuters) use hardmode:scout. Both are read-only by hook
enforcement, so a fan-out cannot modify the tree it analyses. Builders (the only
agents that should write) use the default agent type.
tools/check-workflows.mjs enforces all of this in CI, and the pre-flight lint hook
rejects an inline script that breaks it before any agent spawns. A concurrency cap of
min(16, CPUs−2) applies per workflow — on a small box, split a big fan-out into
several concurrent workflows.
Budget directives
A "+500k"-style directive from the user becomes a hard token ceiling, visible in scripts
as budget. Any unbounded loop MUST guard on budget.total first (with no target,
remaining() is Infinity and the loop runs to the agent cap):
while (budget.total && budget.remaining() > 50_000) { ... }. The ceiling THROWS inside
agent() — a bare await agent() outside parallel() needs .catch(() => null) or the
whole run rejects. The pool is shared across the main loop and all workflows.
Script quality (beyond the native reference)
- Scout the work-list INLINE first (cheap grep/ls), then fan out over known items —
don't make agents discover scope and process it in one breath.
- Three-way verdicts: confirmed / refuted / unverified. Refute-by-default filters kill
hard-to-demonstrate truths; always return what was killed and what couldn't be checked.
- Handle null: skipped/dead agents return null, and a throwing pipeline stage drops the
item and SKIPS its later stages. Seed coverage bookkeeping up front and remove entries
on success, so a dead or thrown stage can never read as "reviewed and clean".
- A schema that validates when empty needs an explicit ran/succeeded flag, or a failed
scan reads as a clean result.
Golden patterns (compose freely)
- Adversarial verify: N refuters per finding, fail-closed with veto semantics — one
concrete refutation sinks the claim; surviving requires positive "withstood" votes,
not silence (verify-claim is the reference implementation).
- Judge panel: N independent attempts from different lenses → judges score →
synthesize winner + best ideas of losers. For wide solution spaces (designs, plans).
- Loop-until-dry: keep spawning finders until K consecutive rounds surface nothing
new; dedup against ALL seen (not just confirmed), atomically per round. Cap rounds;
log the cap.
- Multi-modal sweep: parallel agents each searching a DIFFERENT way (by-name,
by-content, by-caller, by-history) when one angle won't find everything.
- Completeness critic: final agent asks "what's missing?" — its findings are the
next round.
- Verified increments: sequential build → fresh-context verify → one repair → gate
(increment is the reference implementation).
Cost discipline
- Set
effort: 'low' on cheap mechanical stages; effort: 'xhigh' on judges and
verifiers. isolation: 'worktree' ONLY when agents mutate files in parallel.
- Tell the user the fan-out size before launching anything above ~10 agents unless they
already opted into scale.
- After the run, read the RETURNED VALUE, not your expectation of it — if a result looks
empty, read journal.jsonl in the transcript dir before diagnosing.
Saved workflows already installed
/hardmode:paranoid-review (working-diff review, refute-by-default verification),
/hardmode:verify-claim (3 adversarial refuters + vote on any claim), /hardmode:deep-plan
(judge-panel planning), /hardmode:bug-hunt (loop-until-dry whole-repo sweep),
/hardmode:increment (verified increments). Check these before authoring a new script —
the pattern you need may already be a command.
1---2name: orchestrate3description: Etiquette and quality patterns for multi-agent Workflow runs — when to orchestrate, the opt-in rule, model pinning, plugin-namespaced agent types, adversarial-verify/judge-panel/loop-until-dry patterns. Use when a task spans many files/questions/items, when independent verification would change the answer, or when the user asks for exhaustive/thorough/parallel treatment. For the script API itself (syntax, resume, gotchas), load the native workflow-authoring reference.4---56# Orchestration playbook78The native `workflow-authoring` skill owns the script API (meta, agent()/pipeline()/9parallel(), schemas, resume, banned calls). THIS playbook owns what it doesn't: when a10fan-out is worth the money, who pays, which model and which agents the stages run on,11and the patterns that make runs converge.1213## When to orchestrate (any one of these)14- The work-list has >5 independent items (files to migrate, claims to check, modules to audit).15- A conclusion matters enough that independent adversarial verification could change it.16- The exploration would flood your context but you only need conclusions.17- The user said "thorough", "exhaustive", "all", "audit", "comprehensive".1819When NONE hold: one or two Agent-tool subagents, or just do it inline. An orchestrated20trivial task is waste, not rigor.2122## The opt-in rule (ultracode)23The Workflow tool is opt-in — it can spawn dozens of agents, and the USER decides to pay24for that, not you. You may call it only when one of these holds:25- The user included the keyword **"ultracode"**, or ultracode is on for the session (a26 system-reminder confirms either).27- The user asked for orchestration in their own words ("use a workflow", "fan out28 agents") — a task that would merely *benefit* from one does not count.29- A skill or slash command the user invoked tells you to call Workflow (the kit's30 /hardmode:paranoid-review, /hardmode:verify-claim, /hardmode:deep-plan,31 /hardmode:bug-hunt, /hardmode:increment qualify — the USER invoking the command is the32 opt-in for that run; a skill you auto-triggered yourself is not).33Otherwise: use Agent-tool subagents, or briefly describe what a workflow would do and34roughly cost, and tell the user they can say "ultracode" or "use a workflow" to get it.3536When a session IS opted in, the default inverts: orchestrate every substantive task,37ONE workflow per phase (understand → design → implement → review), reading each result38before deciding the next phase. Solo work is for conversational turns and trivial39mechanical edits only.4041## Model and agent policy (enforced)42- Every `agent()` call carries an explicit `model: 'opus'` (default) or `'sonnet'`43 (cheap mechanical stages). Workflow agents NEVER inherit the session model — the44 driver is the most expensive model on the box, and a 20-agent fan-out on an inherited45 driver is a cost bug, not thoroughness. If a subtask is too demanding for opus, the46 main loop does it inline instead of fanning it out.47- Kit agents are **plugin-namespaced**: `agentType: 'hardmode:verifier'`,48 `'hardmode:scout'`, `'hardmode:plan-critic'`, `'hardmode:oracle'`. A bare `'verifier'`49 does not resolve and throws at spawn time — the stage silently returns null.50- Verification stages use `hardmode:verifier`; exploratory stages (finders, hunters,51 planners, judges, refuters) use `hardmode:scout`. Both are read-only by hook52 enforcement, so a fan-out cannot modify the tree it analyses. Builders (the only53 agents that should write) use the default agent type.54- `tools/check-workflows.mjs` enforces all of this in CI, and the pre-flight lint hook55 rejects an inline script that breaks it before any agent spawns. A concurrency cap of56 min(16, CPUs−2) applies per workflow — on a small box, split a big fan-out into57 several concurrent workflows.5859## Budget directives60A "+500k"-style directive from the user becomes a hard token ceiling, visible in scripts61as `budget`. Any unbounded loop MUST guard on `budget.total` first (with no target,62`remaining()` is Infinity and the loop runs to the agent cap):63`while (budget.total && budget.remaining() > 50_000) { ... }`. The ceiling THROWS inside64`agent()` — a bare `await agent()` outside `parallel()` needs `.catch(() => null)` or the65whole run rejects. The pool is shared across the main loop and all workflows.6667## Script quality (beyond the native reference)68- Scout the work-list INLINE first (cheap grep/ls), then fan out over known items —69 don't make agents discover scope and process it in one breath.70- Three-way verdicts: confirmed / refuted / unverified. Refute-by-default filters kill71 hard-to-demonstrate truths; always return what was killed and what couldn't be checked.72- Handle null: skipped/dead agents return null, and a throwing pipeline stage drops the73 item and SKIPS its later stages. Seed coverage bookkeeping up front and remove entries74 on success, so a dead or thrown stage can never read as "reviewed and clean".75- A schema that validates when empty needs an explicit ran/succeeded flag, or a failed76 scan reads as a clean result.7778## Golden patterns (compose freely)79- **Adversarial verify**: N refuters per finding, fail-closed with veto semantics — one80 concrete refutation sinks the claim; surviving requires positive "withstood" votes,81 not silence (verify-claim is the reference implementation).82- **Judge panel**: N independent attempts from different lenses → judges score →83 synthesize winner + best ideas of losers. For wide solution spaces (designs, plans).84- **Loop-until-dry**: keep spawning finders until K consecutive rounds surface nothing85 new; dedup against ALL seen (not just confirmed), atomically per round. Cap rounds;86 log the cap.87- **Multi-modal sweep**: parallel agents each searching a DIFFERENT way (by-name,88 by-content, by-caller, by-history) when one angle won't find everything.89- **Completeness critic**: final agent asks "what's missing?" — its findings are the90 next round.91- **Verified increments**: sequential build → fresh-context verify → one repair → gate92 (increment is the reference implementation).9394## Cost discipline95- Set `effort: 'low'` on cheap mechanical stages; `effort: 'xhigh'` on judges and96 verifiers. `isolation: 'worktree'` ONLY when agents mutate files in parallel.97- Tell the user the fan-out size before launching anything above ~10 agents unless they98 already opted into scale.99- After the run, read the RETURNED VALUE, not your expectation of it — if a result looks100 empty, read journal.jsonl in the transcript dir before diagnosing.101102## Saved workflows already installed103/hardmode:paranoid-review (working-diff review, refute-by-default verification),104/hardmode:verify-claim (3 adversarial refuters + vote on any claim), /hardmode:deep-plan105(judge-panel planning), /hardmode:bug-hunt (loop-until-dry whole-repo sweep),106/hardmode:increment (verified increments). Check these before authoring a new script —107the pattern you need may already be a command.