agentleFS
EMBERFIELDSEMBERFIELDS/claude-code-orchestration/.claude/skills/route/SKILL.md

route

Skill2 starsChanged 7 days agoMITView on GitHub

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".

23 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use learn, plan and 2 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • genomewalkerSkill

    learn

    Learn from web sources, generate SKILL.md, and store key patterns in soul memory. Trigger keywords: learn, skill-gen, web-learn, documentation, tutorial.

    Also in 3 projects that use this

  • BlockSkill

    plan

    Draft a TDD, PRD, or lightweight plan in the conversation without committing it.

    Also in 3 projects that use this

  • GoogleSkill

    prototype

    Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.

    Also in 3 projects that use this

  • MicrosoftSkill

    handoff

    Compact the current conversation into a handoff document for another agent to pick up.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 21 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If ${ORCH_HOME:-$HOME/claude-code-orchestration} contains both package.json and node_modules, run the triager.

    line 9
  2. Very specific:

    No shell reads the task text: --task-file makes the triager read the file itself, so quotes, backticks, $, several lines or a leading dash …

    line 17
  3. Very specific:

    If the user disagrees with the route, follow their choice.

    line 62

“Common” is measured: kept by at least 6 in 10 of the 21 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Size the task before doing it.

  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:

      (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.

  1. 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>, 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.
      • 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.

  2. If the user disagrees with the route, follow their choice. The thresholds live in src/config.ts (TRIAGE) in the orchestration repo.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.