Harness autopilot

From Intense-Visions/harness-engineering · View interactive version

Harness autopilot is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > Lightweight orchestrator — dispatches isolated phase-agents, tracks state, chains artifacts between phases. Delegates all planning/execution/verification/review to dedicated persona agents.

How to use this skill

Skill file

Harness Autopilot

Lightweight orchestrator — dispatches isolated phase-agents, tracks state, chains artifacts between phases. Delegates all planning/execution/verification/review to dedicated persona agents.

When to Use

Persona Agents

| Skill | subagent_type | State(s) |

| ----------------------- | ----------------------- | -------------------- |

| harness-planning | harness-planner | PLAN |

| harness-execution | harness-task-executor | EXECUTE |

| harness-verification | harness-verifier | VERIFY |

| harness-integration | harness-verifier | INTEGRATE |

| harness-code-review | harness-code-reviewer | REVIEW, FINAL_REVIEW |

Iron Law: Autopilot delegates, never reimplements. If writing plan/execute/verify/review logic, STOP — delegate via subagent_type. Always use dedicated persona agents, never general-purpose agents. <!-- not-a-pause: self-correction against reimplementing skills -->

Lifecycle skill hooks (project-declared) — `skillHooks`

A project may attach additional skills, commands, and prompts at lifecycle points of any hook-supporting skill via the top-level skillHooks block in harness.config.json. This is the general framework; autopilot is its flagship consumer (the review case below is the primary worked example). Resolution/normalization is shared in @harness-engineering/core (resolveSkillHooks + the hook input-context helpers) so every hook-supporting skill honors the same contract.

// harness.config.json
{
  "skillHooks": {
    "harness-autopilot": {
      "before:EXECUTE": [
        "preflight-skill", // bare string = a `skill` hook (shorthand)
        { "type": "command", "run": "pnpm lint", "blocking": true },
        {
          "type": "prompt",
          "text": "Prefer existing helpers in packages/core/util over new ones.",
        },
      ],
      "after:REVIEW": [{ "type": "skill", "skill": "canary-cassandra", "blocking": true }],
      "after:FINAL_REVIEW": ["canary-cassandra"],
      "on:failure": [{ "type": "command", "run": "scripts/notify.sh" }],
    },
  },
}

Autopilot's hookable event vocabulary. Event keys follow the grammar ^(before|after|on):[A-Za-z0-9_-]+$. Autopilot's phase states are PLAN, EXECUTE, VERIFY, INTEGRATE, REVIEW, and FINAL_REVIEW. Hooks are wired today at exactly four points: before:EXECUTE, after:REVIEW, after:FINAL_REVIEW, and on:failure (at the failure path — see EXECUTE recovery and the review hard-halt). The remaining phase boundaries (before:PLAN/after:PLAN, after:EXECUTE, before:VERIFY/after:VERIFY, before:INTEGRATE/after:INTEGRATE, before:REVIEW) share the same grammar and resolver but are not yet wired — a hook configured at an unwired event is a no-op (silently skipped, not hard-halted) until that boundary is wired, which is a documented follow-up. Configure only the four wired events for guaranteed firing; the hard-halt false-green protection applies at those wired points.

Three hook kinds. Each array entry is a bare skill-name string (shorthand for a skill hook) or one of three discriminated objects. All object kinds accept "enabled": false to park a hook without deleting it (a disabled hook is skipped — never a hard halt):

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

Blocking & hard-halt policy (per kind).

Hook context (input contract). When autopilot fires a hook it threads the invocation context, assembled once by the shared module:

| Env var (for command) | Meaning |

| ------------------------ | ---------------------------------------- |

| HARNESS_HOOK_EVENT | the event key, e.g. after:REVIEW |

| HARNESS_HOOK_SKILL | the host skill, e.g. harness-autopilot |

| HARNESS_PHASE | the current phase/state, when known |

| HARNESS_PROJECT_ROOT | absolute project root |

| HARNESS_SESSION_DIR | the session directory, when known |

| HARNESS_CHANGED_FILES | newline-separated list of changed files |

| HARNESS_PLAN_PATH | the active plan path, when known |

| HARNESS_FAILURE_REASON | set only on on:failure |

