harness-orchestrator
Skill1 starsChanged 3 months agoMITView on GitHub
Use to drive a multi-step build from a requirement — decompose it into tasks, route each through harness-model-router, and dispatch every task to a fresh, self-grounding, self-verifying subagent instance. Coordinates the other harness skills and tracks resumable progress. Invoke when the user asks to implement a feature "with the harness" or wants grounded, verified, end-to-end generation.
In this repository6 other files it gives its agents.
- harness-analyzerSkill
- harness-context-loaderSkill
- harness-learningsSkill
- harness-model-routerSkill
- harness-verifierSkill
- verifySkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 0 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 42
If the project has no generated project-* grounding skills under .claude/skills/ (and no wired CLAUDE.md), run harness-analyzer first.
- Very specific: line 67
Read .claude/harness/state.md if it exists.
- Very specific: line 103
If an existing state.md predates this schema (no Run ID: line, or missing Conventions & Decisions / Files touched / Learning candidates …
- Very specific: line 124
Write the decomposed tasks into the ## Tasks list of .claude/harness/state.md (in addition to TodoWrite).
- Very specific: line 132
Every task — parallel or serial, folded batch or not — runs in a fresh Agent() instance, never inline in your own context.
- Very specific: line 243
Every decomposed task is complete ([x], none left [!] without the user having been told).
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Harness Orchestrator
Drive a requirement from idea to verified, tested code by running a disciplined loop. You are the orchestrator — you decompose the work and run each step using your own tools and the other harness skills. There is no external runner.
The loop
Requirement
↓
Write requirement.md (verbatim, never mutated again)
↓
Decompose into ordered tasks + dependency graph
↓
harness-model-router scores every task, tier + fold batches
↓
For each task/batch, dispatch a FRESH Agent() instance at its tier:
ground → the instance calls harness-context-loader itself
plan → the instance decides the approach against that context
build → the instance implements the change
verify → the instance calls harness-verifier itself (all gates); fix on red
test → the instance adds and runs tests; fix until green
report → structured result back to the orchestrator
↓
Orchestrator updates state.md ledgers, dispatches next task/batch
↓
All tasks done → feature-complete spec-conformance pass → independent code-review pass → harness-learnings
↓
Feature completeThe orchestrator itself never grounds, builds, or verifies — it only decomposes, routes, dispatches, and tracks. This keeps its own context small for the life of the run, which is what lets the run survive compaction without losing the requirement's crux (the crux lives in requirement.md and the state.md ledgers, not in conversation history).
Procedure
1. Ensure grounding
If the project has no generated project-* grounding skills under .claude/skills/ (and no wired CLAUDE.md), run harness-analyzer first. It generates those skills and wires CLAUDE.md so the flow below is the default for every request. Everything downstream relies on this grounding.
2. Capture the requirement verbatim
Write .claude/harness/requirement.md — the durable, never-mutated for the life of a run anchor for the original ask. Whether you write it fresh or skip and read the existing one is decided by step 3's new-run-vs-resume check, not by this step in isolation — step 3 makes that call once and it governs both files together; don't duplicate the check here.
# Original Requirement
## Verbatim request
<the user's full original request, unedited>
## Artifacts
- Description: <inline text, or "none">
- Reference URL: <url, or "none">
- Screenshot/mock: <path under .claude/harness/spec-assets/, or "none">
## Extracted acceptance criteria
- <bullet, derived directly from the verbatim request — do not reword away from what was actually asked>If the user provided a screenshot, save it under .claude/harness/spec-assets/ and record its path here. This file is what harness-context-loader and the feature-complete spec-conformance pass (harness-verifier) read later — because it's never edited once written, the crux of the ask can't drift across a long run.
3. Initialize loop state
Read .claude/harness/state.md if it exists.
A [!] blocked task present, and every other task is [x] — this is NOT automatically a new run. Read the [!] task's recorded failure summary (why it was blocked). If the incoming request plausibly answers that specific question or decision, treat this as a resume: skip to the Resume paragraph below, record the answer as a new line in Conventions & Decisions, mark the task [>] again, and re-dispatch it — no new run_id, requirement.md untouched. Only if the incoming request is clearly unrelated to the blocked task's question (a genuinely different ask) does it count as a new run — this is the intentional escape hatch for a permanently-abandoned blocked task; its old [!] entry stays in the historical record exactly like any other completed run's tasks.
New run — file missing, every task in it is [x] with no [!] present, or (per the judgment call above) a [!] task judged abandoned: mint run_id = the current ISO-8601 timestamp (e.g. 2026-09-02T19:35:46Z), overwrite .claude/harness/requirement.md with the new ask (step 2), and (re)create state.md:
## User ask
<2-3 line summary of the original request>
Full requirement: .claude/harness/requirement.md
Run ID: <the minted run_id>
## Tasks
- [ ] 1. <task>
- [ ] 2. <task>
## Conventions & Decisions
- (nothing yet, or carried forward — see below)
## Files touched
| Path | Status | Owner task |
|---|---|---|
## Learning candidates
- (nothing yet)
## Done so far
- (nothing yet)Conventions & Decisions and Files touched are the two exceptions that carry forward across runs — if a prior state.md existed (a previous run in this same project already completed), copy its final Conventions & Decisions and Files touched content into the fresh file rather than resetting them; they're cumulative project knowledge, not run-scoped. Everything else (Tasks, Done so far, Learning candidates) resets for the new run.
Only on this new-run branch, also create (if absent) or leave in place .claude/harness/log.jsonl — a single, flat, never-reset, append-only file spanning every run this project has ever had — and append the start event: {"event":"start","ts":"<ISO8601>","run_id":"<run_id>","ask":"<the verbatim request>"}.
Resume — state.md exists with any task not [x] (including a [!] task judged answerable per the paragraph above — mark it [>] again before dispatch), or with a [!] task judged answerable as described above: read it instead of overwriting, reuse the Run ID: line already recorded there for every event you append this loop (except start — never append a second start event for a run already in progress), and continue from the first non-[x] task (a resumed [!] task, now [>], counts here); skip minting a new run_id, skip re-writing requirement.md, and skip the start event above. If .claude/harness/log.jsonl is missing (e.g. deleted), create it empty but still do not append a start event — the run already has a Run ID:, so from this file's point of view it's mid-run, not beginning.
If an existing state.md predates this schema (no Run ID: line, or missing Conventions & Decisions / Files touched / Learning candidates headings), add the missing pieces (mint a run_id for it now) rather than treating their absence as an error — never rewrite what's already there.
Conventions & DecisionsandFiles touchedare append-only, deduplicated ledgers — one entry per fact, regardless of how many tasks later touch the same file. They're what a freshly-dispatched task instance reads to avoid contradicting or redoing prior work. Keep entries to one line each: e.g.Auth errors: AuthError type, defined in src/types/auth.ts (task 1).Done so farkeeps a full structured entry (see step 5's report format) for the last 5 completed tasks; older entries fold to a single[x]summary line once their exports/files/decisions have been migrated into the two ledgers above. This bounds the file's size independent of run length.Learning candidatesstages high-signal learnings during the loop (consumed byharness-learnings, step 7) — only append on: an explicit user correction,harness-verifiercatching the same pattern violation twice in one run, a debugging pass surfacing a non-obvious project-specific gotcha, or an end-of-run review pass identifying a generalizable pattern — not a one-off bug in the code it reviewed, but a reusable rule about how work should be built or tested in this project (e.g. "assert-on-order tests must use data where a correct and a plausibly-broken implementation diverge — verify by mutation").
4. Decompose and route
Break the requirement into the smallest sensible, independently-verifiable tasks. Order them by dependency; mark which are genuinely independent (parallel-eligible) vs. which depend on earlier tasks (serial). Track them with a todo list (TodoWrite) so progress is visible and nothing is dropped. Example:
"Add email/password auth" →
- Auth context +
useAuthhook- Login form
- Signup form
- Protected-route wrapper
- Integration tests
Size every task S or M before writing it down — never larger. S = touches 1 file. M = touches 2-3 files. If a natural task would touch 4+ files, split it along its natural seams (e.g. the type/schema change, the UI change, and the API route each become their own task) rather than dispatching one oversized task to a single agent. This is a scope cap, independent of harness-model-router's complexity tiering below — a task can be S-sized and opus-tier (small scope, hard problem) or M-sized and haiku-tier (several files, all mechanical); size and complexity are separate axes.
The only exception: a task that genuinely can't be split below M without breaking its own coherence (e.g. a mechanical rename touching every call site of a renamed export) — note it as an oversized exception with a one-line reason next to it in state.md's ## Tasks list, rather than forcing an artificial split that produces tasks nothing can independently verify.
Write the decomposed tasks into the ## Tasks list of .claude/harness/state.md (in addition to TodoWrite). state.md is what survives compaction and restarts; TodoWrite is the live in-session view of the same list.
Then invoke harness-model-router with the entire task list (not just parallel ones) — for each task, pass its description, its size (S/M from the sizing step above), whether it's parallel or serial, and whether its acceptance criteria were unclear enough during this decomposition to flag as ambiguous — plus the size-floor table from CLAUDE.md's config sub-block (## Harness configuration → "Model tier floor by task size") — to get a routing table: each task's model tier (clamped to the configured floor, never below it), and which adjacent serial haiku-tier tasks fold into one batch. Record each task's tier next to it in state.md's ## Tasks list, e.g. - [ ] 2. Login form [tier: sonnet].
Append a decompose event to log.jsonl: {"event":"decompose","ts":"<ISO8601>","run_id":"<run_id>","tasks":[{"id":"1","title":"<short>","size":"S","model":"haiku"}, ...],"task_count":<N>}.
5. Dispatch every task to a fresh instance
Every task — parallel or serial, folded batch or not — runs in a fresh Agent() instance, never inline in your own context. This is what keeps your context small for the whole run.
Mark the task (or batch) [>] in .claude/harness/state.md, including its tier and attempt count — e.g. - [>] 2. Login form [tier: sonnet, attempts: 1] — and in-progress in TodoWrite. Build the dispatch brief:
=== ORIGINAL REQUIREMENT ===
Read .claude/harness/requirement.md first — the full, verbatim ask.
=== YOUR TASK ===
Task <N>: <description>
(For a folded batch: list all folded tasks' descriptions, in order.)
You are a fresh instance. Ground yourself: call harness-context-loader.
=== HANDOFF FROM PRIOR TASKS ===
<verbatim copy of the current "Conventions & Decisions" + "Files touched"
sections from state.md, plus the last 1-2 full "Done so far" entries
if they're in the same area as this task>
=== REQUIRED REPORT FORMAT ===
Status: done | blocked-verification | blocked-ambiguous | blocked-decision
Approach: <3-6 high-level bullets of how you broke this task down / the steps you took>
Files created/modified | Exports | Conventions introduced | Deviations (+why)
Verification: full harness-verifier gate report with real command output
Learning candidates: <one-liners for anything matching state.md's staging triggers — an
explicit user correction, harness-verifier catching the same pattern violation twice, or
a non-obvious project-specific gotcha surfaced while debugging — or "none">
If blocked: reason + exact question/decision neededDispatch it:
Agent({
prompt: "<the dispatch brief above>",
model: "haiku", // or "sonnet" / "opus" — this task's (or batch's) tier from harness-model-router
})- Independent tasks dispatch in parallel — multiple
Agent()calls in one turn (seesuperpowers:dispatching-parallel-agents). Use worktree isolation if they touch overlapping files. - Dependent (serial) tasks dispatch one at a time, in order, each waiting for the prior one's result — but each is still its own fresh instance, not inline work in your context.
- Folded batches (from
harness-model-router) dispatch as oneAgent()call carrying every task in the batch; the instance builds and verifies all of them together as one unit.
The dispatched instance is responsible for its own ground → plan → build → verify → test loop, including calling harness-context-loader and harness-verifier itself — you never call either directly for a task's build. You only read back its structured report.
Every dispatch result — done, blocked, or shape-invalid — gets logged in two places, before anything else happens with it:
- Append one
dispatchevent tolog.jsonlfor this attempt:{"event":"dispatch","ts":"<ISO8601>","run_id":"<run_id>","task_id":"<N>","attempt":<k>,"model":"<model ID>","execution":"parallel"|"serial","skills":["harness-verifier", ...other grounding/harness skills the instance actually invoked...],"status":"done"|"blocked-verification"|"blocked-ambiguous"|"blocked-decision","input_summary":"<one sentence — the task ask>","output_summary":"<one sentence — what happened>","tokens":<N>,"duration_ms":<N>}.tokens/duration_mscome from theAgent()dispatch's own tool-call result — not self-reported by the instance, since a subagent doesn't see its own total usage.log.jsonlis written unconditionally — it's the canonical record, independent of the config flag below. - Only if
CLAUDE.md's config sub-block sets "Write per-task/end-of-run log files" to "on" (default off — when off, skip this item entirely; nothing further in this step or step 7's per-pass logs applies): write or appendlogs/task-<N>.md(or<N>-<batch-letter>.mdfor a folded batch) — this file is a secondary, human-readable expansion of the same event, never read back by the loop:
# Task <N>: <title>
## Task summary
<one-line synopsis of what this task is building>
## User question
<this task's description, from state.md>
Full requirement: .claude/harness/requirement.md
## Context pulled
<the project-* grounding skills and ledger facts this instance actually used to ground itself>
## Attempt <k> [tier: <tier>, model: <model ID>]<, escalated if not the first attempt>
### Approach
<the report's Approach bullets, verbatim>
### Result
Status: <the report's Status>
Files: <created/modified, from the report>
Verification: <the report's Verification section, verbatim>
Learning candidates: <the report's Learning candidates, verbatim>
Token usage: <tokens / tool calls / duration from the Agent() call's own result — this
is NOT self-reported by the instance, since a subagent doesn't see its own total usage;
read it from the dispatch's own tool-call result after it returns>When the config flag above is "on": the first attempt creates the file (with the # Task <N> header, ## Task summary one-liner, ## User question, and ## Context pulled — the grounding skills/ledger facts actually used, not the full packet); a retry or escalation (step 6) appends a new ## Attempt <k> section to the same file — one file holds a task's full history, never one file per attempt. If harness-verifier or a review pass found something before this attempt went green, append a fix event to log.jsonl (unconditional, same as dispatch): {"event":"fix","ts":"<ISO8601>","run_id":"<run_id>","scope":"<task_id>","round":<k>,"tasks":<N>,"total_tokens":<N>} (tasks = findings addressed) — and, only when the flag is "on", also append a ## Fix round <k> subsection under that attempt in the per-task log (findings, what changed, re-verification) — mirroring the Attempt structure. When the flag is "off", skip the .md file entirely; log.jsonl's dispatch/fix events remain the full record. These logs are a debugging/audit trail only — nothing later in the loop reads them back.
When the report comes back with Status: done: first check its shape — if Verification: doesn't contain real command output (just a bare "passed" claim), or a required field is missing, treat the report as blocked-verification and follow step 6 instead of absorbing it (never absorb a report you can't distinguish from a hallucinated one — but still log the attempt as above). Otherwise update .claude/harness/state.md:
- Append any new facts to
Conventions & DecisionsandFiles touched(deduplicated). - Append any
Learning candidatesthe report listed tostate.md's## Learning candidatessection (deduplicated against what's already staged). - Add a full structured entry under
Done so farfor this task, in the report's shape, including its tier and attempt count (see step 6). IfDone so farnow holds more than 5 full entries, fold the oldest to a single[x]summary line (its facts are already in the two ledgers). - Set the task to
[x]in## Tasks.
Then dispatch the next task/batch. harness-context-loader (called by the next dispatched instance) reads this file to build that task's context packet.
6. Recover from failures
A dispatched instance can't interrupt you to ask a question — so escalation is a strict bubble-up:
- The instance reports
blocked-verification(after its own focused fix attempts —superpowers:systematic-debugging, not open-ended thrashing),blocked-ambiguous, orblocked-decision, with the real failure evidence. Increment the task'sattemptscount instate.md's[>]marker line each time you dispatch a retry or escalation for it, so the count survives compaction — the same attempt number labels the new## Attempt <k>section appended to the task's log file (step 5). - Retry at the same tier, up to the configured "Same-tier retries before escalating" count (
CLAUDE.md's config sub-block, default 1): dispatch a fresh instance for the same task each time, brief now includes the prior failure evidence. Only escalate once this count is exhausted. - Once same-tier retries are exhausted, escalate to the next tier above (haiku→sonnet, or sonnet→opus), then repeat the same "Same-tier retries before escalating" count at the new tier before escalating again, brief carrying every failure trace so far.
- Repeat escalating and retrying up to the configured "Max escalations" (
CLAUDE.md's config sub-block, default 2) or until reaching the configured "Escalation ceiling" tier (default opus, i.e. no cap below the top), whichever comes first — a task that started at haiku can escalate haiku→sonnet then sonnet→opus by default; a lower configured ceiling (e.g. "sonnet") stops escalation there even if the budget isn't used up, and the task goes to item 5's blocked path instead of reaching opus. - Once the escalation budget or ceiling is reached and the last attempt still fails, or no tier remains above the task's current one — or the instance reported
blocked-ambiguous/blocked-decisionat any point — stop dispatching that task, mark it[!]instate.mdwith the failure summary, append adoneevent tolog.jsonl({"event":"done","ts":"<ISO8601>","run_id":"<run_id>","status":"blocked"}— note a run_id may get more than onedoneevent over its lifetime if it's later resumed per step 3's judgment call and eventually completes; a reader should trust the LASTdoneevent for a givenrun_id), and surface it to the user directly — the one point in this loop where you bring in a human turn. - A user decision gets written as a new line in
Conventions & Decisions, so it's durable for every later dispatch — not answered once and forgotten. - Independent downstream tasks may continue meanwhile; anything depending on the blocked task pauses until it's resolved.
7. End-of-run passes
Once every task is [x], run these before declaring the feature complete. Each is dispatched the same way as a task — a fresh instance — but logged differently: these passes emit review/fix events to log.jsonl unconditionally (never a dispatch event, which is reserved for per-task builds), and — only when the config sub-block's "Write per-task/end-of-run log files" is "on" (default off) — each also gets a logs/ file under the next sequential number (e.g. if the last task was 5, these are 6-spec-conformance.md, 7-code-review.md, 8-learnings.md); when the flag is off, skip these files and rely on log.jsonl's review/fix events alone:
- Feature-complete spec-conformance pass. Dispatch one more fresh instance whose job is to invoke
harness-verifier's spec-conformance gate against the whole built surface — not just the last task's diff — using the artifact recorded inrequirement.md. Ifrequirement.md's## Artifactsare all "none", skip this and report "spec-conformance: n/a — no artifact provided". Auto-fix cap: 2 attempts on concrete mismatches, same as the per-task gate; remaining aesthetic-only mismatches get surfaced to the user with the evidence and a pointer to thedesign-verifyskill. If a fix round runs, append afixevent ("scope":"end_of_run:spec-conformance", same shape as step 7.2's). Append areviewevent:{"event":"review","ts":"<ISO8601>","run_id":"<run_id>","pass":"spec-conformance","status":"pass"|"findings"|"n/a","critical":0,"important":0,"minor":0}. - Independent code-review pass. Dispatch a fresh instance — never one that built any of the tasks, so it can't grade its own work — to invoke the
code-reviewskill at high effort against the full diff accumulated sincerequirement.mdwas written (git difffrom the run's start commit). High effort, not the default, because this is the one deliberately thorough, adversarial pass in the loop — it's meant to catch what the cheaper per-task gates (lint/types/patterns/complexity, all mechanical) can't: logic bugs that pass tests anyway, missed edge cases, silent failures, security issues. Report its findings the same way other gates report: pass, or fail-with-findings ranked by severity. Findings drive a fix-and-re-review cycle capped at 2 iterations, same as other gates; unresolved findings after that are surfaced to the user rather than silently accepted. Append areviewevent ("pass":"code-review", same shape as above). If findings drive a fix round, append afixevent per round (unconditional):{"event":"fix","ts":"<ISO8601>","run_id":"<run_id>","scope":"end_of_run:code-review","round":<k>,"tasks":<N>,"total_tokens":<N>}(tasks= findings addressed), and — only when the config flag is "on" — append the corresponding## Fix round <k>subsection to that pass'slogs/file. If a review pass identifies a generalizable pattern (not a one-off bug), stage it instate.md's## Learning candidatesper the new 4th trigger above. - Learnings graduation. Invoke
harness-learningsonce. Ifstate.md's## Learning candidatesis empty, this is a no-op. Append alearningsevent:{"event":"learnings","ts":"<ISO8601>","run_id":"<run_id>","graduated":<N>,"duplicates_skipped":<N>}(both0if a no-op). Then append the finaldoneevent:{"event":"done","ts":"<ISO8601>","run_id":"<run_id>","status":"done"|"done_with_deferred_minors"|"blocked"}("blocked"if any task is still[!]).
Progress tracking
.claude/harness/state.md is the durable source of truth: the user-ask summary and a pointer to requirement.md, the task list with status ([ ]/[>]/[x]/[!]), the two append-only ledgers (Conventions & Decisions, Files touched), the Learning candidates staging area, and the bounded Done so far log (full detail for the last 5 tasks, older entries folded to one line). TodoWrite mirrors the task list for live in-session visibility. On re-entry after a restart or compaction, read state.md and resume from the first non-[x]/[!] task — the in-progress task is re-grounded from scratch by the dispatched instance calling harness-context-loader itself (the per-task packet is ephemeral by design). A [!] blocked task stays blocked until you judge (step 3) whether a new invocation answers its question — if so, resume it: the user's decision is recorded in Conventions & Decisions and you dispatch it again; if the new invocation is unrelated, it starts a new run instead and the blocked task is abandoned in the historical record.
.claude/harness/logs/ (one file per task, appended per attempt — see step 5) is opt-in, off by default — set CLAUDE.md's config sub-block's "Write per-task/end-of-run log files" to "on" to get it. When on, it's a separate, debugging-only trail: what was asked, how each attempt approached it, which model ran it, its full verification report, and its token usage. Nothing in the loop reads these back — they exist for a human reviewing decision quality after the fact, not for the orchestrator itself. log.jsonl is the always-on canonical record regardless of this flag.
Definition of done
- Every decomposed task is complete (
[x], none left[!]without the user having been told). harness-verifier's full gate set (lint / types / format / tests / patterns / diagrams / complexity / spec-conformance) passed on every task's changes, as reported by that task's own dispatched instance.- The feature-complete spec-conformance pass and independent code-review pass (step 7) both ran and are green, or their remaining findings were explicitly surfaced to and acknowledged by the user.
- Tests exist in the project's style and are green, as reported by each task's own dispatched instance.
- You've reported results honestly — including anything skipped, blocked, or still failing.
See also
harness-analyzer— generates grounding (run first)harness-model-router— tiers and folds every task before dispatchharness-context-loader— each dispatched instance calls this itself to build its briefharness-verifier— each dispatched instance calls this itself; also the feature-complete spec-conformance passharness-learnings— graduates staged learnings at end-of-runcode-review— the independent end-of-run review passsuperpowers:test-driven-development,superpowers:dispatching-parallel-agents,superpowers:systematic-debugging
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
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.

