/autopilot:finish-flowfrom autopilot
Provides a size-keyed closing checklist for the dev-flow finish node, creating individual TaskCreate items for each closing step. Use when wrapping up work to ensure nothing is missed.
Ships in autopilot. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
finish node checklistPurpose: closing is multi-step and easy to compress mentally into "one thing to do". This skill turns each
closing step that applies to the session's size into its own TaskCreate item, which system-reminder surfaces
until it is individually completed. Passive text cannot force behavior; active TaskCreate reminders can.
!cat .claude/finish-flow-config.md 2>/dev/null || true
!cat .claude/dispatch-config.md 2>/dev/null || true
1. Read size, urgent, bug, high_risk, base_ref and level from the marker:
node scripts/session-mode.js status
No marker or no size ⇒ ASK the user (CEO evaluates within DOA), then
node scripts/session-mode.js set --size <XS|S|M|L|XL> [--urgent] [--bug]
2. Enter the node: node scripts/stage-advance.js --to finish
Exit 3 ⇒ an earlier node is still open: go to a node in legal_next and come back. Never force.
3. Select every checklist row whose "Runs for" matches this session, and TaskCreate each one,
in table order, as its own call. Subject: "finish · <item>". Description: the row's
description including its output clause, copied verbatim (not abbreviated).
4. Mark the parent task "finish: Invoke autopilot:finish-flow" (created by dev-flow at intent
for L/XL) in_progress.
5. Work through the sub-tasks in order, marking each completed as its output is produced.
6. Urgent: run the post-finish code-review row last.
Do not combine. Each sub-task is its own TaskCreate call and its own TaskUpdate status=completed call.
"After a merge" = the work was merged from a separate branch (fix/*, hotfix/*, a feature branch); otherwise the
work was committed directly and the confirm-commit row applies instead of the merge row (merge includes branch and worktree removal).
"Incident" = production was broken (hotfix/* branch).
| Item | Runs for | Description + verification output |
|---|---|---|
| Goal review | L, XL | Open the project README. For each success criterion, show (a) the criterion text and (b) the concrete evidence (command output, file contents, or diff) proving it's met. Verify EACH row of the dev-flow requirements ledger is DONE or explicitly deferred (named to the user in the report) — a silently dropped accepted requirement is a FAIL. Output: pass/fail list, zero unverified. |
| Incident fix check | urgent with an incident | State the root cause in one sentence and point to the specific code change that addresses it. Output: root cause + file:line of the fix. |
| qc verdict | all | The qc-gate node's result covers the current HEAD: zero test failures and (M–XL, or XS/S with risk flags) zero blocking autopilot:quality-pipeline findings. Blocking findings block the qc-gate merge (not the lane), within at most 3 fix-review rounds; depth 0 repairs them in pooled rounds. The /l5 / /l6 engine implement-review loop is governed separately by resolver loop_max_rounds. A commit after the gate ran ⇒ run the gate again now. (CI-backed tests on Claude Code may be awaited with the Monitor tool — see quality-pipeline Tests step / portability §7.) Output: the gate's final result for the HEAD sha. |
| Bug commit message | bug | The commit states root cause + what was wrong + how it's fixed. Output: git log -1 --format=%B showing all three. |
| Ongoing-maintenance entry | bug, XS–M | Append one line to <projects_dir>/ongoing-maintenance/YYYY-MM.md (bash scripts/resolve-project-paths.sh --field projects_dir): | MM-DD | commit_hash | fix(area): 根因 → 修法 (跨 N 模組) |. Output: tail -1 of that file. |
| Merge | after a merge | Target: develop (or main per project convention); hotfix/* merges to main. For L5/L6, resolve autopilot_root with the package-root resolver below, set task_status_receipt to a new caller-owned path, then run node "$autopilot_root/bin/autopilot.js" status task --root-run-id "$root_run_id" --json >"$task_status_receipt" and assert the parsed JSON has can_merge === true (for example, node -e 'const v=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8"));if(v.can_merge!==true)process.exit(1)' "$task_status_receipt"). Only after that assertion passes run git checkout <target> && git merge --no-ff <branch>. The merge commit message MUST carry the qc-evidence trailer QC-Verdict: PASS (reviewer <id>, <YYYY-MM-DD>) once the qc verdict row passed — the .githooks/pre-push qc-gate (scripts/resolve-qc-gate.sh, strength per .claude/qc-gate-config.md) refuses to push a protected-path range without it. Trailer parsing only reads the message's LAST paragraph — a blank line between QC-Verdict: and Co-Authored-By: splits them into two paragraphs and %(trailers:...) silently returns empty (fixable with git commit --amend to re-join them into one trailing block; amending a merge commit does not touch its parents). Output: (L5/L6) the pre-merge receipt with can_merge=true, plus git log -1 --format="%H %s%n%(trailers:key=QC-Verdict)" showing merge commit + trailer — checking that combined output for non-emptiness proves nothing, since %H %s alone guarantees non-empty text even with zero trailers; isolate the trailer value itself with git log -1 --format="%(trailers:key=QC-Verdict,valueonly)" | grep -q . and require THAT to succeed. In the same step, from the trunk checkout, run the command block marked finish-hygiene-commands below: detach the feature worktree, git branch -d <branch>, git push origin --delete <branch>, git worktree remove <worktree>, git worktree prune. Subagent and dispatch worktrees live under .claude/worktrees/ or .worktrees/; both are gitignored. Then bash scripts/finish-hygiene-check.sh "$(git rev-parse --show-toplevel)" exits 0. |
| Confirm commit | no merge | git log -1 --format="%H %s" on the expected branch. Output: commit hash + branch name. |
| Post-merge review | M, L, XL after a merge | Re-read critical files that were changed (pick 1–3 highest-risk) to verify the merge didn't silently drop changes. Doc-sync (conditional): if the change touched user-facing behavior or 3+ modules, invoke autopilot:doc-sync in scoped mode (base = the merge-base) to confirm docs still match the merged code; OFFER full mode for large/user-facing ships. Triage confirmed findings per doc-sync's fix policy (user docs → reality; specs → STALE-fix or mark NOT-YET-IMPLEMENTED + BACKLOG). Output: grep/diff confirming each expected change is present on the target + doc-sync drift summary (or "doc-sync skipped: no user-facing/3+ module change"). |
| Archive project | L, XL | Move <projects_dir>/<project>/ → <archive_dir>/<project>/ (bash scripts/resolve-project-paths.sh --field projects_dir / archive_dir). Update the INDEX (--field index) (remove from 進行中, add to 已完成 with date). If .claude/mission-routing-config.json points inside the moved directory, update graph_path to the archived path in the same change and require mission-routing-admission.test.sh plus session-mode.test.sh to pass after the move. Stale-qualifier guard: grep -E '^|' "$(bash scripts/resolve-project-paths.sh --field index)" | grep -Ei '\((pending|target|in progress|WIP|TBD|draft)\)' MUST be empty (scan table rows only — the ^| prefilter excludes section headers like ## 進行中 (In Progress) which would otherwise false-positive under -i; -i then catches lowercase (wip) in a row); on hit, emit matched lines + halt. Plan-as-project archive (campaign work tracked as <plans_dir>/<date>-<slug>.md instead of under <projects_dir>): run node scripts/check-plan-graduation.js --fix — this IS the archive step for plan-as-project; hard-fail if it still reports a blocking violation afterward (--json, exit 1). Output: ls <archive_dir>/<project>/ + grep guard pass-confirmation. |
| Release hygiene | any size that bumped the version | Run scripts/preflight-release.sh — verifies CHANGELOG entry + INDEX row + version mirrors are consistent with canonical .claude-plugin/plugin.json, runs the temp-prefix registry gate (scripts/check-tmp-residue-registry.js, whole repo), and runs the settings registry gate (scripts/check-config-docs.js: a new AUTOPILOT_* env var or config.json key needs a scripts/lib/config-keys.json entry and, if user-facing, a row in docs/guide/settings-reference.md); must exit 0. At the actual release (the version bump that ships) add --with-slash-probe: it runs the 6 paid slash-entry probes, which are NOT RUN by default (BL-0316) and are reported as such in the pass line; routine acceptance runs omit it. Output: the preflight-release pass line. |
| Post-incident learn | urgent with an incident | MANDATORY. Invoke autopilot:learn. Record: incident, root cause, detection method, fix, prevention. Output: knowledge entry path. |
| Dispatch-branch close-out | all | Runs when the round is finished (its work merged or abandoned). Derive integration_target and autopilot_root as in Session end (full) item 10 (do that derivation now, at any size), then run node "$autopilot_root/scripts/repo-residue-sweep.js" close-session --session "$CLAUDE_CODE_SESSION_ID" --repo "$(git rev-parse --show-toplevel)" --integration-ref "$integration_target" --yes whether or not this session dispatched anything (no dispatch branches ⇒ empty result); skip it only when handing unfinished work to a later session (report skipped: handoff) or when CLAUDE_CODE_SESSION_ID is unset. Without --yes it only prints the plan. It deletes this session's dispatch branches, integrated or not, printing for each unintegrated one a recovery line git branch <branch> <tip> that works until git gc prunes it (~2 weeks), and lists every kept branch with its why. Exit 1 (a branch stayed for a non-keep reason) ⇒ resolve it before the next row. To check that a test run left no temp residue, stamp a file before it and run node "$autopilot_root/scripts/lib/tmp-residue.js" new-since --stamp <file> --exclude-kind live,lock --exclude-path <file> --fail-on-entries after (exit 1 lists each leftover with its registry kind or unregistered). Output: the deleted / kept lists, each deleted unintegrated branch with its recovery line (or skipped: handoff). |
| Scratch close-out | level l4, l5, l6, after a merge is pushed and after a full-suite run ends | Reap clean, merged lane worktrees from the session scratchpad: bash "$autopilot_root/scripts/scratch-closeout.sh" --root "<scratchpad dir>" --repo "$(git rev-parse --show-toplevel)" --keep <names of lanes still in flight, comma separated>. depth-0 builds --keep from its open lanes (a lane whose branch is not merged yet, a pending-merge tree, anything a hand still uses); a dirty tree, an unreachable commit, a clone, a plain dir and a live-cwd tree are never removed (no --force), and the branch refs stay. Run it by hand from the closeout, never from a hook. Output: the REMOVED lines and the reap-scratch: summary. |
| Session end (lite) | XS, S, M | (1) Retry check: did I retry any non-trivial operation 2+ times? If yes → invoke autopilot:learn. Also run node scripts/probe-unknown.js report --ledger <ledger>: any learn_required climb (ladder row at rung ≥ 1, no skip reason) makes autopilot:learn MANDATORY, pre-filled with the climb's terms + unknown_type. (2) Deferred items: anything postponed → one row on the resolved backlog (scripts/resolve-project-paths.sh --target "$(git rev-parse --show-toplevel)" --field backlog; never a literal docs/BACKLOG.md) per references/backlog-entry.md, then node scripts/check-backlog-entries.js --backlog <resolved backlog> (warn); backlog: none, or backlog_exists false (--field backlog_exists: the resolved path is not on disk) ⇒ report that this project has no backlog file and hand the items to the user; do not create one. (3) Urgent: staging reflects the change. (4) From backlog: this work came from a row on the resolved backlog ⇒ delete that row (Done handling in references/backlog-entry.md: history stays in git and at the pointer). (5) Level l4/l5/l6: the Session-mode marker row runs next. Output: retry yes/no (+ knowledge entry path), tail of the backlog showing new entries (or "none") plus the gate JSON, staging line (urgent), the deleted row's title (or "not from backlog"). |
| Session end (full) | L, XL | Run the Session end (full) checklist below. Output: pass/fail summary for each gate and four-surface per-surface lines. |
| Session-mode marker | level l4, l5, l6 (any size) | Resolve autopilot_root with the package-root resolver below if it is not already set. LSM status gates (L5/L6 only): after merge and again immediately before marker clear, run node "$autopilot_root/bin/autopilot.js" status task --root-run-id "$root_run_id" --json >"$task_status_receipt"; preserve the final JSON receipt. Report product_merged, consumer_updated, pushed, and zero_residue independently. Never say “merged and clean” unless can_close=true. Session-mode marker: L5/L6 must run node "$autopilot_root/scripts/session-mode.js" clear --task-status-receipt "$task_status_receipt" --root-run-id "$root_run_id"; the command fails closed unless the fresh digest-valid receipt has the same root and can_close=true. L4 keeps node "$autopilot_root/scripts/session-mode.js" clear. Output: (L5/L6) the final status receipt with can_close=true, then the clear command's exit 0; (L4) the clear command's exit 0. |
| Delete merged branch | after a merge | The merge step already ran the marked hygiene commands. This row confirms them: bash scripts/finish-hygiene-check.sh "$(git rev-parse --show-toplevel)" exits 0, and git ls-remote --heads origin <branch> is empty. Dispatch branches stay on the Dispatch-branch close-out row. Enforcer: scripts/finish-hygiene-check.sh. |
| Post-finish code-review | urgent, when node scripts/stage-graph.js next --from finish --size <size> --urgent [--high-risk when the marker's high_risk is true] lists code-review | Invoke autopilot:hetero-review (code loop) on the full diff, --phase full --phase-base <base_ref>; its rail records the stage. Nothing loops back to implement: each finding opens a new S task — one backlog row per references/backlog-entry.md with **Effort**: S. Output: the review receipt path + the new backlog rows (or "no findings"). |
The merge step runs this block from the trunk checkout. <branch> is the merged feature branch. <worktree> is its linked worktree. Detach first so git branch -d can run while that worktree still exists. scripts/finish-hygiene-check.sh is the check.
git -C <worktree> checkout --detach
git branch -d <branch>
git push origin --delete <branch>
git worktree remove <worktree>
git worktree prune
The Session end (full) resolver is executable shell so its fail-closed behavior stays fixture-tested:
resolve_finish_flow_package_root() {
local catalog_skill="${1:-}" root="" canonical_skill=""
if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -n "${PLUGIN_ROOT:-}" ] \
&& [ "$CLAUDE_PLUGIN_ROOT" != "$PLUGIN_ROOT" ]; then
printf '%s\n' 'error: ambiguous plugin roots' >&2; return 2
fi
root="${CLAUDE_PLUGIN_ROOT:-${PLUGIN_ROOT:-}}"
if [ -z "$root" ]; then
[ "$#" -eq 1 ] && [[ "$catalog_skill" = /*/skills/finish-flow/SKILL.md ]] \
&& [ -f "$catalog_skill" ] \
|| { printf '%s\n' 'error: require one exact absolute active finish-flow/SKILL.md catalog path' >&2; return 2; }
canonical_skill="$(cd "$(dirname "$catalog_skill")" 2>/dev/null && pwd -P)/SKILL.md" \
|| { printf '%s\n' 'error: cannot canonicalize active finish-flow skill path' >&2; return 2; }
root="$(cd "$(dirname "$canonical_skill")/../.." 2>/dev/null && pwd -P)" \
|| { printf '%s\n' 'error: cannot derive package root from active finish-flow skill' >&2; return 2; }
else
root="$(cd "$root" 2>/dev/null && pwd -P)" \
|| { printf '%s\n' 'error: plugin root is not a readable directory' >&2; return 2; }
fi
[ -f "$root/skills/finish-flow/SKILL.md" ] \
&& [ -f "$root/scripts/reap-dispatch-branches.sh" ] \
&& [ -x "$root/scripts/reap-dispatch-branches.sh" ] \
|| { printf '%s\n' 'error: package root is incomplete or reaper is not executable' >&2; return 2; }
printf '%s\n' "$root"
}
autopilot:learn when warranted — non-obvious landmine → .claude/knowledge/;
architecture decision → project docs; process gap → the relevant skill; cross-session lesson → persistent
memory; none → skip, do not force it. MANDATORY when node scripts/probe-unknown.js report --ledger <project>/ledger/decisions.jsonl lists any learn_required climb (a ladder row at rung ≥ 1 with no skip reason:
the session consumed an outside source to resolve an unknown; pre-fill the learn entry with that climb's terms
and unknown_type so the next S4 lookup hits; rows with budget-exhausted / not-heterogeneous / knob-off /
rail-failed never trigger it). The learn summary covers errors resolved (root cause + fix), key decisions
(rationale), surprises.autopilot:distill episodic mode (learn records lesson-FACTS, distill produces
executable PROCEDURES).references/backlog-entry.md,
evidence at the pointer. Backlog safety: an item that affects the final goal is never deferred. Work that came
from a backlog row ⇒ delete that row (Done handling in the same reference).git log --oneline $(cat .claude/session-start-sha 2>/dev/null || echo "HEAD~10")..HEAD. Normal mode: present
to the user. CEO mode: decide autonomously and record in the CEO Report.Used: user, Used: e2e, or Used: n/a <reason> for the thing just merged; green tests and review PASS do not count).integration_target from project config; otherwise resolve the origin/HEAD
symbolic ref and normalize only refs/remotes/origin/<name> or origin/<name> to the local <name>; if
origin/HEAD is unavailable, use the unique local develop/main. In every case require refs/heads/<name>
to exist (ambiguity, malformed remote target, or missing local ref ⇒ halt). Assign autopilot_root from the
package-root resolver above and halt on nonzero. When CLAUDE_PLUGIN_ROOT or PLUGIN_ROOT is set, call
autopilot_root="$(resolve_finish_flow_package_root)"; otherwise set active_finish_flow_skill to the one exact
absolute active finish-flow/SKILL.md path shown by the harness catalog and call
autopilot_root="$(resolve_finish_flow_package_root "$active_finish_flow_skill")". Never substitute the consumer git root or a newest-cache search.
The Dispatch-branch close-out row has already run close-session with these values (or skipped it at handoff). Then run
bash "$autopilot_root/scripts/reap-dispatch-branches.sh" check --repo "$(git rev-parse --show-toplevel)" --into "$integration_target".
Exit 1 blocks clean exit until every ahead candidate is integrated or preserved with exact-tip --ack + handoff
rationale. Deliberate discard of these reap-dispatch-branches.sh candidates is manual human/depth-0 action only after verified preservation;
reap-dispatch-branches.sh never deletes an uncontained branch (this session's ledger-owned dispatch branches are
deleted by close-session, each unintegrated one with its recovery line). Re-run until exit 0.finish: Invoke autopilot:finish-flow at the
intent node. Missing ⇒ the intent gate failed — STOP and create it retroactively before continuing.| Wrong | Right |
|---|---|
| Compress the checklist into a single "finish up" TaskCreate | Each row is its own TaskCreate |
| Merge before the qc verdict row | Order matters — the qc verdict comes first |
| Archive before merge | Never reverse them |
Skip autopilot:learn because "nothing to learn" | After an incident, learn is MANDATORY; for L/XL, walk the knowledge questions and skip only if all are "no" |
| Urgent-low findings fixed in place after finish | Each finding opens a new S task; the finished work does not loop back |
| Mark the parent completed while rows are still pending | The parent completes only after every row reaches completed |
| "I know what I need to do, skip the TaskCreates" | The forcing function is the TaskCreates themselves — there is no shortcut |
finish; creates the parent closing task at intent (L, XL).qc-gate node; this checklist re-runs it only when HEAD moved after the gate.learn_required climb; optional otherwise.finish node; all rows are within DOA, no Board escalation
unless a row reveals a goal miss or an irreversible surprise.Done when every selected row is completed, the parent task (L, XL) is completed, and a final summary lists which
rows ran and what evidence each produced. Only then may the session move on or end.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub cookys/autopilot --plugin autopilot32 skills in this plugin
/agent-callContact an already-running persistent coding-agent session via fleet v2 (fallback: Claude SendMessage + outbox). Use when: "通知 <host>", "跟 <host> 說", naming a fleet member/pane. Not for: opinions (→ consult), hetero review (→ hetero-review), new workers (→ /l4–/l6).
/auditCompare two existing implementations for feature parity and missing items. Use when: "compare X with Y", "verify X matches Y", "比對 X 和 Y". Not for: future plan review, single-bug debug, writing tests.
/brainstormPre-code Socratic design exploration that surfaces 2-3 approaches and gates coding until approved. Use when: "help me think through X", "還沒想清楚", "我不確定要怎麼做". Not for: existing options (→ think-tank), external research (→ survey), chosen approach/quick fix (→ dev-flow).
/ceo-agentFull delegation — you own the goal end-to-end, user just wants results. Triggers: "CEO mode", "get it done", "you decide", "handle everything", "I trust you", "take over", "full authority", "just do it", "搞定 X", "幫我處理", "全權處理", "你決定". Not for: research-only (→ survey), participatory planning (→ dev-flow), or parallel task dispatch.
/debugEvidence-first debugging for correctness bugs, crashes, and flaky tests. Use when: diagnosing bugs, crashes, or intermittent failures. Not for: performance/latency/memory issues (→ profiling).
/dev-flowStart here before writing any code — sizes the task (XS/S/M/L/XL, bug, urgent `!`), sets up branch and session rules. Use when: "I'm starting on X", "quick fix for Y", "continuing from yesterday", "hotfix needed", "let's implement X", "skip to coding", "我要開始做 X", "快速修一下", "接續昨天的進度", resuming a feature branch, or any task that touches code. Not for: debugging (→ debug), authoring a plan doc (→ references/plan-template.md), pre-code design exploration (→ brainstorm), or code review (→ quality-pipeline).
Other plugins' skills for the same job