Generic dispatch pattern (one pattern, every event). At each hookable point, resolve and run the project's hooks:

  1. hooks = resolveSkillHooks(config, "harness-autopilot", "<before|after|on>:<STATE>") (empty ⇒ no-op; absent/empty config preserves today's exact behavior — no regression).
  2. For each hook in order, by kind: prompt → append text to this phase's persona prompt; command → run via the command-runner with the hook env + JSON stdin (cannot-spawn ⇒ hard halt; ran-and-non-zero ⇒ finding); skill → dispatch as an additional subagent with a brief carrying the hook context.
  3. Merge command/skill findings into this phase's aggregation, honoring each hook's blocking.

Extension contract — how a skill becomes hook-supporting. (1) Declare its event vocabulary in its own SKILL.md; (2) at each lifecycle point call resolveSkillHooks(config, "<this-skill>", "<event>"); (3) honor the blocking + hard-halt rules and pass the hook input-context. harness-autopilot and harness-code-review are the wired reference consumers; remaining skills (brainstorming, fleets, ...) follow as a follow-up.

RESERVED (v2). Per-iteration granularity (after:EXECUTE:task, after:dispatch:item — a phase-level hook fires once per phase, not per item), a "*" wildcard outer key ("hooks for every skill"), and {{token}} prompt templating.

Canary detectors auto-wire at REVIEW / FINAL_REVIEW (default, zero-config, forward-wired). When canary is present, autopilot's two review moments run canary's deterministic test detectors — canary-savant (test order-dependence / shared-state leakage), canary-blackhawk (temporal dependence: wall-clock, timezone, DST, Feb 29), canary-katana (tests deleted or newly skipped by the change), and canary-cassandra (vacuous tests / assertions that cannot fail) — alongside harness-code-reviewer, never replacing it. These are the SPECIFIC detectors named by the feature request (distinct from a general-purpose test reviewer, which finds brittleness/anti-patterns but structurally cannot find a self-comparing assertion or an order-dependent pass). This is an additional default layer, not new config: it fires only when canary is detected, reusing the exact skillHooks dispatch/context path.

Forward-wired — these are harness-OPTIMISTIC defaults, not guaranteed-installed skills. A detector that is not installed is skipped, never a hard halt — the opposite of a user's typo'd hook — and each auto-activates once canary ships it and it reports as installed. Canary ships all four as of 7.2.0. Availability is matched prefix-insensitively, so a catalog reporting the plugin-qualified canary:canary-cassandra wires the same detector as the bare name. Report the denominator and treat a surprising 0/4 as a finding, not as the expected state — an earlier version of this note asserted that canary shipped none of the four, which made a silent zero read as correct behaviour long after it had stopped being true.

Craft domains auto-wire at REVIEW / FINAL_REVIEW (default, zero-config, forward-wired, ADVISORY).

The craft family's ceiling-layer critique runs automatically at autopilot's two review moments,

alongside harness-code-reviewer and the canary detectors, never replacing either. Resolve

resolveReviewHooksWithCraft(config, "harness-autopilot", "<after:REVIEW|after:FINAL_REVIEW>", { changedFiles, availableSkills, alreadyRanFor })

(from @harness-engineering/core), and use

planCraftReviewDomains(hostSkill, event, changedFiles, availableSkills, opts) for the

{ wired, skipped, expected, files } split.

defaultBlocking(event), which is the canary default sitting one file away. Craft findings are

surfaced in the review report and do not contribute to the error/warn severity counts and

do not gate PHASE_COMPLETE. A taste judgment never blocks.

(the domain's owned, already-normalized subset) and forward it as the craft skill's files

argument, together with a promptBudget where that domain's MCP tool accepts one (see each

craft skill's "Invoked as a review hook" section; mcp__harness__design_craft does not — it

accepts neither promptBudget nor maxFiles, so bound it with phases / mode instead or

it runs all three phases over 13 rubrics with no ceiling). plan.files holds **repo-relative

POSIX paths — resolve each entry against the project root first**; absolute is correct for

every domain and REQUIRED for one. Forwarding them unresolved behaves DIFFERENTLY by domain:

the nine collector-based domains resolve a relative entry against the tool's path (never

the process CWD), so they still read the in-diff file

(packages/cli/tests/shared/craft/relative-files-scope.test.ts), while

mcp__harness__design_craft has no collector, resolves a relative entry against the process

CWD, and THROWS ENOENT out of runCritique, which has no try/catch

(packages/cli/tests/design-craft/phases/files-path-form.test.ts).

Never call rule.owns() yourself: it is correct only on repo-relative POSIX paths, and on raw VCS

output it yields false negatives and, worse, false positives (a dist\… build artifact leaks in).

every domain is reported no-diff-context. Do not fall back to a repository walk.

dispatch up to 2x maxDomains on the same code. At after:FINAL_REVIEW, pass the domains wired

at after:REVIEW as alreadyRanFor when the changed-file set is unchanged; they are then

reported already-run. If the diff changed between the two moments, pass nothing — a domain

should re-run after fixes land.

harness-optimistic (forward-wired), exactly like the canary detectors: the resolver filters them

