Decide whether a non-trivial task (code, research, writing, analysis or operations) should run as a plain session, a plain session plus an independent reviewer, or the multi-agent orchestrator pipeline. Use before starting a non-trivial task, or when asked "should I orchestrate this".
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Route?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/emberfields-route)
---
name: route
description: Decide whether a non-trivial task (code, research, writing, analysis or operations) should run as a plain session, a plain session plus an independent reviewer, or the multi-agent orchestrator pipeline. Use before starting a non-trivial task, or when asked "should I orchestrate this".
argument-hint: <task description>
---
Size the task before doing it.
Health check: a task that asks to scan, audit or check a project or part of it for bugs, security problems, dependency problems or dead code, and not to fix a known problem, skips the sizing below: load the `health-check` skill (`orchestration:health-check`) and follow its interactive mode. It shows the findings, changes nothing before the person has chosen what to fix, and sizes the chosen fixes with this skill.
1. Get the route.
- If `${ORCH_HOME:-$HOME/claude-code-orchestration}` contains both `package.json` and `node_modules`, run the triager. `--repo` is the folder the task is about (any folder; a git repository is not required); substitute its absolute path for `$TASK_DIR`.
First write the task to a file with your file-writing tool, never with a shell command: the text between the `<task>` tags below, exactly as given, into a new file named `route-task.txt` in your session's scratchpad folder (if you have none, run `mktemp -d` and use the folder it prints). Substitute that file's absolute path for `$TASK_FILE`; the path never contains any of the task's words. Then run:
```bash
(cd "${ORCH_HOME:-$HOME/claude-code-orchestration}" && CLAUDE_PLUGIN_DATA="${CLAUDE_PLUGIN_DATA}" npm run --silent route -- --repo "$TASK_DIR" --task-file="$TASK_FILE"); rc=$?; rm -f "$TASK_FILE"; (exit "$rc")
```
No shell reads the task text: `--task-file` makes the triager read the file itself, so quotes, backticks, `$`, several lines or a leading dash are all just text. The command removes the file when it ends.
<task>
$ARGUMENTS
</task>
It makes one cheap read-only model call and prints JSON: `mode`, `reason`, and the `facts` behind it (`filesToTouch`, `linesToChange`, `independentSlices`, `risky` and `code`). It also appends the decision to `routes.jsonl` in that folder's state dir: `.claude/state/` when the project registers the orchestration hooks itself, otherwise the plugin's per-user dir, so nothing is written into the folder.
- Otherwise (no checkout, e.g. a plugin-only install) size the task yourself. Skim the folder, then estimate five facts:
- `code`: true when the task creates or changes source code, tests, build or CI configuration in a repository; false for research, writing, analysis, planning or operations whose output is documents, data, answers or commands run. It changes one rule of the mode, the file count in rule 4. It also decides whether step 2 uses git machinery and how you check the result; the test gate does not read it. When unsure, count it as code.
- `filesToTouch`: files the task creates or changes, of any kind (source, docs, reports, data, config).
- `linesToChange`: lines added or changed, prose and data included, new files included.
- `independentSlices`: parts separate workers could do at the same time with no shared output file and no dependency (modules, documents, or research questions combined at the end); 1 when sequential or small.
- `risky`: a wrong result is costly: security, authentication, payments, data migrations or deletion, public API changes, production operations (deploys, infrastructure, credentials), content sent or published outside the team, or several modules where a wrong change is costly.
Apply these rules in order, the same as `TRIAGE` in `src/config.ts`:
1. risky, fewer than 2 independent slices, at most 3 files and at most 200 lines: `reviewed`.
2. risky otherwise: `orchestrate`.
3. 12 or more files: `orchestrate`.
4. 2 or more independent slices and (10 or more files when `code` is true, 4 or more when it is false, or 1500 or more lines): `orchestrate`. An interface-first plan lets those slices run in parallel, where step 2 allows it, even across few files.
5. Otherwise `plain`. A large but sequential change stays plain: one session keeps a coupled design in one context.
Thresholds: minParallelSlices 2, minParallelFilesCode 10, minParallelFilesNonCode 4, bigFiles 12, reviewedMaxFiles 3, bigLines 1500, reviewedMaxLines 200.
Then, if a route-recording tool is listed (`mcp__orchestration__route`, or `mcp__orchestration-dashboard__route` when the standalone dashboard mod is loaded), call it once with the mode, the reason and the five facts so the orchestration pane shows the triage. If no such tool is listed, carry on.
2. Tell the user `Route: <mode> - <reason, a few words>` on one line, then act on it. Write to the user in short bullets or key: value lines: progress in one short line, only when something changed; a final report of at most 15 lines (plain and reviewed: what changed, the check and its result, what is open; orchestrate: one line per slice, `<id>: pass|fail - <evidence pointer>`, then `health: <n> found, <n> fixed, <n> listed` or `health: skipped - <why>` (the health check below; no line when the light path or work that changes no code skipped it), for code in git `handoff: <branch> at <commit>` or `handoff: none - <why>`, then, when the hand-off made a branch, `Next: type /ship` (`Next: type /steward` when a pull request for it exists), then what is open); more detail only when the user asks. Only code in a git repository uses git machinery (worktrees, the integrator, checkpoint commits, the hand-off, branch reports, `git diff` reviews). The test gate runs the tests whenever a test command exists (detected or configured) and skips them only for a prose-only change in a git work tree; it judges the changed files, never `code`. The review gate applies to every task.
- `plain`: do the task in this session. If it changed code, run the project's tests before saying it is done; otherwise check the result against the request (every requested item is there, and each claim is backed by a source you read).
- `reviewed`: do the task here, then have `orchestration:reviewer` check the result before reporting: `git diff HEAD` for code in a git repository, otherwise the files or answer you produced, with the request and what a correct result must contain.
- `orchestrate`: act as the orchestrator in this session. Ask at most 6 researcher questions, plan at most 12 slices with disjoint output files, delegate with the Agent tool to `orchestration:researcher`, `orchestration:implementer`, `orchestration:reviewer` and `orchestration:integrator`, and implement nothing yourself. Give each slice an acceptance check: the narrowest command that proves the slice for code (the tests of the files it owns), otherwise a checklist a reviewer can verify by reading the output and its cited sources. The test gate runs the project's whole suite when an implementer stops and the integrator runs it once more after the merge, so a brief never also asks a worker to run the whole suite: the integrator's brief is the one that names the project's whole suite. A hook checks every implementer launch: start each brief with `SLICE: <id>`, `FILES: <files it owns, comma-separated>` and `DEPENDS: <slice ids it runs after, or none>`, and before launching the first implementers of a plan with several slices send the plan to `orchestration:reviewer` in a brief that starts with PLAN REVIEW and wait for its report (only the light path, a single slice of at most 3 files and about 1,500 lines with nothing risky, skips the plan review, with `PATH: light` in the brief). In that brief, put the task's hard requirements (MUST and MUST NOT rules, forbidden imports or dependencies, required formats, interfaces, limits) in a `CONSTRAINTS:` block of `C<n>: <text>` lines, and write each slice as its `SLICE:`, `FILES:`, `DEPENDS:` and `GOAL:` lines (the orchestration pane's progress bar reads them), plus `RISKY: yes` when it is risky and `CHECKS: <ids>` for the constraints its files can break. Implementer and reviewer briefs carry the slice's `CHECKS:` line and the text of each constraint it names; workers answer each id (`C1: pass (cmd) <command> -> <result>`, `C1: pass (read) <file:line or URL>` or `C1: fail <reason>`). Those lines are optional: without them no constraint is tracked or gated and no slice counts as risky. A bug-fix slice carries `KIND: bugfix`: its implementer writes a failing reproduction test before the fix. A researcher brief may start with `SOURCES: <paths or URLs>` and `READ: lookup|extract|judge`; ask researchers to back facts read from files with `QUOTE: <locator> | <verbatim text>` lines. Review each slice as soon as its implementer returns, start each reviewer brief with `SLICE: <id>`, and add `FOCUS: <what to check hardest>` when a slice has a known risk. Reviewers list each gap as `GAP: <0-100> <text>` with their confidence. When a slice clearly needs an installed skill you know (a document skill for a .docx, .pptx, .xlsx or .pdf deliverable, a frontend skill for UI work, a security review skill for a risky auth change), add `SKILLS: <comma-separated skill names>` to that implementer, researcher or reviewer brief, each name exactly as the Skill tool lists it (`anthropic-skills:docx`, `frontend-design`, `<plugin>:<skill>`); never invent a name and never give one to the integrator. Load yourself at most two installed skills that shape the plan itself (domain rules, architecture, a threat model), since each loaded skill stays in your context; every other fitting skill goes to the workers by name. In the PLAN REVIEW brief a slice may carry `SKILLS: <names>` or `SKILLS: none`, and a RISKY slice always carries one of the two. The plan check may append suggested skills to those briefs; workers load each named skill with the Skill tool before starting and ignore one that does not fit (saying so in one line of the report, not under OPEN, since a non-empty OPEN is a doubt signal), and end the report with `SKILLS-USED:` and `SKILLS-SKIPPED:` lines. New skill: when no installed skill covers knowledge the task needs and that knowledge is reusable beyond this task, the plan may hold one skill slice per run; when a person can answer, propose it first (name, when it triggers, target, category) and wait for a yes, and in an unattended run do not ask. Its implementer brief adds `KIND: skill`, `SKILL: <name>` and, for the public repository only, `TARGET: public`, with FILES relative to the skills repository (`skills/<name>/, README.md`); it never runs with `isolation: worktree`, reports `DRAFT: <name> <branch>` instead of BRANCH, and the integrator never merges it. Later slices that need it carry `DRAFTS: <name>`. If it fails for good, or the plan check blocks it with `skill_create_off` or `skill_repo_missing`, do the task without it and say so in the report; the report names the draft and its branch, and publishing it is a separate step a person runs.
- Run scope: a run opens at the PLAN REVIEW (or the light-path implementer launch) and closes when every slice is final; a new prompt does not close it. While it is open the plan check blocks fork and built-in subagents (`builtin_agent_in_run`) and implementers whose SLICE or FILES are not in the reviewed plan (`not_in_plan`); to change the plan, send the plan review again.
- Escalation: a RISKY slice gets two `orchestration:reviewer` launches in one message with the same brief, one with model "opus" and one on the default model; it passes only when both pass (`second_review_required`). Wait for both reports before you validate gaps or retry; a failing review from either goes through the retry below. A new attempt is reviewed by two fresh reviewers, never a resumed one. When a gap validation confirms no gap, its pass counts as one of the two: send one more fresh reviewer, with model "opus" when no pass of the attempt ran on opus. When a reviewer launch is refused with `tests_failed_after_report`, resume the implementer first and launch the two reviewers only after it has reported again. For other slices, when a passing review shows a doubt signal (any `(read)` answer, a non-empty OPEN, a retry, an isolated test failure, a test gate that gave up on the slice's latest attempt, or a failing review whose gaps are all below the cutoff, which counts as a pass with a doubt signal), send the slice to an `orchestration:reviewer` with model "opus" before accepting it. The Stop gate enforces this (`opus_review_required`). For a slice that is not RISKY, when the opus review is certain before the review starts (a retry after a failed review, or the slice has checked constraints (a `CHECKS:` line) and no command can prove any of them, so every answer will be `(read)`), launch its one review on opus directly instead of a default-model review followed by an opus one; that review is the slice's review. On its first review, a slice with no checked constraints (no `CHECKS:` line) starts on the default model; a retry after a failed review still goes to opus directly. When in doubt whether a command can prove a constraint, start on the default model.
- Retry and replan: a review fails on a failed checked id or a gap with confidence 80 or more. Before sending those gaps back, send them with the diff (or output files) to a fresh `orchestration:reviewer` whose brief starts with `SLICE: <id>` and `VALIDATE: gaps` (plus the slice's CHECKS line and constraint texts), and forward only the gaps it confirms; if it confirms none, its pass is the slice's review and the opus escalation for a retry applies. Send the confirmed gaps to the same implementer with `SendMessage` (the retry's review of a slice that is not RISKY runs on opus directly); for an isolated slice, check that the BRANCH in its resumed report equals the branch it reported before, and if it differs or `SendMessage` fails, start a fresh implementer on that branch's worktree. Run the third and last attempt as a fresh `orchestration:implementer` with model "opus", the full brief and the confirmed gaps; a slice whose review still fails then has failed for good. Then, or when a launch or the Stop gate blocks with `replan_required` (two failing reviews of a slice in a row that report the same gap), do not retry: send one PLAN REVIEW brief with a `REPLAN: 1` line that plans only the missing work (new slice ids allowed; DEPENDS may name finished slices). When the Stop gate blocks with `implementer_unfinished` (an implementer ran out of turns or was stopped before it finished, so nothing tested or reviewed its work), resume it with `SendMessage` so it finishes, or start a fresh implementer for the slice, then review the result; a partial result is never a finished slice. An implementer's report arrives before its test gate has finished: when a reviewer launch for its slice is refused with `tests_failed_after_report`, the tests failed after the worker reported, so resume that implementer with `SendMessage` (the refusal names its agent id), then review. At most one replan per run; report which slices it replaced.
- Waiting: subagents run in the background and their results arrive as a new turn, so ending your turn to wait is fine, interactively and in `claude -p` (it waits for background subagents before exiting). `claude -p` does not wait for background shell tasks, so never leave a Bash `run_in_background` task running at the end of a headless run. A `completed` notification from a worker that already handed back its report is not a new report and needs no new review, retry or reply (a late shell task of its own woke it). The Stop review gate defers while a subagent or workflow is still running (`agents_running`). Never write the final report until every worker has reported.
- Wave: at most 4 implementers run at a time. With more ready slices, launch 4 and start the next ready slice when one reports. A launch refused with `wave_full` means wait for a running implementer's report, then launch it again (in worktrees the plan check may allow fewer when the project's test suite is slow).
- Code in a git repository: parallel slices use `isolation: worktree` and `orchestration:integrator` merges them. Before any parallel worktree wave, confirm `worktree.baseRef` is "head" in `.claude/settings.json`, `.claude/settings.local.json` or `~/.claude/settings.json` (worktrees otherwise branch from the remote default branch and miss local work); if it is not, run the slices one after another in the shared tree. If earlier shared-tree slices left uncommitted work, first send `orchestration:integrator` a brief starting with CHECKPOINT, a label and the files those slices own, and check the `CHECKPOINT:` field of its reply (a commit hash) before launching the wave; on fail or "none", run the wave sequentially instead. Every CHECKPOINT, merge and HANDOFF brief names the run's branch and head commit (the integrator stops on a mismatch); when the run's branch is the repository's default branch, a brief that makes the integrator commit or merge also names a new branch (such as `orch/<short task words>`), which the integrator creates first and which is the run's branch from then on; on the default branch, send that CHECKPOINT before a parallel wave even when no earlier slice left work, and on fail run the wave sequentially.
- Health check: once every slice is final (after a merge, also the review of the merged result) and before the hand-off, check the changed code once, but only in a run that changed code in a git repository and has at least one passed slice. Skip it on the light path, for work that changes no code, when the task says to skip the health check, when the task itself is a health check, and after its own fix slices: it never triggers itself. Load the `health-check` skill (`orchestration:health-check`) and follow its "Automatic mode" section: bugs and security in the files the run's passed slices changed, no more than four researchers, then one `orchestration:reviewer` that runs the project's check commands and changes no file; without asking it fixes only critical or high findings that reviewer confirmed with a command, and lists the rest. Loading it does not count toward the two plan-shaping skills, and its scan researchers and its confirming reviewer come on top of the researcher questions above. Its fix slices (no more than four, the most severe first) take new ids, `hc1` to `hc4`, and open a new plan review once the run's slices are final (or the light path for one slice that is not risky); they then get the test gate and review like any slice, a bug fix with `KIND: bugfix` and a security fix with `RISKY: yes`. One scan and one round of fixes: the fix run never triggers the check again. The hand-off then includes the fix slices' files; the check itself never pushes, opens a pull request, merges or tags.
- Hand-off (code in a git repository only): once every slice is final, send `orchestration:integrator` a brief that starts with HANDOFF and names the run's branch and head commit, a new branch that does not exist yet (such as `orch/<short task words>`), the exact files of every slice that passed (never a skill slice's) and a commit subject; it creates the branch, stages those files by name, commits, never pushes, and reports `BRANCH:` and `CHECKPOINT:`. Skip it when the task says not to commit or when no slice passed. When the integrator could not create the branch (a headless run denies it), nothing is committed: the final report says the reviewed files are uncommitted and why.
- Publishing is the person's: only the person starts `/ship`, which pushes the hand-off branch, opens the pull request and watches CI (`/steward` watches an existing pull request). Never invoke `/ship` or `/steward`, or the `ship`, `ship-local` or `steward` skills. Pushing, pull requests and CI watching are `/ship`'s by default; brief `orchestration:integrator` to push, open a pull request, merge, tag or create a release only when the person asked for exactly that in their own words in this session, and quote those words in its brief.
- Code outside a git repository: worktrees are impossible, and the test gate runs the whole suite on the shared tree each time an implementer finishes, so parallel siblings would fail each other's gate. Run the slices one after another in the shared folder; nobody commits.
- Work that changes no code: slices run in the shared folder with no worktrees, no integrator and no commits. Slices with disjoint output files may run in parallel in one message without isolation; slices that depend on each other run one after another.
- Every deliverable is reviewed. If you write the answer yourself from the researchers' findings, no implementer runs and the Stop gate never fires, so send the draft and its sources to `orchestration:reviewer` before replying (a second `orchestration:reviewer` with model "opus" when the answer is risky), and fix or flag what it reports. Small question: a question about the project that changes nothing and that at most 5 of your own Read, Grep or Glob calls can settle is answered directly, with a file and line reference for each fact and no researcher, and goes to `orchestration:reviewer` only when a wrong answer is costly.
Fixed-order option: the gated workflow `/orchestration:orchestrate` (project copy: `/orchestrate`) runs the orchestrate route with its order fixed in code (plan with a constraints ledger, build, review with opus escalation, one replan, integrate). Only the user starts it: suggest it when a fixed order helps, never start it unasked.
For an unattended run use `claude -p --agent orchestration:orchestrator`.
3. If the user disagrees with the route, follow their choice. The thresholds live in `src/config.ts` (`TRIAGE`) in the orchestration repo.