flow
Skill4 starsChanged 3 months agoMITView on GitHub
Orchestrator for Ticket-Flow — default is `--local` (all phases in this session with user checkpoints). `--parallel` works multiple ready tickets at once via worktree-isolated subagents in this session; `--serial` (one subagent at a time, merge+deploy+cleanup per ticket) and `--loop` (re-query the ready queue after every merge until empty) turn it into an unattended queue runner. Invoke as `/ticket-flow:flow <kanban-id>`, `/ticket-flow:flow --parallel [<id>…]` or `/ticket-flow:flow --serial --loop [--use-recommendations]`. Also trigger on any natural-language request to work on, implement, umsetzen, bearbeiten, or abarbeiten a specific bead/issue/kanban-item — not only the literal slash command. Phrasing like "implementier DSP-xyz", "setz Bead X um", "lass uns den Bead angehen", "arbeite die offenen/ready Beads ab" all count (User-Anweisung 2026-07-05: muss auch sinngemäß triggern, nicht nur wortwörtlich). Also the resume phrasings — "mach bei X weiter", "setz die Arbeit an X fort", "continue the aborted run": flow detects the existing worktree and resumes at the right phase instead of restarting (step 1.8).
- Commits and pushes
11 other projects use a version of this.
Adopted by
Most recently taken up by
- retospect/precis-mcptheir own version, first seen Oct 3, 2026
- Indrajitvp/claude-skillstheir own version, first seen Oct 1, 2026
- foliveira/harmoniatheir own version, first seen Sep 27, 2026
- cofin/flowtheir own version, first seen Sep 26, 2026
- simota/agent-skillstheir own version, first seen Sep 17, 2026
- Electric-Coding-LLC/skillstheir own version, first seen Sep 4, 2026
Used with
Projects with it also use review.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
SentrySkillreview
Fixture review skill.
Also in 3 projects that use this
Other versions11 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 11
- simota/agent-skills★ 87same name
- rainday/smart-blog-skills★ 35same name
- cofin/flow★ 17same name
- basezh/agent-skills-on-base★ 15same name
- retospect/precis-mcp★ 4same name
- foliveira/harmonia★ 2same name
- tonmoy007/forge-plugins★ 2same name
- tyom/skills★ 1same name
- Electric-Coding-LLC/skills★ 0same name
- Indrajitvp/claude-skills★ 0same name
1 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 4 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 9 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 75
Before pickup, check whether the item's spec still has design decisions that need a human pick.
- Very specific: line 94
When decisions were resolved here via a flag, hold the picks — they get written to the spec's ## Decision Log in step 2.5, *after* pickup, …
- Distinctive: line 112
Read the spec's ACs (step 1.7 already resolved the spec path) and judge which are met by the code that is there.
- Very specific: line 131
Only when step 1.7 resolved decisions via --decisions / --use-recommendations — otherwise skip.
- Distinctive: line 144
Commit it in the worktree:
- Very specific: line 168
Wait for user decision. On OK: Skill(ticket-flow:implement).
- Very specific: line 192
After /finish closes the bd state, build the report from bd:
- Distinctive: line 249
Before dispatch, the controller moves every ticket Backlog → In Progress — sequentially, in the main repo.
“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/flow — Ticket-Flow orchestrator
Args:
<kanban-id>(required — except with--parallel) ·<branch-suffix>(optional, forwarded to /pickup) ·--parallel(optional — work multiple tickets at once via worktree-isolated subagents; with no id = the whole ready queue, see ## Parallel mode) ·--local(optional, the default — kept as explicit flag for symmetry) ·--serial(optional — modifier of the subagent machinery, implies--parallel: one subagent at a time, merge + deploy + cleanup per ticket right after it returns; see ## Serial and loop) ·--loop(optional — modifier, implies--parallel: after every merge re-query the ready queue and continue until it is empty; takes no ids) ·--here(optional, local mode only — forwarded to/ticket-flow:pickup --here: adopt the worktree/branch this session is already in — orca, Conductor, worktrunk, bead-workflow-skills — instead of creating one; rejected with--parallel/--serial/--loop) ·--decisions a,b,c/--use-recommendations(optional, mutually exclusive — resolve the spec's## Decisionssection; see step 1.7;--decisionsis rejected with--parallel/--serial/--loop).
Decide, don't prompt — clear-cut points get a default (all modes)
At any decision point that is unambiguous or indifferent, decide with a sensible default and proceed — never stop with an AskUserQuestion menu for it. Stop only for genuine ambiguity: a choice where a wrong pick has real, non-obvious consequences and no default is clearly right. This is unconditional default behavior across every mode (--local, --parallel) — not a flag, not a mode.
Three things still stop on purpose — they are neither clear-cut nor indifferent:
--local's per-phase checkpoints — the "Ready for /implement? / finish?" review gates in steps 3/4/5. These are the value of--local; they stay. A checkpoint-free local run, if ever wanted, is a separate future flag.--parallel's P5 consolidated checkpoint — merge all / subset / stop. Not in--serial: that modifier exists for unattended runs, so each ticket merges right after its subagent returns and P5 becomes a per-ticket report, not a question — the gates are finish's verification and the merge guard (finish Step 7). Want checkpoints? Use plain--parallel(one consolidated) or--local(per phase).- The step-1.7 decision gate — a spec's genuine
## Decisionssection is ambiguous by construction; resolved by the user or by--use-recommendations, never auto-decided here.
Everything else — reference-fork with nothing to fork, sub-item strategy when there are no sub-items, "inline plan or structured plan" for a trivial bug, "which implement mode" when the plan/item makes it obvious — auto-decides. The phase skills (pickup, implement) follow the same rule; see their step notes.
What it does
Default (/ticket-flow:flow <id>) — equivalent to --local: all three phases run sequentially in this session with user checkpoints between phases.
Parallel (/ticket-flow:flow --parallel [<id>…]) — opt-in: works multiple independent tickets at once. This session is the controller; it dispatches one worktree-isolated subagent per ticket (Agent tool, isolation: worktree), collects the results, and merges them strictly sequentially. No id → the whole ready queue. See ## Parallel mode below.
Serial / loop (/ticket-flow:flow --serial --loop [--use-recommendations]) — the unattended queue runner: --serial dispatches one subagent at a time and merges, deploys and cleans up each ticket before the next one starts; --loop re-queries bd ready after every merge (newly unblocked tickets join), sweeps Testing items first, defers tickets with an unresolved decision gate instead of stopping, and ends when the queue is empty. Both imply --parallel and are the generic core of a personal autopilot skill; project policy (deploy targets, version bumps, time budget, hand-off notes) stays with the caller. See ## Serial and loop below.
DEFAULT (--local):
/ticket-flow:pickup <id> → CHECKPOINT → /ticket-flow:implement → CHECKPOINT → /ticket-flow:finishFor fine-grained control: invoke /ticket-flow:pickup, /ticket-flow:implement, /ticket-flow:finish directly.
Steps
1. Parse args
<kanban-id>(required) — e.g.96<branch-suffix>(optional) — e.g.mainsline--localflag (optional, position-independent) — the default; kept as explicit flag for clarity
# Parse the run-mode args via the pure helper. parse-flow-args.sh is
# unit-tested by tests/test_flow-parallel.sh; it sets MODE (local|parallel),
# ID, SUFFIX, PARALLEL_IDS (array — empty in parallel mode = whole ready
# queue), LOCAL, USE_RECS, DECISIONS, SERIAL, LOOP (--serial/--loop imply
# MODE=parallel), HERE (local only) — or exits non-zero with an `ERROR:` on stderr.
PARSED="$("${CLAUDE_PLUGIN_ROOT}/skills/flow/parse-flow-args.sh" "$@")" || exit 1
eval "$PARSED"1.5. Where am I? — external worktree detection
eval "$("${CLAUDE_PLUGIN_ROOT}/skills/pickup/detect-worktree.sh")" # LINKED WORKTREE MAIN_REPO BRANCH TF_OWNED MANAGERMANAGER (orca · conductor · cc · empty when the tool announces itself nowhere) names the owning tool — use it in the messages below instead of listing the whole field.
LINKED=1andMODE=parallel(also--serial/--loop) → STOP: the controller must run from the main checkout ($MAIN_REPO) —Agent-tool worktrees fork frommain, merges land onmain; inside a linked worktree that is the wrong base. Tell the user tocd $MAIN_REPO; withMANAGER=orcaorconductor, that tool also offers the main checkout as its own workspace.LINKED=1,MODE=local,TF_OWNED=0→ the session sits in a worktree tf does not own ($MANAGER, or an unannounced one — worktrunk, bws, a manualgit worktree add): setHERE=1and say so in one line, naming$MANAGERwhen it is set; pickup adopts it (its step 0 does the same detection and the branch-lock check, so an explicit--hereis never required).LINKED=1,TF_OWNED=1→ STOP: this is a tf worktree of another ticket; run/flowfrom the main checkout.
1.6. Route: parallel mode
If MODE is parallel (also set by --serial/--loop) → the single-ticket path below (steps 1.7 through 6) does not apply. Jump to ## Parallel mode (--parallel) at the end of this skill; SERIAL/LOOP select the deltas marked there.
1.7. Decision gate
Before pickup, check whether the item's spec still has design decisions that need a human pick.
- Find the spec — the
[Spec]link in the item's note is the canonical source of the spec path (projects lay specs out differently — e.g. superpowers-based projects usedocs/superpowers/specs/<date>-<name>.md); the conventiondocs/specs/<id>-*.md(first match) is only the last-resort fallback for items without a link. Sourceskills/kanban/bd-helper.sh;BD_ID="$(bd_id_for "$ID")";SPEC_PATH="$(bd_get_notes "$BD_ID" | grep -oE '\[Spec\]\([^)]+\)' | head -1 | sed 's/^\[Spec\](\(.*\))$/\1/')". Empty → convention fallback. Do not readKANBAN.md. No spec found → no gate, continue to step 2. - Read the spec. Does it have a
## Decisionssection with### D1…entries?- No
## Decisionssection → nothing to resolve, continue to step 2. ## Decisionspresent AND a## Decision Logthat covers everyD#→ already resolved (locked via the/ticket-flow:specreview step), continue to step 2.## Decisionspresent but no covering## Decision Log→ unresolved. This is normal for an approved spec whose owner chose to lock the picks at flow-time — that is exactly what the flags are for:- Neither
--decisionsnor--use-recommendationspassed → STOP. Do not run pickup. Output:⏸ /ticket-flow:flow stopped — #<id> has unresolved decisions <spec-path> has an open `## Decisions` section (D1–D<n>) with no `## Decision Log`. Review the options, then either: • lock them via the /ticket-flow:spec review step, or • re-run: /ticket-flow:flow <id> --decisions <a,b,…> (option per D#) /ticket-flow:flow <id> --use-recommendations (all recommended) --use-recommendations→ for everyD#, pick the option marked(recommended).--decisions a,b,c→ positional: optionaforD1,bforD2, … A count mismatch (more/fewer picks thanD#entries) or an out-of-range option number → STOP with an error naming the mismatch.
- Neither
- No
- When decisions were resolved here via a flag, hold the picks — they get written to the spec's
## Decision Login step 2.5, after pickup, so the log lands on the worktree branch.
1.8. Resume instead of restart (local mode)
An aborted run leaves a claimed ticket behind: status in_progress, a branch: line in the notes (set by pickup step 5), usually a live worktree. Re-running /flow <id> on such a ticket must continue it, not run pickup again — pickup would refuse on the branch-lock, and before it ever did, a second worktree would be pointless.
Detect before pickup:
source "${CLAUDE_PLUGIN_ROOT}/skills/kanban/bd-helper.sh"
BD_ID="$(bd_id_for "$ID")"
LOCK_BRANCH="$(bd_get_notes "$BD_ID" | grep -oE 'branch: [^ |]+' | head -1 | cut -d' ' -f2)"- No
branch:line → fresh ticket, continue with step 2 (pickup) as normal. branch:line present → a previous run claimed this ticket. Find its worktree:git worktree list— the entry whose branch matches$LOCK_BRANCH.- Worktree exists → resume. Skip step 2 entirely;
cdinto the worktree and decide the re-entry phase from its state, not from memory:git -C <worktree> status --porcelain+git log <base>..$LOCK_BRANCH --oneline— what is committed, what is half-done?- Read the spec's ACs (step 1.7 already resolved the spec path) and judge which are met by the code that is there.
- ACs still open, or uncommitted work → re-enter at step 3 (
/ticket-flow:implementpicks up the plan mid-way; its step 1 derives the item from the branch). - All ACs look met → re-enter at step 5 (
/ticket-flow:finish— its verification decides, not your impression). - Say in one line that this is a resume and which phase it re-enters.
- Worktree gone but branch exists (cleanup died between remove and merge, or the harness auto-removed it) → the commits survive on
$LOCK_BRANCH. Recreate a worktree on that branch (git worktree add <path> $LOCK_BRANCH), then resume as above. For a fresh worktree instead, verify its base before working (pickup step 4's base-ref note — a stale fork despitebaseRef: "head"has been observed once;git rebase <target-branch>heals it). - Branch gone too → the lock is stale (a finished run that missed the note cleanup, or a discarded attempt). Say so, remove the stale
branch:line viabd_update_notes_remove_prefix "$BD_ID" "branch:", and continue with step 2 as a fresh run.
- Worktree exists → resume. Skip step 2 entirely;
--parallel/--serial/--loop need none of this: their claim step (P3) skips tickets that are already in_progress, and P4a governs a dispatched agent's death. Resume is the --local counterpart to P4a.
2. Phase 1: pickup
Invoke Skill(ticket-flow:pickup) with <kanban-id> + optional <branch-suffix>; forward --here when HERE=1 (the session already sits in the ticket's worktree — pickup adopts it, creates nothing).
On error (DoR not met, item not in Backlog, etc.): abort + report. The user can fix the issue and re-run /flow.
Pickup returns the worktree path — keep it in $WORKTREE.
2.5. Record resolved decisions (after pickup)
Only when step 1.7 resolved decisions via --decisions / --use-recommendations — otherwise skip.
Append a ## Decision Log to the bottom of the worktree's copy of the spec ($WORKTREE/<spec-path> — the path step 1.7 resolved) — same format the /ticket-flow:spec review step uses:
## Decision Log
Locked <YYYY-MM-DD> — via /ticket-flow:flow (--decisions … | --use-recommendations).
- **D1 → Option <n>** — <one-line summary of the chosen option>.
- **D2 → Option <n>** — <one-line summary>.Commit it in the worktree:
cd "$WORKTREE" && git add <spec-path> \
&& git commit -m "spec: #<id> — lock decisions (D1–D<n>) via /flow"/ticket-flow:implement then reads a spec whose decisions are already locked.
3. Phase 2: implement
Checkpoint output:
✓ /ticket-flow:pickup for #<id> complete
Branch: <branch>
Worktree: <path>
Plan: <plan-path or "missing — consider drafting a plan doc">
Ready for /ticket-flow:implement (--local mode)?
[ ] Yes — go directly
[ ] Write/review the plan first (manually or via Skill(superpowers:writing-plans))
[ ] Stop — I'm taking a breakWait for user decision. On OK: Skill(ticket-flow:implement).
On implement failure: stop, inform the user.
4. Checkpoint after implement
✓ /ticket-flow:implement for #<id> complete
Commits: <count>
Typecheck/test: <status>
Spec ACs: <met>/<total>
Ready for /ticket-flow:finish?
[ ] Yes — merge and move to Testing
[ ] Review manually / polish further
[ ] Stop — I'll run the manual test first5. Phase 3: finish
On OK: Skill(ticket-flow:finish). On failure: stop, inform the user. No auto rollback.
6. Final report
After /finish closes the bd state, build the report from bd:
source "${CLAUDE_PLUGIN_ROOT}/skills/kanban/bd-helper.sh"
BD_ID="$(bd_id_for "$ID")"
BD_STATUS="$(bd show "$BD_ID" --json 2>/dev/null | jq -r '.[0].status')"
BD_LABELS="$(bd show "$BD_ID" --json 2>/dev/null | jq -r '.[0].labels // [] | join(",")')"Then format:
✓ /ticket-flow:flow --local for #<id> complete
Pickup: ✓ branch <branch> + worktree
Implement: ✓ <count> commits + typecheck/test green
Finish: ✓ merge to main + deploy <version>
Bd state: <BD_STATUS> · labels: <BD_LABELS>
Manual verification pending.Parallel mode (--parallel)
--parallel works multiple independent tickets at once — one worktree-isolated subagent per ticket, dispatched from this (the controller) session. Opt-in; the default is unaffected.
Why a controller + subagents: the Agent tool's isolation: "worktree" gives each subagent a real git worktree (.claude/worktrees/agent-<hash>, branch worktree-agent-<hash>). What is isolated is the working tree; the repository itself is shared — one object store, one set of refs (so every agent's commits are visible from the main checkout without a fetch) — and so is everything keyed to the repo root, including the project's permission rules, which therefore hold inside its worktrees. One controller session coordinates, and the controller serializes the merges so they never race.
Where the worktree forks from is a setting, not a given. Claude Code resolves worktree.baseRef to origin/<default-branch> unless told otherwise — not your local tip. This workflow deliberately never pushes, so with the default every dispatched agent forks off a base that is as many commits behind as you have merged since the last push. The merge still succeeds; the earlier tickets' work is simply absent from the later worktree. Step P0 refuses to dispatch in that state.
P0. Preflight — dispatch base
${CLAUDE_PLUGIN_ROOT}/skills/flow/check-worktree-base.shPrints BASE_REF, HAS_REMOTE, DRIFT, VERDICT and exits non-zero on VERDICT=fix-settings.
ok/no-remote→ continue. A repo without a remote cannot drift; that is the normal case for purely local projects.fix-settings→ stop before dispatching. Add{"worktree": {"baseRef": "head"}}to the project's.claude/settings.json, then re-run. Do not work around it by pushing — pushing is the user's call (/ticket-flow:push), never the orchestrator's.
P1. Resolve the ticket set
- No id → the whole ready queue:
bd ready. Keep only DoR-met items (same DoR as/ticket-flow:pickupstep 2). - Explicit ids → validate each is in Backlog + DoR-met; a bad id aborts the whole batch with a clear error.
- Empty set → report "nothing ready" and stop.
- Order (matters in
--serial/--loop, harmless otherwise): priority P0→P4 first; within a priority, tickets that unblock the most others (bd showdependents) first; then bugs with correctness/safety impact before features/comfort. Explicit ids keep the user's order. - Testing sweep (
--looponly, before new work): list the items labeledtestingand verify each against the code state, not the item text — does the test/code/config evidence now prove it? What is agent-provable gets closed with the evidence as close reason; what genuinely needs the user's senses/hardware stays. Never re-implement a Testing item.
P2. Decision gate — all tickets, up front
Run the step 1.7 decision gate for every ticket in the set. If any ticket has an unresolved ## Decisions section (no covering ## Decision Log), STOP the whole batch — never dispatch a partial set. Report which tickets need decisions and how to resolve them (the /ticket-flow:spec review step, or --use-recommendations). --decisions is rejected with --parallel (positional picks can't map across multiple tickets).
--loop exception: the set is dynamic, so an unresolved gate does not stop the run — the ticket is deferred (left in Backlog, listed in the final report with the two ways to resolve it) and the loop continues with the rest. --use-recommendations resolves every gate up front and is the intended companion flag for unattended runs.
P3. Mark all tickets In Progress (controller, sequential)
Before dispatch, the controller moves every ticket Backlog → In Progress — sequentially, in the main repo. Only the controller ever writes .beads/. Subagents never touch ticket state — that keeps .beads/issues.jsonl from diverging across worktrees and merge-conflicting. Write to bd only, no KANBAN.md, no render:
source "${CLAUDE_PLUGIN_ROOT}/skills/kanban/bd-helper.sh"
# per ticket:
BD_ID="$(bd_id_for "$ID")"; bd_set_status "$BD_ID" in_progress \
|| { echo "STOP: $BD_ID is claimed by another assignee — skip it"; continue; } # --claim = atomic mutexbd_set_status in_progress claims the issue (bd update --claim, atomic, idempotent for the same user); a non-zero return means another session/assignee holds it — skip that ticket (--loop: report it as taken), never dispatch on a bead someone else is working.
The branch: lock marker is not set here — each subagent's branch (worktree-agent-<hash>) only exists once its worktree is created. In --parallel the controller tracks the branch↔ticket mapping in-session instead.
--serial: mark each ticket In Progress immediately before its own dispatch, not the whole set up front — bd ready stays truthful for everything still queued, and a run that dies leaves at most one orphaned In-Progress item.
--serial, once the dispatch is live: the Agent result names the worktree branch (worktreeBranch in its task notification / spawn result) — write it as the bead's branch: note right then (bd_update_notes_replace_prefix "$BD_ID" "branch:" "branch: worktree-agent-<hash>"). Without it a run that dies with the session leaves a bead that /ticket-flow:flow <id> cannot resume (step 1.8 looks for exactly this marker) and that --serial --loop would skip as in_progress (observed 2026-09-06: marker set by hand after a session abort).
P4. Dispatch one subagent per ticket
Establish the verification recipe once — before any dispatch. The controller works out, one time for the whole batch, how this project is actually verified: the typecheck command, the test command, and the end-to-end check a change of this kind needs (sources, in order: the project conventions doc /ticket-flow:discover writes, the project's CLAUDE.md/.claude/rules/, package scripts, the CI workflow, an existing test/e2e directory). The result goes verbatim into every dispatch prompt. Left to the subagents, each one re-derives it behind its own worktree wall, and a batch ends up with as many verification standards as it has agents — with the weakest deciding what "green" meant on the tickets it happened to draw. Pattern from Claude Code's built-in /batch, which resolves the e2e recipe once up front and hands the same one to every worker. When a project has no e2e path, say that explicitly in the prompt (E2E: none — the unit suite is the ceiling) instead of dropping the line: an absent line reads as "figure it out yourself".
Bundle file-overlapping tickets first (heuristic, not an algorithm). Two worktree agents that touch the same core file fork from different points of main and produce a real 3-way merge conflict at P6 — even when the tickets change textually disjoint functions. Before dispatching, skim each ticket's spec/notes/description for the files it names; tickets that share a file go to one subagent — one worktree, one prompt covering all bundled tickets. Specs/notes usually name the core files; when unsure, bundle. P6 then treats a bundle as one unit: one branch, one merge, finish per ticket.
Dispatch all subagents in a single message (multiple Agent calls → they run concurrently), each with subagent_type: "general-purpose", isolation: "worktree", and model: chosen by ticket complexity (the model-tier table in skills/implement/SKILL.md, ticket-flow-sqh). --serial: dispatch one Agent call, wait for its report, run P6 for that ticket, then dispatch the next — never two in flight.
Each prompt is self-contained — the controller supplies everything, because the subagent's branch is not a tf branch: marker and KANBAN branch-derivation will not find the item:
Ticket #<id>: <title>
Spec: <path or none> Plan: <path or none>
Acceptance Criteria: <inline list or "see spec">
Verification recipe for this project — established once by the controller,
use exactly this, do not invent your own:
Typecheck: <command, or "none">
Tests: <command, or "none">
E2E: <command or procedure, or "none — the unit suite is the ceiling">
You are in an isolated git worktree. Implement this ticket end-to-end:
- FIRST action: an initial plan commit — `git commit --allow-empty`, your
implementation plan in the body. Then commit after every sub-step, never
batch work uncommitted: if you die early (spend limit/stall), only
committed history keeps your worktree alive and resumable — a commitless
worktree is auto-removed with all context.
- Follow skills/implement/SKILL.md steps 3–6 (pick mode by plan complexity,
incremental commits, typecheck/test after each major step). Skip steps 1–2
(branch-derivation) — the context above replaces it.
- Then run skills/finish/SKILL.md steps 2–4 and classify every AC as
*proven* or *residual*:
· step 2 — typecheck, tests and the e2e check from the recipe above,
plus the testable-surface gate;
· step 3 — the review, and it is NOT optional (skip only for a genuinely
trivial change of ≤50 lines, and say so). If the project's CLAUDE.md /
`.claude/rules/` names a dedicated review agent, dispatch that one.
Otherwise dispatch **one** `Agent` call yourself — `subagent_type:
"general-purpose"`, `model: "haiku"` — with the full diff
(`git diff <target-branch>...HEAD`) embedded directly in its prompt —
run the command and paste its OUTPUT into the prompt text: a prompt
string is never shell-expanded, so a literal `$(git diff …)` arrives
as those characters and the reviewer, handed no diff, reviews the
surrounding prose and reports that as findings (a fabricated review
that reads like a real one — observed 2026-08-25);
it reviews the diff it's handed, it does not collect its own.
Paste the FULL, UNCONDENSED diff — never summarise it, trim it,
or replace test bodies with outlines; a condensed diff produces
findings about code that is not there (observed 2026-09-10). Too
large for one prompt? Split it across two or three review agents
BY FILE GROUP, each with its full part of the diff. Ask it
to check for correctness bugs, contradictions with the surrounding
code/doc text, and call sites or other references the change may
have missed. Wait for its result and act on the findings before you
write the verdict.
If the dispatch fails, do NOT substitute your own assessment: put
`not run (<reason>)` in the verdict's `review` field and say the
same in the prose, so the controller can hand `/code-review high` to
the user as a deeper option. Never `ultra` — it cannot be started
by a model at all;
· step 4 — deploy only if the project defines one.
[--serial: steps 2–3 only — do NOT deploy; the controller deploys from
the merged target branch after the merge.]
- Do NOT merge, do NOT push, do NOT touch .beads/ or KANBAN.md, do NOT run
the finish merge/cleanup steps.
- Documentation discipline for any CLAUDE.md/AGENTS.md you touch: entries
are normative rules, at most ~2 short lines each — no diagnostic numbers,
derivations or incident narratives. That depth belongs in the project's
docs/ tree or the ticket's comments, per the routing rules the global and
project CLAUDE.md define. A format-guard hook may reject oversized
entries — tighten the entry, never work around the guard.
- On a hard blocker: report it back instead of filing the escalation bead
yourself (the controller files it).
Report: a short prose summary, then — as the LAST thing in your message —
the VERDICT as one fenced ```json block in exactly this shape (the
controller machine-checks it; a report without a valid verdict is not
merged):
{"ticket": "<id>", "branch": "<git branch --show-current>",
"sha": "<git rev-parse HEAD>", "commits": <n>,
"acs": [{"id": "AC1", "status": "proven|residual", "evidence": "<what proves it / why it needs the user>"}, …],
"tests": {"typecheck": "green|red|n/a", "suite": "green|red|n/a"},
"review": "<level> — <n> findings | not run (<reason>) | skipped (trivial, <n> lines)",
"residual_checklist": ["<step the user must do>", …],
"blockers": ["<hard blocker>", …]}P4a. Agent death (limit / stall)
A subagent can die before delivering its report, while a usable diff already sits in its worktree — or it can go quiet without dying at all: the harness still shows it running, but no new tool output has appeared for a long stretch. Read the situation first — the three cases need different responses, and the first two are distinguishable from the third by one thing: they come with an explicit error message. A stall does not — it is silence, nothing else.
- Usage limit ("you've hit your usage limit", session or weekly): a time window that reopens by itself. Claude Code continues the session automatically when a claude.ai usage limit resets (2.1.234, switchable in
/config). Waiting is the correct response; resume per rule 1 below once work continues. - Spend limit ("you've hit your monthly spend limit") or out of credits: read the message before classifying it. When it names a reset time ("your session limit resets HH:MM"), it is the plan's time quota with credit-overage disabled — the window reopens by itself; treat it exactly like a usage limit (wait, then resume per rule 1). Only a spend-limit message without a reset time is the hard money ceiling: it does not reset, the user has to raise it, and waiting never helps — which is why persistent retry mode fails immediately on these instead of polling (2.1.239). In
--serial/--loop, on the hard case: stop the run, report which tickets are done and which are untouched, and say plainly that the limit needs raising. Re-dispatching against a money ceiling produces a chain of instant deaths that burns wall-clock and context for nothing. - Stall (no error, no death — just quiet): judged by comparing elapsed wall-clock time since dispatch to what a normal dispatch on this project looks like. There is no fixed number here and tf does not compute one: it measures and reports elapsed time, it never decides "stalled" on its own — a guessed cutoff would be indistinguishable from a clean run right up until it wrongly kills one (the decision this ticket is built on, 2026-08-25). For orientation only — an observation from one real run, not a threshold (DSP autopilot swarm, 19 subagents, 2026-08-25): ordinary dispatches finished in 1–7 minutes; seven agents died on the usage limit, five of them at exactly 23 minutes; one outlier finished normally at 187 minutes. Note the dispatch time per ticket (e.g.
date -u +%FT%TZright before theAgentcall) and carry elapsed time into the P5/P7 report next to that ticket — the controller (the user in--local/--parallel, the caller's own policy layer in--serial/--loop) judges from there whether it is worth aSendMessageprobe or more waiting. Probe before treating a stall as dead: a quiet agent can still be mid-reasoning or running a slow tool, andSendMessageto a live agent is harmless.
Then, for a death of either limit kind, or a stall confirmed unresponsive after a probe, two rules:
- Resume vs. fresh dispatch — decided by worktree existence. Before any resume attempt:
git worktree list. Worktree still listed → resume viaSendMessage, restating the full ticket context plus the state found in the worktree. Worktree gone (death before the first commit — the harness auto-removes an unchanged worktree) → dispatch a fresh subagent with the original P4 prompt; never resume: a worktree-less resume continues in the main checkout and silently loses isolation. - Inspect the diff after every death — before resuming, merging, or discarding.
git diff --statin the surviving worktree + read the touched files against the ticket's requirements. The agent's last inline message often describes intent, not result — never adopt the work unchecked, never discard it unchecked. - Death at the worker MODEL's own ceiling, with the work already complete in the worktree. A resume runs on that same model and dies again; a fresh dispatch discards the commits. Instead the controller verifies against the worktree itself — build, tests twice, the e2e recipe, every AC against the code — and merges on its own verification. Say plainly in the report that the verdict is the controller's, not the agent's (observed 2026-09-10: agent died after both reviews, before its verdict; controller verified 281 tests twice, harness 24, exporter byte-identical, 20/20 ACs, then merged).
P5. Consolidated checkpoint
When all subagents return, present one checkpoint — per ticket: branch, commits, ACs proven/residual, review (REVIEW from the verdict — not reported and not run (…) are results and get printed as such; an omitted line reads as "reviewed"), blockers. --parallel has no per-ticket checkpoints — that is the trade for throughput; use the default --local when you want them. Ask once: merge all / merge a subset / stop.
--serial: no question — print the same per-ticket line as a report and go straight to P6 for that ticket. The run stops only for a hard blocker (escalation bead), a merge conflict on that ticket (left standing, loop continues), or an unresolved decision gate without --use-recommendations (deferred in --loop, stop otherwise).
P6. Merge — controller, strictly sequential
For each ticket whose subagent succeeded, one at a time — never two at once (main and .beads/issues.jsonl are shared state). A P4 bundle is one unit here: one branch, steps 1–3 once, then step 4 per bundled ticket.
Verdict gate (mandatory, before anything else): save the subagent's final message to a file and run
"${CLAUDE_PLUGIN_ROOT}/skills/flow/verdict-check.sh" <file>— it extracts the fenced ```json verdict, validates it (branch, git sha, non-emptyacswithproven|residualeach, proven needs evidence,testspresent) and printsBRANCH=… SHA=… PROVEN=… RESIDUAL=… BLOCKERS=… REVIEW=…foreval. Invalid or missing verdict → do not merge on prose. Treat it like P4a rule 2: inspect the worktree diff, thenSendMessagethe subagent asking for the verdict (worktree still present) or dispatch fresh (worktree gone).BRANCH/SHAfeed step 1,PROVEN/RESIDUALfeed the gating in step 4,BLOCKERS>0goes to step 5,REVIEWgoes verbatim into the P5/P7 report (it is reported, never gated — but anot run (…)ornot reportedis stated, not swallowed). Pattern: Castra's persona verdict — nothing mutates until the verdict validates.A shipped hook makes this structural, not just procedural.
hooks/verdict-gate.shruns onSubagentStopand validates the same message through the same script before the agent is gone, handing back the defect list while its context still exists — so a missing verdict usually costs one extra turn instead of a re-dispatch. It fires only inside a.claude/worktrees/checkout of a ticket-flow project, and blocks at most once per agent, so an agent that genuinely cannot produce one still ends. The controller check here stays: the hook reduces how often it trips, it does not replace the gate.- Verify the commits are on the expected branch (mandatory, before any merge attempt):
git branch --contains <sha>with the last-commit sha from the verdict (SHA) — the expectedworktree-agent-<hash>branch must appear.isolation: worktreedispatches occasionally commit straight onto the base branch instead, and the subagent's report still reads like success; only this check catches it. If the expected branch is missing:git rebase <target-branch>run inside that worktree replays the commit onto the right base without losing it — then re-run the check. Do not merge until it passes. cd <main-repo>— commit dirty.beads/yourself, exactly as inskills/finish/SKILL.mdstep 5c: skip when.beads/is gitignored (git check-ignore -q .beads/issues.jsonl), otherwisegit addthe dirty.beads/exports andgit commit -m "chore: bd-Export-Sync vor Merge"on the target branch — never leave it to the user (a dirty.beads/makes every merge refuse with "Your local changes … would be overwritten").git merge <worktree-agent-branch>— on a conflict: stop this ticket, leave it for the user, continue with the rest. 3a. Catch-up review — only when the subagent's did not happen (every dispatched mode:--parallel,--serial,--loop;--localnever reaches P6 and gets its review from finish step 3 directly). P4 step 3 has the subagent run one cheap diff-review inside its worktree, before the merge; that is where a finding is still cheap to act on. ReadREVIEWfrom the verdict: a real result (<level> — <n> findings) means the review happened — do not run a second one, the whole point of the change was to stop paying twice. Anot run (…)ornot reportedmeans it did not — but check your own inbox first: a review agent dispatched by a subagent sometimes delivers its task-notification to the CONTROLLER rather than to the subagent that spawned it, so the subagent finalises withnot runwhile the result is already sitting here (observed 2026-08-26 on a DSP run; not reproducible on demand). If such a result arrived, credit it and correct the verdict'sreviewfield instead of paying for a second review. Credit it only when it demonstrably belongs to this ticket — same branch or the sha the verdict names, and the ticket id in the review agent's own prompt. Anything less and you are attributing a review of some other diff. No match → run it now, controller-side — ONE agent,model: haiku, read-only, the merged commit range named in the prompt, focus on real correctness bugs, no style findings — and act on its findings before anything downstream. Project-specific risk reviews (e.g. a safety reviewer wired into the project's deploy skill) stay as the project defines them, on top of this. Nevercode-reviewat levelhighhere: it fans out ~8 finder agents plus verifiers, several 100k tokens per ticket, and a spend-limit death mid-fan-out loses all of it (measured on the DSP autopilot run 2026-08-24/25: three dead attempts, zero findings delivered)./code-review highstays a recommendation the report hands to the user.- Finish the ticket: run
skills/finish/SKILL.mdsteps 6–7 — gating (residual → Testing, none → Done) from the subagent's classification, the state update (bd only — neverkanban-render.shin the workflow), and worktree cleanup behind finish Step 7's guard: firstgit -C <main-repo> merge-base --is-ancestor <worktree-agent-branch> <target-branch>(fails → the merge in step 3 did not land, e.g. it ran from a cwd where that branch was already HEAD and printed "Already up to date" — stop this ticket, no cleanup, no-D) andgit -C <path> status --porcelainempty; only thengit worktree remove <path>. Nogit worktree unlockfirst: since 2.1.157 a Claude-managed worktree is left unlocked when its agent ends (often removed by the harness outright), so the lock is gone by the time the controller cleans up — a lock that is still there means a live session holds the worktree, and forcing past it is wrong. Thengit branch -D <worktree-agent-branch>(safe only because the guard proved containment). On anOperation not permittedfrom the remove, apply finish Step 7's verify-then-defer rule:git worktree listdecides (the error is often fake); if the path survives, leave it standing and hand the manual commands to the user — never delete the directory yourself. Acannot remove a locked working treeis the other error: judge it by whether the work is safe, not by the locking pid. That pid is the whole session, not the agent, so it stays alive after a subagent reports and a pid check alone never clears anything (measured 2026-08-25: two of four worktrees stranded that way). Agent reported and the is-ancestor guard above passed and the worktree is clean →git worktree unlock <path>then remove (-ffalso overrides the lock; a single--forcedoes not). Any of the three missing → leave it standing; Claude Code's own periodic sweep (cleanupPeriodDays) collects it later without touching worktrees that still hold work. - On a reported hard blocker: file the escalation bead now, controller-side, per
skills/implement/SKILL.md§ Escalation on a hard blocker.
--serial additions (between step 3a and step 4): 3b. Deploy from the merged target branch — if the project defines a deploy (finish Step 4's project deploy step, or a standing order in the project's CLAUDE.md), the controller runs it now, from <main-repo> on the freshly merged <target-branch>; the subagent was told not to. One deploy target, never concurrent, always the merged state. A failed deploy stops the run (no rollback, everything left for inspection — same rule as finish). Then step 4 as above (state update + guarded cleanup).
--loop additions (after step 4): re-run P1 — bd ready again (merged tickets may have unblocked others), re-apply the order, skip deferred/blocked/conflicted tickets from this run, and continue with P3 for the next ticket. The loop ends when the queue is empty, when every remaining ticket is deferred/blocked, or when the caller's own budget logic says so — wake-up-timer and spend-budget policy stays with the caller, because tf has no visibility into the caller's subscription plan or cost ceiling (not because it cannot read a clock: it reports elapsed time per ticket, see P4a, and leaves the cutoff decision to that policy layer).
P7. Final report
One consolidated report — per ticket: Done / Testing (+ residual pointer) / merge-conflict / blocked, plus the ticket's REVIEW string. --loop adds: Testing items closed by the sweep (with evidence), tickets deferred (open decision gate — name the two ways to resolve), escalation beads filed, deploys run, and why the loop ended (queue empty / all remaining deferred or blocked / caller stop). Network ops stay out: --parallel/--serial/--loop leave commits local like the default mode; the user runs /ticket-flow:push from this session afterwards.
Serial and loop — summary
--serial and --loop are modifiers of the parallel machinery (they imply --parallel; the arg parser emits SERIAL/LOOP). Everything in P1–P7 applies, with the deltas marked --serial / --loop above: ordered set + Testing sweep (P1), deferral instead of batch-stop (P2), In Progress per ticket (P3), one subagent in flight and no subagent deploy (P4), report instead of checkpoint (P5), controller deploy after merge + re-query (P6), extended report (P7). P4a (agent death), the P6 verdict gate (verdict-check.sh — no merge on prose) and finish Step 7's guard (is-ancestor + clean tree before any -D/remove) apply unchanged. What stays outside tf by design: deploy targets and version bumps, spend/time budgets and wake-up timers, hand-off notes into a personal knowledge vault — that is the caller's (e.g. a personal autopilot skill's) policy layer.
What it doesn't do
- Implementation logic — fully delegates to the phase skills
- Verifying the "Done" status — that stays manual (real test)
- Conflict resolution — on a merge conflict, the user takes over
- Network ops (
git push,gh repo create) — these happen via/ticket-flow:push//ticket-flow:publish. After a/ticket-flow:flowchain finishes, the user runs/ticket-flow:pushto upload. Scope of "commits stay local, no push, no PR": it is tf's rule for the sessions tf itself drives — this controller and the subagents it dispatches, which the P4 prompt tells so explicitly. It is not a property of agent sessions in general: a Claude Code background session commits, pushes and opens its own draft PR (2.1.198). Work handed to one of those is outside this guarantee, and/ticket-flow:pushis then not the only thing that can reach the remote.
For reference / troubleshooting (read on demand only):
- Behavior on interruption (stateless flow + recovery hints)
- Tradeoff: auto-finish without user checkpoint (rationale for
--localopt-in) - When NOT to use /ticket-flow:flow (anti-patterns)
→ See reference.md in this skill folder.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