out and they are recorded in the denominator. A **USER-declared unresolvable hook still

HARD-HALTS.** Availability is matched prefix-insensitively, so a catalog reporting

harness-claude:code-craft wires the same domain as the bare name.

{sessionDir}/phase-{N}-review.json and in the denominator; an advisory reviewer that crashed is

a missing opinion, not a broken gate.

dispatch); { "enabled": false } parks it. Dedup is by canonical name — note that

harness-design-craft is the only craft skill whose canonical name carries the harness-

prefix, so declaring design-craft does NOT suppress it.

expected and why each was skipped — e.g. "craft domains: 2/3 activated, 1 skipped:

unsupported-language". A surprising 0/M renders as 0/M, never as silence.

gains them.

Rigor Levels

Set at INIT (--fast / --thorough); persists for session. Default: standard.

| State | fast | standard | thorough |

| ------------ | ------------------------------- | --------------------- | ------------------------------- |

| PLAN | Skip skeleton pass | Default | Always skeleton with approval |

| APPROVE_PLAN | Signal-based (same as standard) | Signal-based | Review forced (every plan) |

| EXECUTE | Skip scratchpad | Scratchpad >500 words | Verbose scratchpad |

| VERIFY | harness validate only | Full pipeline | Expanded checks |

| INTEGRATE | WIRE only | Full tier-appropriate | Full + every ADR draft reviewed |

Rigor decides how much is checked; autonomy decides who approves (see the Pause Protocol, D2). --fast never approves a plan or INTEGRATE on its own.

Pause points

Every point below where this skill stops for the human carries a marker line, _Pause point (<class>): resolve per the Pause Protocol._ followed by a <!-- pause: <class> --> comment. Resolve each one with the Pause Protocol: agents/skills/templates/pause-protocol.md (also shipped in the harness CLI package at dist/agents/skills/templates/pause-protocol.md).

State Machine

INIT → ASSESS → PLAN → APPROVE_PLAN → EXECUTE → VERIFY → INTEGRATE → REVIEW → PHASE_COMPLETE
                                                                                  │
                                                                           [next phase?]
                                                                            │           │
                                                                         ASSESS   FINAL_REVIEW → OUTCOME_EVAL → DONE

INIT

  1. Resolve spec path (argument or prompt).
  2. Derive session slug: strip docs/, drop .md, replace / and . with --, lowercase. Set sessionDir = .harness/sessions/<slug>/.
  3. Apply autonomy flags first (D17). Before any subagent dispatch and before the first marked point below: if this skill was invoked with --supervised, call manage_state({ action: "set-autonomy", path, session, level: "supervised" }); if with --audit, call it with audit: true. Flags only lower autonomy: on --trusted or --no-audit, change nothing and print the raise hint from the Pause Protocol. Then read autonomy with gather_context({ path, session, include: ["autonomy"] }). With no session slug nothing can auto-resolve, so there is nothing to lower.
  4. Check for existing state: read {sessionDir}/autopilot-state.json. If present and not DONE: report "Resuming from {currentState}, phase {N}: {name}." Apply schema migration if schemaVersion < 5 (backfill missing fields). Jump to recorded state.
  5. Fresh start: read spec, parse ## Implementation Order for phases (### Phase N: Name + <!-- complexity: low|medium|high -->, default: medium). Capture startingCommit via git rev-parse HEAD. Write autopilot-state.json (schemaVersion: 5, currentState: "ASSESS", currentPhase: 0).
  6. Flags: --fast → rigorLevel: "fast". --thorough → rigorLevel: "thorough". --review-plans → reviewPlans: true. Both flags together → reject with error.
  7. Call gather_context({ path, skill: "harness-autopilot", session: slug, include: ["state", "learnings", "handoff", "graph", "businessKnowledge", "sessions", "validation", "autonomy"] }).
  8. → ASSESS.

After every dispatch

After every subagent dispatch (planner, task-executor, verifier, integration, reviewers, hooks), read {sessionDir}/handoff.json blockers and concerns.

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

If any blocker starts with audit-disagreement:, the subagent hit a self-audit disagreement it could not settle headless (Pause Protocol, Escalation): present both positions from concerns to the human in plain text and wait for their choice. This escalation stops at every autonomy level. It is not a failure: it never enters the EXECUTE retry path, and the same unit is never re-dispatched to settle it. Once the human answers, record the answer per the Pause Protocol (Escalation) and resume the state that dispatched the unit, passing the answer to it as context.

_Pause point (judgment): resolve per the Pause Protocol._ <!-- pause: judgment -->

