/craft:commitfrom craft
Phase 9 — atomic commits, decisions promotion dialog, slice archive write, plan file closing (deleted, or moved into .claude/plans/.closed/ under a rule on removing files). On a pull-request + Protected-main profile it opens a PR and merges via gh only after a GitHub approval ("Freigabe ≠ Merge"). The slice closes here — and a finished epic (Epic-close: after an autopilot run's merge, a sequential run, or slice by slice by hand).
Ships in craft. Installing the plugin adds it to Claude Code.
Close the slice properly: split changes into atomic commits with Conventional Commits + Slice: footers, surface decisions for promotion to intent.md / rules.md, write the slice archive entry from the Phase 6 recap, and close the ephemeral plan file (deleted, or moved into .claude/plans/.closed/ — Step 7).
This command is a durable-state mutation (git history, project knowledge files, slice archive, plan closing) and follows the Pre/Post-Assertion pattern documented in skills/workflow/SKILL.md. Follow that skill for Phase 9 mechanics.
Ensure-primed gate — before the checks below, if the session marker
.claude/plans/.primedis absent, emit "Session not primed — running /craft:prime first", run/craft:prime(it loads project context, verifies the required tools, and writes the marker), then resume this command. Silent no-op when the marker is already present. Defined inskills/workflow/SKILL.md→ Session Priming Gate.
Glob .claude/plans/*.md. Identify the slice expected to be in Status: committing (or awaiting-approval, completing a protected-main PR). Pre-Assertion A2 below aborts on anything else.This step is informational. The Pre-Assertions enforce that a single, valid slice plan is present.
If a slice plan is found, read its ## Recap Draft section (written in Phase 6). It will feed the slice archive entry. Empty/missing recap is caught by the Pre-Assertions.
Run all of the following. Any failure stops the command before any commit, archive write, or deletion happens.
The order. First Mode Detection's Which worktrees count and step 0 (below): when step 0 finds the Epic-close mode, A1–A6 do not run — that mode has its own pre-assertions (end of this file). Then A0, then Mode Detection steps 1–2 (A0 guards them: they need the main checkout), then A1–A6 — A3 and A6 read the mode steps 1–2 detected.
Bash git rev-parse --show-toplevel and compare against the path of the first entry in git worktree list --porcelain (the primary worktree). They must match.
Failure → abort: "Run /craft:commit from the main checkout, not from inside a worktree. cd to <main-path> first."
This guards the Mode-Detection logic below — every mode requires main as the operating context.
Glob .claude/plans/*.md.
Status: committing. Did the earlier phases actually run?"Status: committing or awaiting-approval (the other plans are not ready to land — e.g. a parent epic plan, or sibling slices during a sequential-epic run). If exactly one plan is at that status, record it as <slice-plan> and continue. If zero or more than one plan is at that status, abort with the list and ask the user to specify which slice to commit (this command does not auto-pick; ask it with AskUserQuestion, one option per listed plan — where the tool is not available, a numbered list as text). In the zero case, when a listed slice plan's slice has a worktree (git worktree list --porcelain shows its <slice-id>-<slug> branch), name the re-run: "<slice-id> has a worktree, but its plan in this checkout reads Status: <X> — finish the slice there, then run /craft:execute <slice-NNN>: its step 6 commits the slice's work and reads the plan back (Status: committing). Then re-run /craft:commit."<slice-plan>.Parse the frontmatter of <slice-plan>. Required fields: Slice-ID:, Status:, Phase:.
Status: must be committing (a slice cleared by /craft:review) or awaiting-approval (completing an already-opened protected-main PR — Step 6, second invocation). Any other value → abort: "Plan <plan> has Status: <X>. Phase 9 requires committing (reached when /craft:review clears the slice) or awaiting-approval (a protected-main PR waiting for its approval to be merged). Run /craft:review first (or, when Status: awaiting-release, /craft:release then the remaining phases)."bash "${CLAUDE_PLUGIN_ROOT}/scripts/tree-dirt-state.sh"
Which of CRAFT's own files — plans, ID counters, local state — do not count as uncommitted work is defined once, in that helper (DIRTY=yes|no, one DIRT= line per counted change). A helper that cannot run (non-zero exit) fails A3.
DIRTY=yes (there are uncommitted changes to commit). Hold its DIRT= lines — P2 needs them to tell a change the human keeps out of Step 1's split from one Phase 9 left behind. If DIRTY=no → abort: "Nothing to commit. Did Phase 4 / Phase 7 / Phase 8 actually run?"DIRTY=no AND the corresponding worktree+branch from Mode Detection must exist. If main has uncommitted work AND a finalize mode was detected → abort: "Working tree on main has uncommitted changes while a finalize-mode worktree is also present. Commit or stash the main-side changes before finalizing." Each slice worktree the mode names (the slice's; in Epic-finalize every included slice's that still exists) must report DIRTY=no too, judged by the same helper in its slice scope, which counts the slice's work and none of CRAFT's own files (the plan copy, .craft/, the seeded .primed marker): bash "${CLAUDE_PLUGIN_ROOT}/scripts/tree-dirt-state.sh" --scope slice-worktree --checkout <worktree>. Otherwise abort, naming the worktree, its DIRT= lines and the fix — "<slice-id>'s worktree holds work that was never committed on its branch; re-run /craft:execute <slice-NNN> — its step 6 commits it and reads the plan back — then /craft:commit." The merge in Step 1a would otherwise land a branch without the slice's work, and Step 7 would remove the worktree with it.Status: awaiting-approval — Step 6, second invocation): the commits + archive already landed on the first invocation, so the tree is expected clean. Skip the non-empty check; this invocation only detects the PR approval and merges via gh.Run the project's test command (derived from rules.md ## Test Strategy / ## Stack & Tools, or asked from the user if not derivable; offer the likeliest commands as AskUserQuestion options, "Other" takes the user's own — where the tool is not available, ask as text).
rules.md or run tests manually and re-invoke."The slice plan must contain a ## Recap Draft section with content.
<plan>. Run /craft:recap (Phase 6) before /craft:commit."This catches only the Standard-mode-on-the-trunk case — a direct commit on the trunk
with no branch to open a PR from. Abort before any commit only when all hold: the
profile's Merge → Type is pull-request with Protected-main: yes; and
Mode Detection found Standard mode; and git branch --show-current equals the trunk
(main or the configured trunk):
"Protected-main opens a PR from a branch, but you are on <trunk> directly with no branch
to land. Run the slice via /craft:execute (worktree) or in-place so there is a branch, or
set Merge → Type: direct." When Mode Detection step 2 named CRAFT worktrees that are no finalize target, repeat
those lines below the message and add: "None of these is ready to finalize — if you meant to finalize one, finish it
first (or /craft:abort a leftover). The changes on <trunk> still need a branch of their own."
The mode decides, not the worktrees: a finalize-mode run executes from the primary checkout
(A0), whose current branch is the trunk, but its slice/epic branch lives in a separate
worktree — it genuinely has a branch to PR, and it is no Standard mode, so A6 does not apply. An in-place run is on
its own branch in the primary checkout (current branch ≠ trunk), so it passes. A slice already at
Status: awaiting-approval likewise sits on its PR branch (in-place) or still has its finalize worktree — it passes.
Only a genuine Standard commit directly on the trunk trips A6 — also while a worktree exists that is no finalize
target, a slice still building or one an aborted slice left (slice-079: A6 used to step aside for any CRAFT worktree,
so such a worktree let a Standard commit land on the protected trunk). Running this before Step 1 ensures no commits
land on a trunk that then cannot be pushed.
/craft:commit runs in one of four modes. Run this detection before Step 1 and pick the matching procedure path. Run it from the main checkout, not from inside a worktree.
main with no /craft:execute run, but also a <slice-id>-<slug> branch when a slice was built in-place on a branch in the main checkout (an in-place single slice, or a sequential-epic slice under pull-request + Protected-main: yes — A6 needs that branch to open the PR from). Follow Steps 1–7 exactly as written below — except on an autopilot epic branch epic-<NNN>-<slug> in the main checkout, where the Autopilot Mode differences (end of this file) apply from Step 1 on./craft:execute <slice-NNN> has completed; a worktree at ../<repo>-worktrees/<slice-id>-<slug>/ holds the slice-branch with Status: committing (first pass) or awaiting-approval (protected-main PR completion, second pass) and a clean tree. Follow Steps 1a, 2, 4, 5, 5b, 6, 7 (with the merge in Step 1a replacing Step 1's atomic split — the orchestrator already committed the sub-task work inside the worktree)./craft:execute <epic-NNN> has completed; an epic-<NNN>-<slug> worktree exists with every contained slice already merged in. Follow Steps 1b, 2, 4, 5, 5b, 6, 7. The decisions walk in Step 4 runs once per included slice.[Y] merged its epic branch into
the trunk (direct) or opened a PR for it (pull-request + Protected-main: yes), or a sequential / hand-worked epic
has every slice landed. Every slice already closed, and what is left is the epic itself (D37, D38). Under protected
main it runs in two passes, like Epic-finalize (D39). Follow the Epic-close Mode section (end of this file) —
its own pre-assertions, steps and post-assertions. Step 0 below judges it first, so on an autopilot epic branch with no
slice at committing it wins over Standard mode's Autopilot differences.Which worktrees count (slice-078). Steps 0, 1 and 2 below judge the linked worktrees only through
scripts/worktree-kinds.sh — which worktree is CRAFT's (a branch carrying a slice-<NNN> or epic-<NNN> token) is
defined in its header, once. Run it once, from the project root, before step 0:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/worktree-kinds.sh"
A worktree on no slice or epic branch — detached, or on another branch — decides no mode and no guard. Name each
KIND=foreign line in one line of the output, its fields as printed, and go on:
· Worktree <WORKTREE> (<BRANCH>) is on no slice or epic branch — ignored
The helper cannot run (non-zero exit, no CRAFT_COUNT=) → say so in one line and stop before any write: without its
answer the mode cannot be judged.
The start branch (slice-080). Before step 0, hold git branch --show-current as <start-branch> — the branch this
run started on (empty on a detached HEAD). Step 7's In-place-finalize reads it: by then Plans and the trunk under
protected main may already have moved the checkout to the trunk.
Detection logic:
A finished epic. Only when no slice plan under .claude/plans/ is at Status: committing or
awaiting-approval, worktree-kinds.sh reports CRAFT_COUNT=0, and git branch --show-current is
the trunk (main, or the trunk rules.md ## Deployment names) — or, on the PR path, an autopilot epic branch
epic-<NNN>-<slug> (the one a5's PR leaves checked out) or a close branch epic-<NNN>-<slug>-close (Epic-close's own
first pass): run, from the project root,
bash "${CLAUDE_PLUGIN_ROOT}/scripts/epic-close-state.sh" --trunk <trunk>
Mode = Epic-close when any of these holds: a line reads STATE=closing (an epic plan at awaiting-approval whose
close PR is open — the second pass, run from the three branches above: the first pass leaves the checkout on the epic
branch or the close branch, and the trunk is where the human may have gone since), CLOSABLE_COUNT= is above 0, or a line reads
STATE=pr-path with BRANCH= equal to the current branch (the epic's PR is open and this checkout is its branch —
the first pass, riding on that PR). None holds, at least one epic line, and no slice plan under
.claude/plans/ (only epic plans) → stop here, before A1: there is no slice to commit either, and A1/A2
would answer with a slice message — A1 takes the lone epic plan for the slice and A2 rejects it as not reviewed
(slice-061 review R1-1). Print "Phase 9 aborted — no slice at committing and no epic to close:", then one line per
epic plan as that mode's state table words it. Nothing was written. A slice plan exists (at another status), or no
epic plan → go on with step 1: A1/A2's slice message is the one that helps then. The helper cannot run (non-zero
exit) → say so in one line and go on with step 1.
worktree-kinds.sh reports CRAFT_COUNT=0 → mode = Standard.
Otherwise, for each KIND=craft worktree, look up the matching plan file under .claude/plans/.
Branch starts with epic- and the epic plan exists with all decomposition entries archived/merged → Epic-finalize mode (the matching epic-worktree is the merge source).
Branch matches slice-<NNN>-<slug> and the slice plan has Status: committing or awaiting-approval (protected-main PR completion) → Slice-finalize mode.
Anything else — a slice still building, a worktree an aborted slice left, a branch with no plan — is no finalize
target. Name it in one line, <STATUS> being its plan's Status: or none when no plan matches, and go on:
· Worktree <WORKTREE> (<BRANCH>, plan <STATUS>) is no finalize target — not finalized by this run
No worktree matched a finalize mode → mode = Standard (A6 then judges a trunk commit under protected main). If multiple plausible modes match, ask the user which one to finalize (defensive — should not happen in normal flow; ask it with AskUserQuestion, one option per plausible mode — where the tool is not available, as text).
When the protected-main PR gate has opened a PR (Step 6, first pass), the finalize target's
plan carries Status: awaiting-approval: the slice plan for lone-slice / Slice-finalize, or
the epic plan for Epic-finalize (that plan is the Epic-finalize target for the second pass) and for Epic-close's PR path
(step 0's STATE=closing: the second pass is found by the helper, not by a worktree — Epic-close Mode, The PR path).
If the user invokes /craft:commit from inside a worktree, refuse: "Run /craft:commit from the main checkout, not from inside a worktree. cd to <main-path> first."
If the finalize target's plan (the slice plan, the epic plan in Epic-finalize, or the epic plan in Epic-close's PR
path) has Status: awaiting-approval, this invocation is the second pass of the protected-main
PR gate (Step 6): the commits, the decisions promotion, and the archive already landed on the
first pass. Skip Steps 1–5b entirely and go straight to Step 6's
Second invocation branch, then Step 7 (in Epic-close: that mode's The PR path names what runs of it). Do not re-propose a commit split, re-walk the
[K]/[I]/[R]/[D] dialog, or re-write and re-commit the archive.
Otherwise (Status: committing) run Steps 1–7 normally.
git diff --stat to see scope..claude/plans/ — a sibling slice planned meanwhile — is the human's to include or leave out; never
anything under .claude/plans/.closed/ (closed plans, gitignored only once /craft:prime step 4f's block is applied).Present the proposal as a list. Ask the confirmation at its end with AskUserQuestion (three options: proceed / propose a different split / abort); where the tool is not available, print the question below as text.
Commit 1: feat(api): add reservation endpoint
- app/Http/Controllers/ReservationController.php
- routes/api.php
- tests/Feature/ReservationApiTest.php
Commit 2: feat(pwa): reservation button with optimistic UI
- resources/views/...
- resources/css/...
- tests/Feature/ReservationPwaTest.php
Commit 3: refactor(http): extract common validation trait
- app/Http/Validation/HasReservationFields.php
- app/Http/Controllers/ReservationController.php (use trait)
Proceed with this split? (Y / propose-different / abort)
If user wants a different split, iterate. Abort → clean exit, no mutation.
The slice-branch already contains the slice's commits, made inside the worktree by /craft:execute step 6 (it commits the slice's work there before it reads the plan back, and A3 has checked that nothing is left uncommitted). There is nothing to split.
Protected-main gate: if the profile's Merge → Type is pull-request with Protected-main: yes, do not run the direct merge below — leave the slice-branch unmerged and land it via the Step 6 PR gate instead (continue with Step 2, Steps 4–5b, then Step 6). Otherwise (Type: direct, the default) merge the branch into main:
git checkout main
git merge --no-ff <slice-id>-<slug> -m "Merge <slice-id>: <slice-title>"
If the merge produces conflicts (rare — main should be ahead of the slice's fork point only by other merges, not by hand-edits), surface them and stop. Do not auto-resolve. The user inspects the slice worktree and decides whether to rebase the slice-branch onto current main and retry, or escalate.
After a clean merge, skip directly to Step 2 with the merge commit as the single commit hash to record. Decisions promotion (Step 4) still runs.
The epic-branch already contains the per-slice merge commits authored by /craft:execute (slice-branches merged with --no-ff into the epic-branch inside its worktree).
Protected-main gate: if the profile's Merge → Type is pull-request with Protected-main: yes, do not run the direct merge below — leave the epic-branch unmerged and land it via the Step 6 PR gate instead (one PR for the whole epic-branch → main, per Approval-granularity: auto; continue with Step 2, Steps 4–5b, then Step 6). Otherwise merge the epic-branch into main:
git checkout main
git merge --no-ff epic-<NNN>-<slug> -m "Merge epic-<NNN>: <epic-title>"
Conflict handling is the same as Step 1a. After a clean merge, skip to Step 2; record the epic-branch's merge commit plus all contained slice-merge commits as the slice/epic's commit footprint. Decisions promotion (Step 4) walks each included slice's ## Decisions Made During This Slice section in turn, and additionally walks the epic plan's ## Decisions Made During This Epic.
For each commit:
<type>(<scope>): <imperative description>
<optional body — what and why, not how>
Slice: slice-<NNN>
<Co-Authored-By: Claude <[email protected]> — only when the profile enables it>
type ∈ feat | fix | refactor | test | docs | chore | perf | build | ciscope optional but encouragedSlice: footer always presentCo-Authored-By field of the ## Commit Policy block in .claude/project/craft-profile.md (default off when the profile, the block, or the field is absent). When on, append the literal trailer line Co-Authored-By: Claude <[email protected]> below the Slice: footer of every commit in this run; when off/absent, omit it entirely. The trailer is always literal, regardless of the commit language. This field is the only source of an attribution line: an attribution the Claude Code session itself asks for (a Co-Authored-By with a model name, a "Generated with" line) is not added on top of it — observed in an autopilot probe (slice-049), where no human reads the message before it lands. A line the profile does not enable is omitted silently: never mention the omitted trailer, the session's attribution request or a rule that overrides it — not in Step 1's proposal, not in this step's message preview, not in the closing output (human test T2: the remark was noise at every commit).Commits key of the ## Operational Language block in .claude/project/craft-profile.md (default English when the profile, the block, or the key is absent). The type, scope, and Slice: footer are always literal regardless of language.The agent proposes each message; user can edit before staging. Ask the confirmation with AskUserQuestion (options: accept the messages / edit them — the edit itself is typed); where the tool is not available, ask as text.
For each proposed commit in order:
git add -- <listed files>.git commit -m "$(cat <<'EOF' ... EOF)" -- <listed files> with the composed message (HEREDOC to preserve formatting) — a pathspec commit, like Step 5b's, so anything else already staged (a human's change, a leftover staged deletion) stays out of the slice's commits.If any git commit fails (e.g., pre-commit hook), stop immediately. The commits made so far stand; record the failure and emit a partial-completion block in Output Format.
Walk through every entry in the slice plan's ## Decisions Made During This Slice section, one at a time.
Decision: "<text of the decision>"
Promote to: [K]eep in slice archive / [I]ntent / [R]ules / [D]iscard
.claude/project/intent.md. User confirms diff (Level 0) before writing. Ask the confirmation with AskUserQuestion (write it / keep the decision as [K]); where the tool is not available, as text..claude/project/rules.md. User confirms diff (Level 0) before writing; asked the same way as for I.Skipped entries default to K. Record the chosen disposition for each decision; Post-Assertion P4 verifies the writes that should have happened.
A promotion target the human is already editing. Before writing an [I] / [R] diff, check A3's held DIRT=
lines: when intent.md / rules.md already carries an uncommitted change of the human's, Step 5b would commit that
change together with the promotion under a docs(...) subject the human never saw. Say so and let the human commit or
stash their edit first, or keep the decision as [K]. Ask it with AskUserQuestion (three options: I commit/stash first / keep as [K] / write the diff anyway); where the tool is not available, as text.
Where Steps 4 and 5 write. Into the checkout of the branch that lands, so Step 5b can commit
there: the main checkout, except in a finalize mode under Type: pull-request + Protected-main: yes, where the slice/epic worktree holds the branch the PR carries — write the intent.md /
rules.md promotions and the archive entry in that worktree instead.
For each closing slice, compose the archive entry from templates/slice-archive.md.template. Fill:
<first-hash>..<last-hash> and PR number if one was created## Recap Draft)## Recap Draft)rules.md)## Follow-ups — the lines bash "${CLAUDE_PLUGIN_ROOT}/scripts/review-findings-state.sh" <slice plan> --followups prints (FOLLOWUP=<ID> <severity> · <fix-nature> · <description>[ — <note>], one per follow-up → slice archive line of ## Review Findings, and one ending — known limit[: <why>] per accepted → known limit line); none → omit the section. A FOLLOWUP_MALFORMED=<ID> line, or a helper that cannot run, means a follow-up could not be read — surface it and ask the human for the line before writing the archive, never drop it silently## Recap Draft if present)Write each to .claude/project/slices/slice-<NNN>-<slug>.md.
In Epic-finalize mode (and in Epic-close mode, its step 2), also write the epic archive at .claude/project/slices/epic-<NNN>-<slug>.md, composed from templates/epic-archive.md.template — the one definition of its layout (D38):
> Completed: today and the epic plan's Started:, > Slices: N/N landed · <how they landed>> Merge: — one of four values: <hash> (Merge <epic-NNN>: <title>), the epic branch's merge commit into the trunk; through PR (epic-<NNN>-<slug> → <trunk>), when the archive is written before a PR merges it (Epic-finalize under pull-request + Protected-main: yes, or Epic-close riding on the epic's open PR); <hash> (<its subject>), the trunk's commit that merged the epic's PR before Epic-close ran — the merge commit holding the epic branch's tip as a non-first parent, or, the branch deleted, GitHub's Merge pull request #<N> from … commit (<N> from the epic plan's PR #<N> opened line); or trunk-based, no merge, when no epic branch was merged (a sequential or hand-worked epic). This is the only place the epic archive names commits; each slice's commits stay in its own archive — never add a ## Commits section## Vision — the epic plan's ## Vision, as written## Slices (N/N) — one line per decomposition entry, in its order, linked to the slice archive ([<slice-id> — <short-name>](./<slice-id>-<slug>.md)), with what it did in one line## Epic Decisions — the epic decisions kept ([K]) or promoted ([I]) in Step 4## Open follow-ups — epic-level open items only; a slice's own follow-ups stay in its archive — name the slice instead of copying themWhat each field holds is defined here only — the template carries the layout and its placeholders, no rules; copy no
guidance into the archive. The epic plan's ## Recap Draft, when a human filled it, is the source of ## Vision's
closing paragraph and of ## Open follow-ups — never a section of its own. The per-slice archive entries link back to
the epic archive.
/craft:commit leaves no file of its own uncommitted — Post-Assertion P2 requires a clean tree,
and a /craft:execute re-run after s0 must not find this slice's record as dirt (B13). Commit
what Steps 4 and 5 wrote, in the checkout they wrote it in, as separate docs commits composed
and confirmed like Step 2's:
docs(intent): <subject> for .claude/project/intent.md,
docs(rules): <subject> for .claude/project/rules.md (only when Step 4 wrote it).docs(slices): archive slice-<NNN> (<short title>) with every archive entry
Step 5 wrote (in Epic-finalize mode, the epic archive in the same commit).Commit each with a pathspec — git add -- <files> then git commit -m "…" -- <files> — never
-A and never a bare git commit: a human's unrelated change, staged or not, stays theirs. Capture each hash
into the commit-log buffer (the archive's Commits: range keeps naming the work commits from
Steps 1–3, not these). A failing git commit stops like Step 3 does.
Under Type: direct the commits land on the trunk (Standard mode, and a finalize mode after its
Step 1a/1b merge) or on the in-place branch that Step 7 merges. Under pull-request +
Protected-main: yes they land on the PR branch before Step 6 pushes it, so the record reaches
the trunk with the approved merge and not as a direct commit.
Never for a slice on an autopilot epic branch
epic-<NNN>-<slug>in the main checkout — Autopilot Mode skips this step under every Merge Workflow: nothing is pushed and no PR is opened per slice. (Epic-close's PR path is no slice: its first pass runs this step's first invocation from that branch or from its own close branch, its second pass the second invocation — Epic-close Mode, The PR path.)
How a finished slice/epic reaches main is driven by the profile's ## Merge Workflow
(Type, Protected-main, Approval; documented defaults direct / no / chat when the
profile or a field is absent). The commit split / decisions / archive above already ran;
this step only decides the landing.
Type: direct (default) — the branch was already merged into main by Step 1a/1b
(finalize modes), or the changes were committed directly on main (Standard mode). Nothing
more to do; proceed to Step 7. (rules.md ## Deployment may still opt into an ad-hoc PR —
if so, ask before pushing — with AskUserQuestion, two options (push / do not push); where the tool is not available, as text; that is a convenience, not the protected-main gate.)
Type: pull-request + Protected-main: yes — the "Freigabe ≠ Merge" gate: the
human approves the PR (a real review); the system merges via gh once the approval
exists. (Approval: github-pr-review is implied by this gate — a chat approval is
meaningless under branch protection.) A two-invocation flow (open-then-resume), keyed
off the slice Status:. It needs a branch distinct from the trunk — a finalize-mode
slice/epic branch, or an in-place branch. A Standard commit directly on the trunk has no
branch to PR, but that case is already rejected by Pre-Assertion A6, so by Step 6 there is
always a branch.
Verified gh mechanics (gh 2.95.0 — never --admin; a plain merge failing until the
approval exists is the gate, not a bypass):
First invocation (slice Status: committing):
0. A tracked plan's removal rides in the PR — the trunk takes no direct commit, so the plan
leaves it with the approved merge. In the checkout Steps 4–5 wrote in, with every plan Step 7
would delete (Epic-finalize: every included slice plan and the epic plan), run
bash "${CLAUDE_PLUGIN_ROOT}/scripts/plan-landing.sh" close --message "chore(plans): close slice-<NNN>" [--keep-copy] <plan>...
(Epic-finalize: close epic-<NNN>). Pass --keep-copy when that checkout is the main
checkout (in-place) — the live plan stays there for this pass and the second one; omit it in a
finalize worktree, which Step 7 removes. What "tracked" means and how the deletion is committed
is the helper's (its header): a COMMIT=<hash> goes into the commit-log buffer, COMMIT=-
means no plan was tracked, ERROR= stops like a failing git commit in Step 3.
git push -u origin <branch> (Level 0 — external).gh pr create --base <trunk> --title "<slice/epic title>" --body "<What / Why / Commits summary>". Capture the PR number #N and URL. On the PR path there is no merge commit, so the slice archive's ## Commits records the branch's own commit range (<first>..<last> on the branch) plus the PR #N — backfill #N into that line, then commit and push the backfill on the PR branch, in the checkout Steps 4–5 wrote in: git commit -m "docs(slices): record PR #N for slice-<NNN>" -- <archive path> and git push. It lands before any approval, so it dismisses no review, and the archive is not left modified for Step 7's checkout or worktree removal. A failing commit or push is handled like a failing gh pr create below.main is not merged, and the resume gesture — approve the PR on GitHub, then re-run /craft:commit.If git push or gh pr create fails here: do not set awaiting-approval; the commits +
archive stand and the plan file is kept — the user reconciles manually.
Second invocation (slice Status: awaiting-approval):
<N> from the plan's > PR: frontmatter (or gh pr list --head <branch> --json number -q '.[0].number'), then gh pr view <N> --json state,reviewDecision — read both fields.state is MERGED (a prior pass merged it, or it was merged on GitHub) → skip the merge and proceed to Step 7 (cleanup). state: CLOSED (closed unmerged) → surface "PR #N is closed without merging — inspect on GitHub." and stop; the slice stays awaiting-approval.state: OPEN and reviewDecision: APPROVED → gh pr merge <N> --merge (no --admin; no --delete-branch — Step 7 owns branch/worktree cleanup, and the branch is still checked out here). On success, proceed to Step 7. Re-checking reviewDecision is deliberate: a code-modifying push after approval dismisses it (stale-review dismissal).state: OPEN but not APPROVED (REVIEW_REQUIRED / CHANGES_REQUESTED / null) → report "PR #N not yet approved (reviewDecision=<X>) — approve it on GitHub, then re-run /craft:commit." Change nothing; the slice stays awaiting-approval.gh pr merge fails despite APPROVED (e.g. a required check still pending) → surface the gh error and stop; the slice stays awaiting-approval for another re-run.Granularity (Approval-granularity: auto, the default): a lone slice opens one PR; a
parallel epic opens one PR at the epic-finalize (the whole epic-branch → main); a
sequential epic opens one PR per slice — s3 in /craft:execute's Sequential epic path
opens it (first invocation, from the slice's <slice-id>-<slug> branch), and the next
/craft:execute <epic> invocation's s0 completes it (second invocation → gh pr merge +
Step 7's Plans and the trunk under protected main). Each slice lands on its own approved PR.
Protected-main PR gate: Step 7 runs only on the second invocation, after
gh pr mergesucceeds (Step 6). On the first invocation the slice is left atStatus: awaiting-approvalwith its plan intact — do not reach Step 7.
Closing an untracked plan — the one definition; wherever this command closes a plan that git does not track, it means this, and never an
rmof your own (a user may deny or ask on removing files, and CRAFT never goes around that rule — D34). From the project root, one call per plan:bash "${CLAUDE_PLUGIN_ROOT}/scripts/close-file.sh" --project "<project-root>" <plan>
RESULT=moved→ the plan now lives atTARGET=in.claude/plans/.closed/(gitignored once/craft:primestep 4f's block is applied; move mode: a deny or ask rule on removing it, named byRULE_SOURCE=, or doubt, named byREASON=). Nothing else to do.RESULT=delete→ no such rule: issueDELETE_CMD=exactly as printed, as a Bash call of its own — the permission check stays the final judge. If that call is denied or refused, run the helper again with--moveand go on.ERROR=tracked:→ git tracks it: the tracked-plan rule below applies instead. Any otherERROR=→ surface it and leave the plan where it is; P5 reports it.
In Standard mode: close .claude/plans/slice-<NNN>-<slug>.md (Closing an untracked plan) — under pull-request + Protected-main: yes never: Plans and the trunk under protected main below replaces this close, for tracked and untracked plans alike, and must find the plan still on disk. The slice archive + commits are now the durable record. No worktree to remove (none was created).
A tracked plan (
git ls-files --error-unmatch <plan>succeeds — the project versions its plans): delete it withgit rm -finstead of closing it, in every mode (Standard included) —-fbecause the plan always carries uncommitted status edits by now, and its content lives on in the archive — and commit the deletions of this run with a pathspec,git commit -m "chore(plans): close slice-<NNN>" -- <plan paths>(Epic-finalize:close epic-<NNN>), on the trunk, after any merge this step performs — underType: directonly, where an untracked or ignored plan is simply closed. Underpull-request+Protected-main: yessee Plans and the trunk under protected main below instead.
Plans and the trunk under protected main (second pass, after
gh pr mergesucceeded): the approved merge landed on the remote only, and it already carries every tracked plan's removal (Step 6, first invocation, item 0). Bring the main checkout to the merged trunk and drop the local plan copies in one call, from the main checkout, with every plan Step 7 deletes in this mode:bash "${CLAUDE_PLUGIN_ROOT}/scripts/plan-landing.sh" sync --trunk <trunk> <plan>...How it moves the checkout and what it does with each plan copy is defined in the helper's header. This call is the plan deletion in this mode and the trunk sync of In-place-finalize and the finalize modes below; do not close or
git rma plan before or after it.
RESULT=okwithON_TRUNK=nofor every plan → the plan is gone locally and on the remote trunk, nothing is staged. Continue.ON_TRUNK=yes→ the merged PR did not carry that plan's removal (a PR opened before this rule): the trunk still tracks it, and the helper left its local removal as an unstaged deletion — so this checkout already reads the slice as landed. Name it in the output: the removal needs a PR of its own, and that deletion is what the PR carries. Do not stage or commit it here.ERROR=(git's reason printed above it) → surface both and stop before any branch or worktree removal. The helper left every plan copy as it was, on the branch it started from, so the slice staysawaiting-approvaland a re-run of/craft:commitretries once the cause is cleared (Step 6 finds the PRMERGEDand comes straight back here).
In-place-finalize (a slice built in-place on a non-trunk branch): never on an autopilot epic branch
epic-<NNN>-<slug>— Autopilot Mode lands there. Otherwise, when the landed slice was built in-place on a<slice-id>-<slug>branch in the main checkout (slice-018 in-place, or asequential-epic slice under apull-requestworkflow) — i.e. Mode Detection found Standard mode and<start-branch>(Mode Detection → The start branch) is a branch other than the trunk — empty (a detached HEAD) never is — whatever other worktrees exist (slice-080: a worktree count skipped the merge while the plan was still closed). The commands below name<start-branch>, which a customBranch name patternmay have shaped. Return to the trunk after landing, so the next run starts clean onmain:
directworkflow → the commits are on the branch; land them on the trunk:git checkout <trunk>thengit merge --no-ff <start-branch>, thengit branch -d <start-branch>. A failing merge → surface it and stop before the plan is closed: the slice's commits are on<start-branch>only, and a closed plan would read as landed.pull-request+ protected-main → the Step 6gh pr mergelanded the merge on the remote; Plans and the trunk under protected main above has already checked out and fast-forwarded the trunk (so local<trunk>contains the merged work) and dropped the plan. Onlygit branch -d <start-branch>is left. Underdirect, then continue the Standard-mode cleanup (close the plan). Ifgit branch -dfails (unmerged — should not happen post-land), surface it and skip the delete. Never-D(force). (Adirectsequential-epic slice builds directly on the trunk with no branch, so it skips this entirely — it is already onmain.)
Finalize modes under
pull-request+Protected-main: yes(second pass): the approved merge landed on the remote only. Before removing any worktree, bring the local trunk up to date in the main checkout through Plans and the trunk under protected main above — that is how the archive and promotions Steps 4–5 wrote in the worktree reach the main checkout, where P3/P4 read them and a later/craft:executeA6 finds the archive — and the plan removal it performs replaces the plan close below.
Releasing a slice worktree's plan copy —
/craft:executehanded the main checkout's plan into every slice worktree it created (step 5), and an untracked or modified file there would make git refuse the worktree's removal. So before each slice worktree is removed (the epic worktree holds no such copy), run from the project root, one call per worktree:bash "${CLAUDE_PLUGIN_ROOT}/scripts/plan-roundtrip.sh" release --worktree <worktree> <plan>—<plan>is that slice's plan path in the main checkout. The helper's header defines what it does: besides the plan copy it hides CRAFT's own files in that worktree (the.primedseed, a session's.hook-env, a resolved handoff marker) from git, so none of them makes git refuse the removal; it removes nothing.
RESULT=releasedwithACTION=none→ a tracked copy was restored to the worktree's HEAD, or there was no copy. Continue with the removal.ACTION=close→ close the copy named byPLAN=as Closing an untracked plan says — its one definition, so it adds no second close site — with--projectset to thePROJECT=the helper names (the worktree's project directory) instead of the project root. Then continue with the removal. (The helper has already made sure the worktree's.claude/plans/.closed/hides itself from git where the project's.gitignoredoes not, so a move-mode close leaves nothing forgit worktree removeto refuse.)RESULT=conflict, anERROR=or noRESULT=line → skip that worktree's removal and itsgit branch -dand say so: "⚠<slice-id>: the plan copy in<worktree>is<REASON>(edited after/craft:executeread it back, or there is no record of the hand-in) — the worktree is left as it is. Inspect the copy, then remove the worktree yourself (git worktree remove, with--forceonly if you mean to drop that edit) andgit branch -d <branch>; a re-run of/craft:executecannot read the plan back any more, the slice has merged and this step has closed the main checkout's plan." The rest of Step 7 goes on.
In Slice-finalize mode: close the slice plan (Closing an untracked plan; under protected main never — the sync above replaces this close, also when it reports ON_TRUNK=yes). Then release the worktree's plan copy (above), remove the worktree and delete the slice-branch:
git worktree remove ../<repo>-worktrees/<slice-id>-<slug>
git branch -d <slice-id>-<slug>
In Epic-finalize mode: close every included slice's plan AND the epic plan (Closing an untracked plan; under protected main never — the sync above replaces this close, also when it reports ON_TRUNK=yes). Then release each slice worktree's plan copy (above), remove the slice-worktrees, the epic-worktree, and delete all the branches:
for each <slice-id>-<slug>: git worktree remove ../<repo>-worktrees/<slice-id>-<slug>
git branch -d <slice-id>-<slug>
git worktree remove ../<repo>-worktrees/epic-<NNN>-<slug>
git branch -d epic-<NNN>-<slug>
If any git branch -d fails (unmerged commits — should not happen at this point), surface the warning, skip the delete, and let the user inspect. Never -D (force).
A slice/epic that just closed may have been the prerequisite another slice was blocked on. Once the close is durable (Step 7 done), free the dependents:
Collect the closed ID(s): the slice-ID just archived (Standard / Slice-finalize), or in Epic-finalize the epic-ID and every included slice-ID.
Glob .claude/plans/*.md and read each remaining plan's frontmatter. Match any plan whose
Blocker-type: is prerequisite-work and whose Blocked-on: value equals one of the
closed IDs. The Blocker-type guard is essential: only prerequisite-work puts a slice/epic-ID
in Blocked-on — external / decision / access blockers carry free text, which must
never be auto-cleared even if it happens to string-equal a closed ID (those clear only via
/craft:unblock). (A Blocked-on: (pending — …) marker holds no ID and never matches — it must
be back-filled via /craft:unblock before its prerequisite closes, or it will not
auto-resurface. Surface a one-line reminder if a (pending) dependent exists for a closed
prerequisite the user likely meant to link.)
For each matched dependent plan, clear the block:
Blocked-status is not one of the six execution tokens (implementing,
testing, review, refactoring, reviewing, committing), skip it and warn rather
than restoring blindly — a corrupt resume token would strand the slice (mirrors
/craft:unblock Pre-Assertion A2);Status: back to the plan's Blocked-status value;Blocker-type, Blocked-on,
Blocked-since, Blocked-status);## Blocker section resolved — prepend > Resolved: <ISO date> — <closed-id> landed
and keep the prose as an audit note (do not delete it).Emit a notification listing each freed slice and the status it resumed at:
↻ Unblocked by this close:
slice-<NNN> "<title>" → resumed at <status> (was Blocked-on <closed-id>)
If nothing was blocked on the closed ID(s), this step is a silent no-op.
This step never deletes or commits — it only rewrites the dependents' frontmatter/## Blocker
section. It is safe to run in every mode; the closed ID set is what scopes it.
Run all of the following. Any failure → warn loudly, surface to the user, do not pretend success. No auto-rollback (git history is durable). On the protected-main PR first invocation (Step 6 halts at awaiting-approval before Step 7), only P1–P4 apply; P5–P6 run on the second invocation after gh pr merge.
For each commit proposed in Step 1 and confirmed by the user — and each record commit (Step 5b) and plan-closing commit (Step 7, or under protected main Step 6's plan-landing.sh close) — verify the commit hash exists:
git cat-file -e <hash>
Failure → "⚠ Commit <hash> (<subject>) is not present in git history. The split may have been interrupted. Inspect git log manually."
bash "${CLAUDE_PLUGIN_ROOT}/scripts/tree-dirt-state.sh"
It must report DIRTY=no — the work commits (Step 3), the record commits (Step 5b) and the plan-closing commit (Step 7, or under protected main Step 6's plan-landing.sh close) leave nothing of this slice behind. A remaining DIRT= line whose path A3 already listed and that no commit of this run touched is the human's own change, kept out of the split on purpose: report it as ℹ Left uncommitted (yours): <paths> — not a failure. Any other DIRT= line → "⚠ Working tree is not clean after Phase 9: <DIRT= lines>. Uncommitted changes remain — Phase 9 commits the sub-task changes, the archive and the promotions. Inspect manually."
Read .claude/project/slices/slice-<NNN>-<slug>.md in the checkout Steps 4–5 wrote in (Where Steps 4 and 5 write, Step 4): the main checkout, or — on the first pass of a protected-main finalize — the slice/epic worktree; on that mode's second pass, the main checkout after Step 7's trunk sync. Must exist and contain the headers ## What, ## Why, ## Commits, ## Decisions.Failure → "⚠ Slice archive entry missing or malformed at <path>. Step 7 has closed the plan — recover the recap from it: deleted → from git, if it was tracked; moved → at <TARGET> in .claude/plans/.closed/, which only you can open (CRAFT's guard blocks reading it)."
The epic archive (Epic-finalize, Epic-close) — checked against templates/epic-archive.md.template itself, never
against a copy of its headings: for every ## line of the template, the archive holds a line that starts with that
line's text up to its first {{ (all of it when it has none) — ## Slices ( matches ## Slices (10/10). By command,
one call per heading: awk -v h='<that text>' 'index($0, h) == 1 { f = 1 } END { exit !f }' <archive>. The archive
also holds no ## Commits line (grep -qxF '## Commits' fails).
Failure → "⚠ Epic archive <path> lacks <heading> from templates/epic-archive.md.template (or carries a ## Commits
section). Fix the archive before the next slice."
For each decision promoted to [I] or [R] in Step 4, in the same checkout P3 reads:
[I] → confirm .claude/project/intent.md now contains the promoted text (or the user explicitly rejected the diff at Level 0, which down-grades to [K]).[R] → confirm .claude/project/rules.md now contains the promoted text (same caveat).Failure → "⚠ Decision <text> was marked for promotion to <intent.md | rules.md> but the file does not contain it. The decision is preserved in the slice archive; reconcile manually if needed."
Every plan file Step 7 closed or removed must no longer exist at its path (a moved plan lives in .claude/plans/.closed/):
.claude/plans/slice-<NNN>-<slug>.md..claude/plans/epic-<NNN>-<slug>.md.Failure → "⚠ Plan file still present at <path>. The slice did not fully close. Close it by hand after confirming the archive is correct."
In Slice-finalize and Epic-finalize modes: every worktree removed in Step 7 must no longer appear in git worktree list --porcelain, and every deleted branch must not appear in git branch --list <name>.
Failure → "⚠ Worktree <path> or branch <name> was not cleaned up. Inspect with git worktree list and git branch — /craft:worktree-clean can reconcile orphans."
For every dependent freed in Step 7b: it was a prerequisite-work blocker (no external /
decision / access blocker was cleared), its restored Status: equals the Blocked-status
it recorded and is one of the six execution tokens, the four on-demand blocker fields are
gone, and its ## Blocker section carries the > Resolved: marker. If no dependent was blocked
on the closed ID(s), this passes vacuously.
Failure → "⚠ Dependent <slice> was matched for auto-resurface but its state is inconsistent
(Status/blocker-fields/Blocker-marker). Inspect its plan before resuming it."
Success:
✓ Slice slice-<NNN> "<title>" closed.
✓ Pre-assertions: slice ✓, tests green, recap present
✓ Post-assertions: <N> commits ✓, working tree clean, archive ✓, plan closed
Commits:
<hash> <subject>
<hash> <subject>
...
Archive: .claude/project/slices/slice-<NNN>-<slug>.md (committed in <hash>)
[PR: <url>]
[Plan <path> still tracked on <trunk> — the merged PR did not carry its removal; the unstaged deletion here is what its own PR needs]
Recommended next: /craft:plan to start the next slice, or /craft:prime to refresh status.
A closable epic left behind (slice-061 review R1-4). When Mode Detection step 0 did not run — a slice was at
committing, or a finalize worktree existed — and the checkout is on the trunk once Step 7 is done, run step 0's helper
command once more. CLOSABLE_COUNT= above 0 → replace the Recommended next: line with
Recommended next: /craft:commit — closes <EPIC> (<KIND>), one line per closable epic — under pull-request +
Protected-main: yes Recommended next: /craft:commit — closes <EPIC> (<KIND>) through a PR (two passes: it opens the PR, you approve it, you run it again), since Epic-close's PR path cuts the close branch from the trunk. Not on an
autopilot epic branch (Autopilot Mode) and not when the helper cannot run — then the line stays as it is.
Protected-main PR opened (awaiting approval — first invocation):
⏸ Slice slice-<NNN> "<title>" — PR opened, awaiting your GitHub approval
PR: <url> (#N)
Branch: <branch> → <trunk> (main NOT merged yet)
The commits are in the PR. Approve it on GitHub (a real review), then:
[In-place with a tracked plan: stay on <branch> in this checkout until then — the plan is an
untracked file here, so `git checkout <trunk>` refuses; `stash -u`, `clean` or `checkout -f`
would destroy the live plan.]
Complete: /craft:commit (detects the approval and merges via gh)
Aborted:
Phase 9 aborted — <reason>. No mutation occurred.
Partial (commit landed but post-assertions surfaced issues):
⚠ Phase 9 partially complete — <which assertion(s) failed>.
Commits already in history:
<hash> <subject>
...
[Archive written | plan file still present | promotion incomplete — details above]
Inspect and reconcile manually before starting the next slice.
| Situation | Behavior |
|---|---|
| A1 fails (no slice / multiple slices) | Abort with the diagnostic message. |
A2 fails (wrong Status: in plan) | Abort with hint to run the proper phase command first. |
| A3 fails (nothing to commit) | Abort. |
A3 (finalize): a slice worktree holds uncommitted slice work (--scope slice-worktree) | Abort before any merge; name the worktree, its DIRT= lines and the /craft:execute <slice-NNN> re-run whose step 6 commits it. |
| A4 fails (tests red) | Abort, refuse to commit. |
| A5 fails (no recap) | Abort with /craft:recap recommendation. |
| User aborts during split proposal | Clean abort; no commits, no mutations. |
git commit mid-loop fails (pre-commit hook) | Stop; the partial commits stand; emit the partial-completion block. Do not auto-revert. |
Decisions promotion: user picks [I] or [R] but rejects the proposed diff | Down-grade that decision to [K]; do not write intent.md / rules.md. P4 treats this as expected, not a failure. |
| Push fails (network, auth) | Stop after Step 6; archive written, plan kept, user told how to push manually. Do not proceed to Step 7. |
| PR creation fails | Same as push fail: archive written, plan kept, recovery instructions emitted. |
plan-landing.sh sync fails after the merge (fetch, diverged trunk, checkout, fast-forward) | Surface git's reason and its ERROR=; no branch or worktree is removed. The plan copy is as it was (awaiting-approval) on the branch sync started from, so a re-run retries the sync once the cause is cleared. |
Step 7: plan-roundtrip.sh release reports conflict, or cannot run (finalize modes) | Skip that slice worktree's removal and branch deletion with a ⚠ line naming the worktree and the reason; the rest of Step 7 goes on, and the leftover is the human's (inspect it, then git worktree remove and git branch -d, as the line says). |
| P1–P5 fail after the procedure | Warn loudly; emit partial-completion block; do not auto-rollback. |
No slice plan and no epic closable (Mode Detection step 0), or Epic-close's E1–E3 fail, or its close question (E4) answered [N] | Stop before any write; word each epic's state as the mode's state table does. |
| Epic-close re-run after a close that stopped part-way | E4 finds the epic archive committed and resumes at step 4 (PR path: at the first pass's item 2) — never a second walk, archive or archive commit. |
Epic-close, PR path: the epic's PR is MERGED or CLOSED at the first pass (E3), or the close branch already exists | Stop before any write; the line names the trunk sync (MERGED — a re-run then closes through the close branch), the PR to inspect, or the branch. |
Epic-close, PR path: the push or gh pr create fails on the first pass | Same as a failed push of a slice: the commits and the epic plan stay, the plan is not set to awaiting-approval; a re-run resumes at the push. |
Epic-close second pass: the close PR is not approved, closed, or gh pr merge fails | Step 6's second-invocation message; nothing changes and the epic stays closing. A PR closed without merging also gets the way out (second pass, item 1): reopen it, or start the close over by hand. |
/craft:commit is where the auto flow ends (skills/workflow/SKILL.md → Auto flow): it does not ask
scripts/flow-state.sh and starts nothing afterwards; the closing output's Recommended next: stands. It does settle a
pause request still pending (bash "${CLAUDE_PLUGIN_ROOT}/scripts/pause-request.sh" consume --project "<project-root>", in CRAFT's own source repo scripts/pause-request.sh): the flow
ended, and an unread request must not pause the next slice of this session. A missing or failing helper does not matter here.
Applies whenever the main checkout's current branch is an autopilot epic branch, epic-<NNN>-<slug> — when
/craft:execute's Autopilot run → a3 runs this command, and when a human does, after answering an autopilot
stop by hand (/craft:test recommends /craft:recap, and the slice walks on to here). The slice was built in place on
that branch, the one checkout, so Mode Detection finds Standard mode. Everything above runs as written, with these
differences. Not when Mode Detection step 0 finds an epic to act on: with no slice plan at committing or
awaiting-approval, the epic branch checked out and its epic reading pr-path or closing, that is Epic-close's
PR path, which runs on this very branch — its two passes keep Step 6 and Step 7's Plans and the trunk under protected
main (the push, the PR, the trunk sync and the branch deletes), and none of the differences below applies to them.
The landing — whoever runs it:
## Merge Workflow says. The epic branch is where the slice lands; nothing is pushed
and no PR is opened per slice. The merge into the trunk is the human's answer at the end of the run (a5).git rm -f,
then a pathspec commit chore(plans): close slice-<NNN> on the epic branch; an untracked one: closed (Closing an
untracked plan, Step 7). The protected-main
gate note, Plans and the trunk under protected main (plan-landing.sh) and In-place-finalize do not apply —
no git checkout <trunk>, no sync, no merge, no branch deletion; the checkout stays on the epic branch. Without this,
every landed slice would reach the trunk one by one, before the human has seen the epic — and a trunk sync would
leave the epic branch mid-run.Recommended next: /craft:execute epic-<NNN> --autopilot — the run resumes
at the next slice.Only when /craft:execute a3 runs it — Level 2, no questions:
Slice: footer and the profile's Co-Authored-By and language settings apply unchanged. No plan other
than the one this run closes enters the split — Step 1 leaves them to a human, and there is none here; the epic
plan's ## Autopilot Log lines stay uncommitted.[K], without the dialog. Nothing is written to intent.md / rules.md: a
promotion stays a human's Level-0 act. Step 5 carries each decision line into the archive's ## Decisions as
written — the epic-end digest finds a Refactor candidate (autopilot, not applied): line by its prefix
(/craft:refactor → Subagent Mode, /craft:execute → a5). Check the Phase-7 lines by command before Step 5b,
the plan still in place. They are the decision bullets in either of refactor.md's two forms, matched at the line
start so that a plan or archive that merely mentions the prefix (in its Goal, recap or diagram) counts nothing:
grep -cE '^- \*\*(Refactor candidate \(autopilot, not applied\):|Phase 7 \(autopilot\): no refactor candidate)\*\*'
on the plan and the same on the archive must print the same count. When the archive has fewer, insert the plan's
lines it does not already hold verbatim — grep -E '<the same pattern>' <plan> | grep -Fxv -f <archive> prints
them — unchanged, at the end of the archive's ## Decisions, and count again; still unequal → stop, a failed
assertion. A slice-056 probe wrote the archive's decisions from memory and dropped the plan's line — read off the
files, not recalled.A failing pre- or post-assertion stops the command as it always does; /craft:execute then stops the run (a3).
Mode Detection step 0 found it: an epic whose slices have all landed, with no epic worktree left to finalize. It comes
in two kinds, the helper's KIND=:
KIND=autopilot — an autopilot run's a5 [Y] merged the epic branch into the trunk, or opened a PR for it. Each
slice already went through this command on the epic branch (Autopilot Mode) — committed, archived, its plan closed
(D37).KIND=sequential — the epic plan has no autopilot log: a sequential run (/craft:execute s5) or an epic worked
slice by slice by hand. Each slice already landed on the trunk through this command; there is usually no epic branch
(D38).What is left is the epic: its decisions, its archive, its plan and — for an autopilot epic — its branch. A human runs
this mode; Level 1 as everywhere above. Whether an epic is ready is decided once, by scripts/epic-close-state.sh (its
header) — this section only acts on its lines.
Two paths (D39). Under Merge → Type: pull-request with Protected-main: yes — or for an epic whose line reads
STATE=pr-path or STATE=closing — the close cannot be committed on the trunk. It runs as the PR path, in two
passes (The PR path, below). Every other epic closes on the direct path: Steps 1–6 below, on the trunk.
The state table — what each STATE= line of the helper means here. Step 0's abort and pre-assertion E2 word it
so. The a5 states and pr-path occur only with KIND=autopilot:
| Line | Meaning | Tell the human |
|---|---|---|
STATE=closable | every entry landed; autopilot: merged on a5 [Y] (or its PR merged and the trunk synced), the branch merged (or already deleted); sequential: no unmerged epic branch | the target — any other closable line: <EPIC>: closable too — run /craft:commit again to close it |
STATE=not-signed-off | the run is open, a5's question was never answered (no_answer), or the run stopped before a5 (run_stopped) | <EPIC>: not signed off (<REASON>) — re-run /craft:execute <EPIC> --autopilot |
STATE=not-merged | a5 answered without a merge into this trunk (REASON=) | <EPIC>: not merged into <trunk> (<REASON>) — a re-run asks again |
STATE=pr-path | a5 opened a PR and the trunk does not hold its merge yet | on the PR's branch (BRANCH= is the current branch) the target — the first pass rides on that PR; elsewhere <EPIC>: PR still open — check out <BRANCH> and run /craft:commit (the epic's record joins the PR), or merge it on GitHub with a merge commit (not squash or rebase), update <trunk> and run /craft:commit |
STATE=closing | the epic's close PR is open (the first pass ran; the plan reads awaiting-approval) | the target of the second pass — any other closing line: <EPIC>: close PR open — approve it on GitHub, then run /craft:commit |
STATE=entries-open | an entry has not landed (REASON=) — for a sequential epic, simply one still in progress | <EPIC>: <REASON> — every entry must land first |
STATE=branch-unmerged | the trunk does not hold BRANCH= (BRANCH_STATE=) — after a5's merge line, or an epic branch a sequential epic left | <EPIC>: <BRANCH> is <BRANCH_STATE> on <trunk> — merge it, or, if it holds nothing to keep, delete it with git branch -d <BRANCH> (git refuses while it carries unmerged commits); then run /craft:commit again |
STATE=malformed | the epic plan cannot be read as one (REASON=) | <PLAN>: <REASON> |
Pre-assertions — any failure stops before anything is written. A1–A6 do not apply (there is no slice to commit, and the code already landed — A4's test run belongs to the slices, which ran it).
E1 — Main checkout. A0 as written. The branch is judged by E3, once the path is known.
E2 — One epic to act on. The targets, in this order: STATE=closing lines (a close already in flight is
completed first — the second pass); else the STATE=closable lines plus the one STATE=pr-path line whose BRANCH=
is the current branch (the first pass). Exactly one → record its EPIC=, PLAN=, KIND=, BRANCH= and
BRANCH_STATE=. More than one → list them and ask which to close (this command does not auto-pick; with AskUserQuestion, one option per epic — where the tool is not available, a numbered list as text). Either way,
print every other line in its table wording, one line each, here, before Step 1 — the human sees what stays open
before anything is written, not only in the closing summary (slice-061 human test).
E3 — The path, and the branch it runs from. The PR path when the profile's Merge → Type is pull-request
with Protected-main: yes, or the target's state is closing or pr-path; else the direct path. Then, per path:
git branch --show-current is the trunk, else stop — "Check out <trunk> first."closing): the epic branch, the close branch or the trunk (Mode Detection step 0 runs on
those three; plan-landing.sh sync moves the checkout to the trunk itself).pr-path: the current branch is BRANCH= — the PR's branch, which the close rides on.
Before anything is written, <N> is the number in the plan's last ■ line (PR #<N> opened), and
gh pr view <N> --json state,reviewDecision,headRefName,url must read headRefName = BRANCH=, else stop —
"PR #N belongs to branch <headRefName>, not <BRANCH> — check the epic plan's PR #N opened log line, or
check out <headRefName>; nothing was written." — and then:
OPEN → rides (a reviewDecision of APPROVED is said once, before anything is pushed: "PR #N is approved
already — pushing the close adds commits, so GitHub may ask for the approval again"); MERGED → stop: "PR #N is
merged on GitHub — check out <trunk>, bring it up to date (git pull --ff-only), then run /craft:commit
again: the close then opens its own close PR. If the helper still reads this epic pr-path on the updated trunk,
the PR was squash- or rebase-merged: no merge commit proves it, and this mode cannot close it — record the epic by
hand."; CLOSED → stop: "PR #N is closed without merging — inspect it on
GitHub."closable: the current branch is the trunk, else stop — "Check out <trunk> and bring it
up to date (git pull --ff-only) first: the close branch is cut from it." The one exception is a first pass that
stopped part-way and is resumed (E4): the checkout is the close branch <EPIC>-<slug>-close itself. On the trunk, a
close branch of that name that already exists stops here, before E4's question, and nothing is overwritten:
"<EPIC>-<slug>-close exists already — check it out and run /craft:commit again to resume that close, or delete
it with git branch -d if it holds nothing to keep (git refuses while it carries unmerged commits)."gh auth status succeeds, else stop before anything is written — the push and the PR are the
pass's last steps, and a commit made before they fail would only leave the human a half-done close.It runs before E4's question, so the human is never asked to close what this profile or checkout then refuses (slice-062 review R1-1).
E4 — The human says so. The second pass skips this: the first pass asked, and this run only completes it. A first
pass (every path): ask, Level 1, with AskUserQuestion (two options; where the tool is not available, as text), with the target's title and kind: Close <EPIC> "<title>" (<KIND>) now? [Y] close it / [N] leave it open — alone, as a question of its own, never batched with Step 1's decisions walk;
Step 1 starts only after the [Y] (slice-062 human test). [N] stops, nothing written. "Every entry landed" can be
true of an epic the human still means to extend, and a sequential epic has no a5 [Y] (D38). On [Y], run
bash "${CLAUDE_PLUGIN_ROOT}/scripts/epic-entry-link.sh" resolve <PLAN> and hold its SLICE= IDs — P3 checks the
archive against them after the plan is closed (R1-3). On the pr-path first pass the helper has not judged the
entries (the epic's PR is still open), so they are checked here: RESULT=ok and every SLICE= line reads
STATE=landed, else stop — ": has not landed — every entry must land first." And find where an
earlier run stopped: when git cat-file -e HEAD:.claude/project/slices/<EPIC>-<slug>.md succeeds, steps 1–3 already
ran and their record is committed — say so and resume at step 4 (on the PR path, at the first pass's item 2,
which also covers a first pass whose push or gh pr create failed); never walk, write or commit the archive twice
(R1-2).
E5 — Hold the tree. Run A3's tree-dirt-state.sh and hold its DIRT= lines, as Standard mode does — Step 4's
promotion check and P2 read them. A dirty tree is no abort: every commit below is a pathspec commit.
Steps (direct path) — each delegates; nothing here redefines what it runs.
## Decisions Made During This Epic only. The slices'
decisions went through their own close and stay in their archives (D37).templates/epic-archive.md.template, at
.claude/project/slices/<EPIC>-<slug>.md. Its > Merge: line names the trunk's merge commit Merge <EPIC>: … when
the epic branch was merged (BRANCH_STATE=merged or deleted), else trunk-based, no merge. The slice archives
exist already; do not rewrite them.docs(slices): archive <EPIC> (<short title>). No Slice: footer — no slice closes here; Step 2's attribution and language rules apply.chore(plans): close <EPIC> on the trunk. The slice plans closed with their slices.BRANCH_STATE=merged → git branch -d <BRANCH>; never -D. A refusal (unmerged —
should not happen after E2) → surface it, skip the delete, and let the human inspect. BRANCH_STATE=deleted or
none → nothing to delete.<EPIC> as the one closed ID — each slice's own close already ran it for that slice.Steps 1–3 are the direct path's, on the branch the close rides on; what differs is where the record lands and how the
epic plan leaves the trunk. The trunk takes no direct commit: the record reaches it with an approved PR (Step 6's
"Freigabe ≠ Merge" gate), in two passes keyed off the epic plan's Status:.
The branch the close rides on. STATE=pr-path → the epic branch BRANCH=, the PR a5 opened (the epic's own PR,
<N> from E3). STATE=closable — a sequential epic, or an autopilot epic whose PR merged before this run — has no open
PR to ride on: after E4's [Y], cut the close branch from the checked-out trunk, git checkout -b <epic-id>-<slug>-close
(<epic-id>-<slug> is the epic branch's name, BRANCH=), unless E4 found a resumed first pass already on it. A branch
of that name that already exists was stopped by E3, before E4's question. This is the one branch the command
creates itself: it is new and holds nothing yet, while switching to the epic branch (a dirty or diverged checkout the
human has to resolve) stays the human's act (E3).
First pass — the epic plan is not yet at awaiting-approval; E1–E5 passed.
Steps 1–3 as above, in the main checkout, which is on that branch. Step 2's > Merge: line names how the epic
landed: through PR (<BRANCH> → <trunk>) on the epic branch's own PR (Step 5's second value);
on a close branch, trunk-based, no merge for a sequential epic and, for an autopilot epic whose PR merged,
Step 5's third value (the trunk's commit that merged that PR).
Land it — Step 6's first invocation, items 0–4, by delegation, with the epic plan as the plan and these differences:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/plan-landing.sh" close --message "chore(plans): close <EPIC>" --keep-copy <PLAN>
— always --keep-copy: the live epic plan stays in the main checkout for the second pass;git push -u origin <branch>);gh pr list --head <epic-id>-<slug>-close --state open --json number,url first, an existing PR
is reused; else gh pr create --base <trunk> --head <epic-id>-<slug>-close --title "Close <EPIC>: <title>" --body "<what the PR carries: the epic's decisions, its archive, its plan's removal>".
The epic branch's own PR exists already, so nothing is created there, and <N> and its URL come from E3's
gh pr view. The epic archive holds no ## Commits, so there is no #N to backfill;craft:writes status=awaiting-approval marker, in Step 6 — the status graph allows exactly one per
command) sets the epic plan Status: awaiting-approval and records > PR: #N <url> in its frontmatter — only once
the push (and, on a close branch, the PR) succeeded;A failing git push or gh pr create leaves the plan where it is and the commits standing: the human clears the cause
and runs /craft:commit again, and E4's resume picks the pass up at this item 2.
Second pass — the epic plan reads Status: awaiting-approval (STATE=closing), after the human's GitHub approval.
Steps 1–5b of the command do not run again (Step 0's short-circuit).
<N> from the plan's > PR: and the epic plan as the plan — plus
headRefName in the gh pr view call, which names the branch to delete in item 3. It reads the PR, merges an
approved one with gh pr merge <N> --merge (never --admin) and stops with its own message when the PR is not yet
approved, was closed, or the merge fails; nothing changes then and the epic stays closing. For a PR closed
without merging it adds the way out to its message: reopen PR #N on GitHub and run /craft:commit again, or start
the close over — check out the branch the close rode on, delete the close branch if there is one (git branch -d),
remove the epic plan's > PR: line and set its Status: back by hand (the first pass overwrote it with
awaiting-approval; git log -p on the plan shows the earlier value), then run /craft:commit again. Read the plan's
Epic-Slug now: item 2 drops the plan, and item 3 needs the epic branch's name.bash "${CLAUDE_PLUGIN_ROOT}/scripts/plan-landing.sh" sync --trunk <trunk> <PLAN>
— brings the main checkout to the merged trunk and drops the epic plan's local copy, as that note defines (its
ON_TRUNK=yes and ERROR= outcomes included; an ERROR= stops before the branch is removed, and a re-run retries).
The epic archive and the promotions the first pass committed are now in the main checkout.git branch -d <headRefName> (the branch the close rode on: the epic branch, or the
close branch) and, when it exists and is not that one — an autopilot epic whose PR merged before the close — the
epic branch <EPIC>-<Epic-Slug> too, as the direct path's step 5 does; never -D. A refusal → surface it, skip that
delete, let the human inspect. The checkout is on the trunk by now, so none of them is checked out.<EPIC> as the one closed ID.Post-assertions — P1, P2, P4 and P7 as written, and P3, P5 and P6 below. On the PR path they split by pass, as
Step 6 splits them: the first pass runs P1–P4 (the plan-closing commit P1 counts is plan-landing.sh close's),
the second pass P5–P7, and re-reads P3's archive in the main checkout (it reached the trunk with the merge).
templates/epic-archive.md.template) and
names every slice E4 held — by command, not by reading: grep -qF -- '<slice-id>' <archive> succeeds for each held
SLICE= ID.PLAN= (a moved one lives in .claude/plans/.closed/), and the helper,
run again, prints no line for it.git branch --list <BRANCH> prints nothing (on the PR path: for the branch the close rode on
and for the epic branch <EPIC>-<Epic-Slug>; unless a delete surfaced a refusal, or there was none to delete).Output:
✓ Epic <EPIC> "<title>" closed (<KIND>).
✓ Post-assertions: <N> commits ✓, working tree clean, archive ✓, epic plan closed[, <BRANCH> deleted]
Commits:
<hash> <subject>
Archive: .claude/project/slices/<EPIC>-<slug>.md (committed in <hash>)
Recommended next: /craft:plan to start the next slice, or /craft:prime to refresh status.
The PR path's second pass prints this block too, with a line PR #N merged after the first and without the Commits:
list (the first pass made them). Its first pass stops with the awaiting-approval block instead:
⏸ Epic <EPIC> "<title>" — <the epic's PR carries the close | close PR opened>, awaiting your GitHub approval
PR: <url> (#N)
Branch: <branch> → <trunk> (<trunk> NOT merged yet)
The epic's decisions, its archive and its plan's removal are in the PR. Approve it on GitHub (a real review), then:
[Where the trunk tracked the epic plan: it is an untracked file here now — stay on <branch> until then;
`git checkout <trunk>` refuses, and `stash -u`, `clean` or `checkout -f` would destroy the live plan.]
Complete: /craft:commit (detects the approval, merges via gh, brings <trunk> up to date)
When P5's helper run still prints a STATE=closable line — a second finished epic — replace the Recommended next:
line with Recommended next: /craft:commit — closes <EPIC> (<KIND>), one line per such epic (R1-4).
intent.md / rules.md requires explicit [I] / [R] from the user and diff confirmation — in an autopilot run every decision stays [K] (Autopilot Mode).direct profile never opens a PR; a pull-request + Protected-main: yes profile opens one automatically as the profile-driven landing (Step 6) — but even then it never merges without a real GitHub approval (no --admin), and it opens none for a slice on an autopilot epic branch (Autopilot Mode)._legacy/ files or any project history.Files this command reads when invoked
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub chriras/craft --plugin craft24 commands in this plugin
/abort/craft:abort — Abandon a SliceAbandon a slice. Asks confirmation, then closes the plan file by default — deleted, or moved into .claude/plans/.closed/ when the user's settings deny or ask on removing it. Aborted slices have no archive value — they leave only their (possibly partial) commits behind, which the user manages separately./block/craft:block — Block the Active Slice on a PrerequisiteRecord a first-class `blocked` state on the active slice when work cannot proceed until a prerequisite — itself a unit of work or a decision — is resolved. Classifies the blocker, writes on-demand frontmatter + a/build/craft:build — Implement the Active SlicePhase 4 — implement the active slice. Loads project-local specialist skills lazily, works sub-tasks in order, runs tests silently, bundles at sub-task boundaries./checkout/craft:checkout — Inspect a WorktreeSwitch into a slice- or epic-worktree for human inspection during Recap / Review. Read-only — resolves the worktree path, prints the cd instruction and the stack-pack provisioning hint. Does not install anything./continue/craft:continue — Resume an Active SliceResume work on an active slice. Routes automatically to the right phase command based on the slice's recorded Status. Use after /craft:prime when picking up where you left off./epic/craft:epic — Plan a Multi-Slice EpicPlan a multi-slice epic — captures Vision and initial Slice Decomposition, writes an epic plan file under .claude/plans/.Other plugins' commands for the same job