Autopilot
Drive a specced feature to completion autonomously — all phases, review, fixes — in a dedicated worktree by default. Stops at /do…
Claude CodeGeneric
---
description: Drive a specced feature to completion autonomously — all phases, review, fixes — in a dedicated worktree by default. Stops at /done on the branch (merge to main stays human/opt-in).
argument-hint: [slug] [--here] [--merge]
---
You are about to **autonomously drive an already-specced feature to completion**: every
implementation phase, the review, and the fixes — then stop with the feature promoted on its
own branch, ready for a human to merge.
This command is a **thin driver**. It does **not** reimplement any dispatch logic. It *composes*
the existing slash commands — `/next-phase`, `/feature-review`, `/resolve`, `/done` — by invoking
them in sequence (via the Skill tool, exactly as if a user typed them), and owns **only** the
parts they don't: the worktree wrapper, the loop + termination, the retry budget, the orchestrator
chore-commits between steps, and the hard-stop conditions. Treat the four sub-commands as the
single source of truth for *how* each step dispatches; never duplicate their bodies here.
## Args from the user
$ARGUMENTS
Parse: the first non-flag token is `<slug>` (required). Flags:
- `--here` — **opt out of the worktree.** Run the whole pipeline in the current checkout instead
of a sibling worktree. (Default is worktree-per-feature so concurrent work isn't blocked.)
- `--merge` — **opt in to auto-merge.** After `/done`, also merge the branch into `main`. Default
is to **stop before merging** and hand that judgment to a human.
If no slug is given and exactly one feature is in `.kanban/2-in-progress/`, infer it; otherwise
list the active features and stop.
---
## How this command behaves (read before running)
- **Resumable.** Every step leaves a clean tree and an advanced `checkpoint.yaml`. Re-invoking
`/autopilot <slug>` after any interruption re-enters the worktree and picks up from checkpoint
state — it never restarts work already committed.
- **Cost.** A full run executes the entire `dotnet test` suite **at least 3×** (both
`/feature-review` passes + `/done`'s `final_verify`), on top of each phase's `verify-phase`. On a
large feature that is real wall-clock time — expected, not a hang.
- **Two hard rules that override everything below:**
1. **Hard gates are never retried or forced past.** A red `verify-phase`, a red `final_verify`,
a merge conflict, or a post-merge-red → **STOP immediately, leave the tree exactly as it is,
and write a handoff** (what failed, the exact command to resume). Never edit code to force a
gate green outside the normal phase/resolve flow.
2. **Soft failures get 2 attempts, then stop.** A phase or a finding that the sub-agent cannot
resolve after **2 total attempts** → STOP + handoff. Do not loop a third time.
---
## Step 1 — Preconditions (run in the **main checkout**, before any worktree)
Stop on the first failure and tell the user how to fix it.
1. **Spec exists and is committed on `main`.** `worktree-start` branches from the *committed*
`main` ref, so an uncommitted spec won't carry into the worktree.
```bash
git -C . rev-parse --abbrev-ref HEAD # expect: main (or run --here)
[ -d ".kanban/2-in-progress/$SLUG" ] || { echo "no spec for $SLUG — run /spec first"; exit 1; }
[ -z "$(git status --porcelain .kanban/2-in-progress/$SLUG)" ] \
|| { echo "spec for $SLUG is uncommitted — commit it on main first"; exit 1; }
- Spec validates.
If this fails, the brief/plan needs the architect — stop and say so (stash scripts/checkpoint/checkpoint.stash validate-spec "$SLUG"/spec). - Pin
mainfor the split-brain guard. Record main's SHA now, in the main checkout — you pass it toassert-phase-landed --main-refeach phase so a worktree run can prove its commits never leaked ontomain:
(Undergit rev-parse main # remember this SHA — referred to as <MAIN_REF> below--herethere is no worktree, so the pin is moot — skip--main-refin Step 3.)
Step 2 — Enter the worktree (default) / resume / --here
--here: skip this step entirely. Work in the current checkout. (No merge step at the end — the work simply lands wherever you are.)- Worktree already exists (
../stash-<slug>+feature/<slug>present — an interrupted prior run): do not callworktree-start(it refuses on collision). Just re-enter it:EnterWorktree path: ../stash-<slug> - Otherwise — create it:
thenstash scripts/checkpoint/checkpoint.stash worktree-start "$SLUG"EnterWorktree path: ../stash-<slug>. Once inside (cwd is now the worktree, with its own.kanban/andscripts/), run the parallel-safety heads-up and surface its warning but do not stop (it is non-blocking, exit 3):stash scripts/checkpoint/checkpoint.stash check-parallel-safety "$SLUG" || true
Everything from here runs inside the worktree (or the current checkout under --here), so the
sub-commands resolve all paths locally — no cross-checkout orchestration.
Step 3 — Phase loop (until all phases done)
Repeat until stash scripts/checkpoint/checkpoint.stash status "$SLUG" shows every phase done:
- Invoke
/next-phase <slug>(Skill tool). One implementer, one phase./next-phasealready runs its own pre-flight (validate, clean-tree check, get-next-phase) and its own post-dispatch verification + implementer chore-commit fallback — let it. - After it returns, assert the phase landed with the deterministic verdict (replaces eyeballing
status.stash+git statusby hand). In worktree mode add the--main-refpin from Step 1 so a stray commit ontomainis caught:
(Dropstash scripts/checkpoint/checkpoint.stash assert-phase-landed "$SLUG" "<phase-id>" --main-ref <MAIN_REF>--main-refunder--here.) A non-zero exit means the phase did NOT land cleanly — dirty tree, phase notdone/`verified
Maintain Autopilot?
Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.
[Autopilot on getagentictools](https://getagentictools.com/loops/thekrystalship-autopilot?ref=badge)