If any blocker starts with judgment-fork:, the subagent reached a judgment fork it could not audit (Pause Protocol, Handing a fork back). Resolve it here as a judgment pause per the Pause Protocol, using the options and recommendation from concerns. In trusted mode, run the self-audit in this session and auto-take only on agreement. Then remove that judgment-fork: blocker from {sessionDir}/handoff.json, so nothing later (for example the orchestrator) reads it as unresolved, and resume the state that dispatched the unit, passing the decision to it as context. Like a disagreement, it is not a failure and never enters the EXECUTE retry path.


ASSESS

  1. Read current phase at currentPhase.
  2. If planPath set and file exists: → APPROVE_PLAN.
  3. Intelligence-enhanced complexity assessment. Before routing by complexity, refine the annotation with signals from available tools:
  1. Complexity routing:

_Pause point (judgment): resolve per the Pause Protocol._ <!-- pause: judgment -->

  1. Update currentState: "PLAN".

PLAN

Auto-plan (low/medium): Dispatch harness-planner:

subagent_type: "harness-planner"
prompt: "Phase {N}: {name}. Spec: {specPath}. Session: {sessionSlug}. Rigor: {rigorLevel}. Follow harness-planning. Write plan to docs/changes/<topic>/plans/ (topic from specPath; legacy docs/plans/ if spec is outside docs/changes/). Write {sessionDir}/handoff.json when done."

On return: read planPath from {sessionDir}/handoff.json. Complexity override check: low + tasks>10 or checkpoints>3 → "medium"; tasks>20 or checkpoints>6 → "high". Update state planPath. → APPROVE_PLAN.

_Pause point (judgment): resolve per the Pause Protocol._ <!-- pause: judgment -->

Interactive plan (high): Check for plan file at docs/changes/<topic>/plans/*{phase-name}* (or legacy docs/plans/*{phase-name}*) or planPath in handoff. If found: update planPath → APPROVE_PLAN. If not: remind and wait.


APPROVE_PLAN

  1. Gather: task count, checkpoint count, concerns from {sessionDir}/handoff.json (default []).
  2. "fast" → same signals as "standard" (D2: --fast reduces checking; it never approves on its own).
  3. "thorough" → force shouldPauseForReview = true.

_Pause point (ceremony): resolve per the Pause Protocol._ <!-- pause: ceremony -->

  1. Signals (any true → pause; all false → auto-approve):
  1. Auto-approve: emit report (mode, complexity, concerns, task count). Record decision with signal snapshot in decisions[]. → EXECUTE.

_Pause point (ceremony): resolve per the Pause Protocol._ <!-- pause: ceremony -->

  1. Pause: show triggered signals. Ask "Approve? (yes / revise / skip phase / stop)." Record decision. Route accordingly. If reviewPlans is true, this approval never auto-resolves: the human asked to see every plan.

EXECUTE

Pre-dispatch: before:EXECUTE hooks. Resolve resolveSkillHooks(config, "harness-autopilot", "before:EXECUTE") and run each hook in order by kind (see Lifecycle skill hooks): a prompt hook appends its text to the task-executor brief; a command hook runs via the command-runner with the hook env + JSON stdin (cannot-spawn ⇒ hard halt to .harness/failures.md; ran-and-non-zero ⇒ a finding, blocking per its policy — surface it before dispatching); a skill hook runs as a pre-flight subagent. This is the non-review generality proof: hooks fire at a non-review phase too. Empty/absent ⇒ no-op.

Pre-dispatch: plan parallelization (standard automatic parallelism). Before dispatching tasks, decide the safe parallel structure. This is orchestration, not reimplementation — autopilot chooses HOW to dispatch; the persona agents still do the work.

  1. Collect the phase's tasks with their files, dependsOn, and owns (from the plan's task headers — owns comes from the optional **Owns:** line). Call the plan_parallelization MCP tool:

```json

{

"path": "<project-root>",

"tasks": [{ "id": "task-1", "files": ["..."], "dependsOn": [], "owns": ["src/api/**"] }],

"depth": 1

}

```

It returns a ParallelizationPlan: waves[] (each { tasks, severity, firing, analysisLevel }), serialized[], cyclic[], narration, and ownershipForecast. Forwarding each task's owns lets the cheap deterministic owns-overlap check contribute implicit edges to the wave DAG and surface any overlapping ownership pairs in ownershipForecast. Omit owns for tasks that declare none — it stays a no-op.

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

  1. If cyclic is non-empty: STOP. Surface the cycle and route back to PLAN/APPROVE_PLAN (a dependency cycle is a plan defect). Do not dispatch.
  1. Announce (announce-and-proceed): emit narration verbatim. Do NOT pause here — announcing is not a gate.
  1. Dispatch in dependency order — prerequisites first, then waves in array order:
  1. For each wave, honor its firing:

_Pause point (judgment): resolve per the Pause Protocol._ <!-- pause: judgment -->

  1. Serial fallback is preserved when a phase has fewer than minWaveSize (default 3) independent tasks, when a confirm is declined, or when no graph is available and the human does not confirm — honoring the standing "when in doubt, run serially" default. <!-- not-a-pause: describes the fallback after a declined confirm -->

Each dispatched unit (parallel wave or serial task) then follows the existing per-task contract below (state.json per task, checkpoints, retry budget).

Dispatch harness-task-executor:

subagent_type: "harness-task-executor"
prompt: "Phase {N}: {name}. Plan: {planPath}. Session: {sessionSlug}. Rigor: {rigorLevel}. Update {sessionDir}/state.json per task. Write {sessionDir}/handoff.json when done or blocked."

Checkpoints:

_Pause point (ceremony): resolve per the Pause Protocol._ <!-- pause: ceremony -->

_Pause point (judgment): resolve per the Pause Protocol._ <!-- pause: judgment -->

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

After each passing checkpoint: commitAtCheckpoint().

Outcome: All tasks complete → VERIFY. A handoff blocker starting audit-disagreement: or judgment-fork: is not a task failure; handle it per After every dispatch. Task fails → retry logic:

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->


VERIFY

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

```

subagent_type: "harness-verifier"

prompt: "Phase {N}: {name}. Session: {sessionSlug}. Rigor: {rigorLevel}. Verify and report pass/fail with findings."

```

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

Pass → INTEGRATE. Fail → ask "fix / skip verification / stop." fix: re-enter EXECUTE (retry budget resets).


INTEGRATE

  1. Resolve tier: max(plan.integrationTier, derived-from-execution). If tier escalated: notify human with "Tier escalated from {planned} to {derived}: {reason}."
  2. Dispatch harness-integration skill:

```

subagent_type: "harness-verifier"

prompt: "Phase {N}: {name}. Session: {sessionSlug}. Tier: {tier}.

Plan: {planPath}. Verify integration per harness-integration skill."

```

  1. Rigor interaction:
  1. Pass → REVIEW.

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

  1. Fail → report incomplete items. Ask "fix / skip integration / stop":

REVIEW

Dispatch harness-code-reviewer:

subagent_type: "harness-code-reviewer"
prompt: "Phase {N}: {name}. Session: {sessionSlug}. Follow harness-code-review. Report findings (critical / important / suggestion)."

Then run each effective after:REVIEW hook. Probe canary once (canary_probe; status: "available" ⇒ present), determine which of the four detectors are installed, and resolve resolveReviewHooksWithCanary(config, "harness-autopilot", "after:REVIEW", { canaryPresent, availableSkills }) (from @harness-engineering/core). This returns the project's configured skillHooks (default none) followed by canary's installed deterministic detectors when canary is present — see "Canary detectors auto-wire" under Lifecycle skill hooks. When canary is absent it returns exactly the configured hooks (no regression). Run each hook in order by kind (see Lifecycle skill hooks): a skill hook is dispatched as an extra reviewer, a command hook runs via the command-runner, a prompt hook appends its text to the review brief. For a skill hook:

Also resolve craft's advisory domains at this moment. Call

resolveReviewHooksWithCraft(config, "harness-autopilot", "after:REVIEW", { changedFiles, availableSkills })

and planCraftReviewDomains("harness-autopilot", "after:REVIEW", changedFiles, availableSkills) —

see "Craft domains auto-wire" under Lifecycle skill hooks. Dispatch each wired domain as an extra

reviewer with its own plan.files[skill] resolved to absolute paths, plus a promptBudget

where that domain's MCP tool accepts one (mcp__harness__design_craft does not), and

merge its findings as non-blocking advisory output that does not count toward severity. Record

which domains wired; they are the alreadyRanFor input at FINAL_REVIEW.

subagent_type: "<hook skill name>"
prompt: "Phase {N}: {name}. Session: {sessionSlug}. Domain review. Context: {hook context}. Report findings (critical / important / suggestion)."

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

If a user-declared hooked skill cannot be dispatched (typo / not installed), or a command hook cannot be spawned (missing binary), do not skip it silently and do not offer it as an overridable finding: record it in .harness/failures.md, set the review status to failed, and halt REVIEW with "cannot verify" — a hard halt (see Lifecycle skill hooks, above). (A command that RAN and exited non-zero is instead a normal finding, blocking per policy — not a hard halt.) A harness-default canary detector that is not installed is the exception: it was already filtered out by resolveReviewHooksWithCanary (forward-wired, graceful skip) and is recorded as skipped in the denominator, never a hard halt. Persist each hook's findings under a per-hook key in {sessionDir}/phase-{N}-review.json so provenance survives, and merge them into the same blocking/non-blocking aggregation as the baseline reviewer. Report the detector denominator (how many hooks ran of how many were expected, and how many were skipped-not-installed) so a partial or forward-wired run is never presented as complete. Report the craft denominator in the same breath ("craft domains: N/M activated, K skipped: <reasons>") — a not-installed or unsupported-language craft domain is a graceful skip recorded in the denominator, never a hard halt and never a blocking finding.

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

Persist findings to {sessionDir}/phase-{N}-review.json. No blocking (across baseline + additional reviewers) → PHASE_COMPLETE. Blocking → ask "fix / override / stop." fix: re-enter EXECUTE. override: record decision in decisions[] → PHASE_COMPLETE.


PHASE_COMPLETE

  1. Present summary: name, tasks completed, retries used, verification result, integration report ({sessionDir}/phase-{N}-integration.json), review findings count, elapsed time.
  2. Record in history[]: phase index, name, startedAt, completedAt, tasksCompleted, retriesUsed, verificationPassed, integrationPassed, reviewFindings.
  3. Mark phase complete in state. Clear scratchpad: clearScratchpad({ session, phase, projectPath }).
  4. Sync roadmap: manage_roadmap sync apply:true (skip if no roadmap; never force_sync: true).
  5. Write session summary: writeSessionSummary(projectPath, sessionSlug, { session, lastActive, skill: "harness-autopilot", phase, status, spec, plan, keyContext, nextStep }).

_Pause point (ceremony): resolve per the Pause Protocol._ <!-- pause: ceremony -->

  1. More phases: "Phase {N} complete. Next: {N+1}: {name} ({complexity}). Continue? (yes / stop)." yes → increment currentPhase, reset retryBudget, → ASSESS. stop → save and exit.
  2. No more phases: → FINAL_REVIEW.

FINAL_REVIEW

  1. Set currentState: "FINAL_REVIEW", finalReview.status: "in_progress".
  2. Gather per-phase findings from {sessionDir}/phase-{N}-review.json files.
  3. Dispatch harness-code-reviewer:

```

subagent_type: "harness-code-reviewer"

prompt: "Final cross-phase review. Diff: git diff {startingCommit}..HEAD. Session: {sessionSlug}. Prior findings: {collected}. Focus on cross-phase coherence: naming, duplicated utilities, architectural drift. Report findings (critical / important / suggestion)."

```

Then run each effective after:FINAL_REVIEW hook — resolveReviewHooksWithCanary(config, "harness-autopilot", "after:FINAL_REVIEW", { canaryPresent, availableSkills }) (configured skillHooks plus canary's installed deterministic detectors when canary is present; exactly the configured hooks when absent) — over the same cross-phase diff. Run each by kind; a skill hook is dispatched as an extra reviewer:

Resolve craft's advisory domains here too:

resolveReviewHooksWithCraft(config, "harness-autopilot", "after:FINAL_REVIEW", { changedFiles, availableSkills, alreadyRanFor }).

alreadyRanFor is the set of craft domains wired at this phase's after:REVIEW **when the

changed-file set is unchanged** — craft resolves once per phase per diff, and the budget is

per-resolution, so omitting it lets the same code be critiqued twice. Domains passed this way are

reported already-run in the denominator, not silently absent. If the cross-phase diff differs

from the REVIEW diff, pass nothing. Craft findings merge into finalReview.findings as

non-blocking advisory output and never set the final-review status to failed.

```

subagent_type: "<hook skill name>"

prompt: "Final cross-phase domain review. Diff: git diff {startingCommit}..HEAD. Session: {sessionSlug}. Context: {hook context}. Report findings (critical / important / suggestion)."

```

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

An unresolvable user-declared hooked skill (a typo, a not-installed declared skill) or an un-spawnable command hook is a FINAL_REVIEW failure, not a skip, and not an overridable finding — record it in .harness/failures.md, set the final-review status to failed, and hard-halt with "cannot verify" rather than reporting a green final review that silently dropped a configured hook. A harness-default canary detector that is not installed is instead forward-wired: resolveReviewHooksWithCanary already filtered it out, so it is a graceful skip recorded in the denominator, never a FINAL_REVIEW failure. (A command that ran and exited non-zero is a normal blocking finding, not a hard halt.) Hook findings merge into the same finalReview.findings aggregation; report the detector denominator (including skipped-not-installed) so a partial or forward-wired run is never presented as complete.

  1. No blocking (across baseline + additional reviewers): store in finalReview.findings, set "passed" → OUTCOME_EVAL.

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

  1. Blocking: ask "fix / override / stop."

OUTCOME_EVAL

The blocking post-execution spec-satisfaction gate — the harness's ship gate. It fires ONCE per session, after FINAL_REVIEW and before DONE, judging the WHOLE change against the spec. (It runs at the ship boundary, not per phase: a per-phase judgment would spuriously fail while later phases are still outstanding.) It runs at every rigor level — the gate is not weakened by --fast.

  1. Set currentState: "OUTCOME_EVAL".
  2. Gather the evidence (required). Capture the cumulative change as a unified diff: git diff {startingCommit}..HEAD. Capture the most recent test-runner output retained from VERIFY; if none is retained, re-run the project test command and capture stdout+stderr. Resolve the head sha via git rev-parse HEAD.
  3. Invoke the gate. Call the outcome_eval MCP tool:

```json

{

"specPath": "<spec path>",

"diff": "<git diff {startingCommit}..HEAD>",

"testOutput": "<captured test output>",

"commit": "<git rev-parse HEAD>"

}

```

Supplying real diff and testOutput is mandatory — omitting them degrades the verdict to INCONCLUSIVE/advisory, a silent false-negative that defeats the gate. The tool persists the verdict as an execution_outcome node (keyed by commit) and returns verdict, confidence, judgedAgainst, rationale, unmetCriteria, and the TS-derived authority.

  1. Honor the TS-derived authority — never the LLM. authority is computed in TypeScript from (verdict, confidence); read it, never recompute or override it.

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

  1. Never block on infrastructure noise. A provider failure, a missing/unjudgable spec, or an absent ANTHROPIC_API_KEY degrades to INCONCLUSIVE/advisory and proceeds — surface the degradation to the human, but do not halt.

DONE

  1. Present: total phases, tasks, retries, time, finalReview.status + findings count, any overridden findings, and the OUTCOME_EVAL verdict (verdict / confidence / authority, plus any recorded override).
  2. Auto-decision summary (SC11). If .harness/sessions/<session-slug>/auto-decisions.jsonl does not exist, print nothing. Otherwise run harness autonomy log --session <session-slug>. If its output contains a line starting No auto-decisions recorded, print nothing more; otherwise print the output verbatim. If the command fails or is not recognised, print Auto-decision summary unavailable (<reason>); raw log: .harness/sessions/<session-slug>/auto-decisions.jsonl and never report zero decisions you did not read.

_Pause point (irreversible): resolve per the Pause Protocol._ <!-- pause: irreversible -->

  1. Ask "Create a PR? (yes / no)." When creating the PR, include a bare closing line Closes #<N> where <N> is the issue number from the roadmap row's External-ID. The keyword MUST sit IMMEDIATELY before the ref — no intervening words (Closes #<N>, never Closes roadmap #<N>), or GitHub will not link/close the issue and roadmap auto-done will skip the row.
  2. Write final handoff to {sessionDir}/handoff.json. Append learnings to .harness/learnings.md. Call promoteSessionLearnings(projectPath, sessionSlug). If learnings count > 30, suggest harness learnings prune.
  3. If docs/roadmap.md exists: call manage_roadmap update to set feature done. Skip if not found.
  4. Write final writeSessionSummary(). Set currentState: "DONE" in autopilot-state.json.

Process

Prompt the human in plain text — every phase-continue and human-decision interaction in this skill is plain text only. Do not elevate to AskUserQuestion: natural headers like "Continue phase" exceed its 12-char cap, rendering the call as ERR.

  1. INIT — Resolve spec, derive session slug, check for existing state, parse phases.

_Pause point (judgment): resolve per the Pause Protocol._ <!-- pause: judgment -->

  1. ASSESS — Route by complexity: low/medium auto-plans, high pauses to choose auto-plan (recommended) or interactive planning.
  2. PLAN → APPROVE — Dispatch harness-planner, check approval signals, auto-approve or pause.
  3. EXECUTE — Dispatch harness-task-executor with plan path, handle checkpoints and retries (max 3).
  4. VERIFY — Dispatch harness-verifier, confirm code correctness and wiring. <!-- not-a-pause: the verifier checks correctness, not a human -->
  5. INTEGRATE — Resolve integration tier, dispatch harness-integration, verify system wiring, knowledge materialization, and documentation per tier.
  6. REVIEW — Dispatch harness-code-reviewer plus the effective after:REVIEW hooks (resolveReviewHooksWithCanary: project skillHooks plus canary's INSTALLED deterministic detectors when canary is present — forward-wired, not-installed ones skip), plus craft's ADVISORY domains (resolveReviewHooksWithCraft: diff-scoped, budget-capped, non-blocking, reported in a denominator), fix blocking findings.
  7. PHASE_COMPLETE — Summarize (including integration report), sync roadmap, loop to ASSESS for next phase or proceed to FINAL_REVIEW.

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

  1. FINAL_REVIEW → OUTCOME_EVAL → DONE — Cross-phase review, then the blocking spec-satisfaction gate (halt on a high-confidence NOT_SATISFIED), offer PR creation, write final handoff.

Context-Budget Trip Wire

Autopilot keeps context fresh between phases — every state dispatches a distinct cold subagent — but a single long-running turn (one harness-task-executor grinding through a large phase, or a fleet lane building an item end-to-end) can accrue context creep within its own turn and silently degrade into the "dumb zone". A token-anchored, window-keyed trip wire watches that intra-turn budget. Use evaluateContextBudget(usedTokens, window) from @harness-engineering/core as the classifier — it returns ok | warn | trip.

| Window class | Soft-warn (converge + flush) | Hard trip (checkpoint-and-restart) |

| ------------------------------ | ---------------------------- | ---------------------------------- |

| 1m (≥ 900K, [1m] variants) | 250K | 350K |

| 200k (≥ 150K, Sonnet/Opus) | 80K | 100K |

| local (≤ 128K, Qwen / local) | ~30% (round(0.30×win)) | ~37.5% (round(0.375×win)) |


Harness Integration


Gates

Escalation

_Pause point (gate): resolve per the Pause Protocol._ <!-- pause: gate -->

Rationalizations to Reject

| Rationalization | Reality |

| ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| "Low complexity means I can skip APPROVE_PLAN" | Low complexity means auto-approval only when no signals fire. Signals override complexity. |

| "I can inline planning logic instead of dispatching to harness-planner" | Iron Law. Autopilot delegates, never reimplements. No exceptions. |

| "Retry budget exhausted but one more approach might work" | 3-attempt budget prevents compounding failure. Exceeding it without human input is unrecoverable. |

| "Keeping research in conversation is faster than scratchpad" | Scratchpad gated by rigor level. At standard/thorough, >500 words must go to scratchpad. |

| "Plan auto-approved, so I can skip recording the decision" | Every approval—auto or manual—is recorded in decisions[]. That array is the audit trail. |

| "Closes roadmap #123 reads fine, GitHub will figure out the issue" | An intervening word breaks GitHub's closing-keyword parser: closingIssuesReferences stays empty and auto-done leaves the row planned. Use a bare Closes #123. |

Success Criteria

Examples

Invocation: /harness:autopilot docs/changes/security-scanner/proposal.md

INIT: 3 phases found: Phase 1: Core Scanner (low), Phase 2: Rule Engine (high), Phase 3: CLI Integration (low).

Phase 1 — ASSESS → PLAN: harness-planner dispatched. Returns plan: docs/changes/security-scanner/plans/2026-03-19-core-scanner-plan.md (8 tasks).

Phase 1 — APPROVE_PLAN (auto): All signals false. "Auto-approved Phase 1: Core Scanner | auto | low | no concerns | 8 tasks."

Phase 1 — EXECUTE: harness-task-executor dispatched with plan path + session. 8 tasks complete. 2 checkpoint commits.

Phase 1 — VERIFY: harness-verifier dispatched. Pass. REVIEW: harness-code-reviewer. 0 blocking, 2 notes.

Phase 1 — PHASE_COMPLETE: "Phase 1 complete. Next: Phase 2: Rule Engine (high). Continue? → yes"

Phase 2 — ASSESS: High complexity. "Run /harness:planning interactively, then re-invoke." [User plans interactively. Re-invokes.]

INIT (resume): "Resuming from PLAN, phase 2: Rule Engine. Found plan: docs/changes/security-scanner/plans/2026-03-19-rule-engine-plan.md"

Phase 2 — APPROVE_PLAN (paused): Complexity: high triggered. "Approve? → yes" EXECUTE → VERIFY → REVIEW → PHASE_COMPLETE. 14 tasks, 1 retry.

Phase 3: auto-plans and executes. FINAL_REVIEW: harness-code-reviewer on startingCommit..HEAD. 0 blocking, 1 warning. Passed.

DONE: 3 phases, 30 tasks, 1 retry. "Create PR? → yes" <!-- not-a-pause: worked example output, not a step -->

Retry exhaustion (during any phase):

Task 4 fails → Retry 1/3: obvious fix applied, still fails
             → Retry 2/3: expanded context (related files + learnings), still fails
             → Retry 3/3: full context gather (test output + imports + plan), still fails
Budget exhausted. Recorded in .harness/failures.md.
Fix manually and continue / revise plan / stop?
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.