flow-workflows 0.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +320 -0
  3. package/adapters/README.md +128 -0
  4. package/adapters/codex/AGENTS.md +82 -0
  5. package/adapters/codex/CORE.md +522 -0
  6. package/adapters/codex/PRIMITIVES.md +64 -0
  7. package/adapters/codex/README.md +126 -0
  8. package/adapters/codex/config.snippet.toml +88 -0
  9. package/adapters/codex/skills/flow-bug-fix/SKILL.md +171 -0
  10. package/adapters/codex/skills/flow-bug-investigate/SKILL.md +216 -0
  11. package/adapters/codex/skills/flow-bug-postmortem/SKILL.md +98 -0
  12. package/adapters/codex/skills/flow-bug-review/SKILL.md +190 -0
  13. package/adapters/codex/skills/flow-bug-ship/SKILL.md +187 -0
  14. package/adapters/codex/skills/flow-bug-start/SKILL.md +212 -0
  15. package/adapters/codex/skills/flow-bug-validate/SKILL.md +99 -0
  16. package/adapters/codex/skills/flow-doctor/SKILL.md +254 -0
  17. package/adapters/codex/skills/flow-feat-build/SKILL.md +350 -0
  18. package/adapters/codex/skills/flow-feat-design/SKILL.md +399 -0
  19. package/adapters/codex/skills/flow-feat-plan/SKILL.md +165 -0
  20. package/adapters/codex/skills/flow-feat-review/SKILL.md +350 -0
  21. package/adapters/codex/skills/flow-feat-ship/SKILL.md +417 -0
  22. package/adapters/codex/skills/flow-feat-start/SKILL.md +289 -0
  23. package/adapters/codex/skills/flow-feat-validate/SKILL.md +216 -0
  24. package/adapters/codex/skills/flow-init/SKILL.md +153 -0
  25. package/adapters/codex/skills/flow-news/SKILL.md +57 -0
  26. package/adapters/codex/skills/flow-next/SKILL.md +55 -0
  27. package/adapters/codex/skills/flow-work-README/SKILL.md +247 -0
  28. package/adapters/codex/skills/flow-work-abandon/SKILL.md +103 -0
  29. package/adapters/codex/skills/flow-work-clean/SKILL.md +228 -0
  30. package/adapters/codex/skills/flow-work-daily/SKILL.md +114 -0
  31. package/adapters/codex/skills/flow-work-green/SKILL.md +162 -0
  32. package/adapters/codex/skills/flow-work-query/SKILL.md +169 -0
  33. package/adapters/codex/skills/flow-work-respond/SKILL.md +176 -0
  34. package/adapters/codex/skills/flow-work-resume/SKILL.md +123 -0
  35. package/adapters/codex/skills/flow-work-status/SKILL.md +127 -0
  36. package/adapters/codex/skills/flow-work-try/SKILL.md +94 -0
  37. package/adapters/codex/skills/flow-work-watch/SKILL.md +223 -0
  38. package/adapters/gemini/CORE.md +521 -0
  39. package/adapters/gemini/PRIMITIVES.md +117 -0
  40. package/adapters/gemini/README.md +149 -0
  41. package/adapters/gemini/commands/flow/bug/fix.toml +168 -0
  42. package/adapters/gemini/commands/flow/bug/investigate.toml +213 -0
  43. package/adapters/gemini/commands/flow/bug/postmortem.toml +95 -0
  44. package/adapters/gemini/commands/flow/bug/review.toml +187 -0
  45. package/adapters/gemini/commands/flow/bug/ship.toml +184 -0
  46. package/adapters/gemini/commands/flow/bug/start.toml +209 -0
  47. package/adapters/gemini/commands/flow/bug/validate.toml +96 -0
  48. package/adapters/gemini/commands/flow/doctor.toml +251 -0
  49. package/adapters/gemini/commands/flow/feat/build.toml +347 -0
  50. package/adapters/gemini/commands/flow/feat/design.toml +396 -0
  51. package/adapters/gemini/commands/flow/feat/plan.toml +162 -0
  52. package/adapters/gemini/commands/flow/feat/review.toml +347 -0
  53. package/adapters/gemini/commands/flow/feat/ship.toml +414 -0
  54. package/adapters/gemini/commands/flow/feat/start.toml +286 -0
  55. package/adapters/gemini/commands/flow/feat/validate.toml +213 -0
  56. package/adapters/gemini/commands/flow/init.toml +150 -0
  57. package/adapters/gemini/commands/flow/news.toml +54 -0
  58. package/adapters/gemini/commands/flow/next.toml +52 -0
  59. package/adapters/gemini/commands/flow/work/README.toml +244 -0
  60. package/adapters/gemini/commands/flow/work/abandon.toml +100 -0
  61. package/adapters/gemini/commands/flow/work/clean.toml +225 -0
  62. package/adapters/gemini/commands/flow/work/daily.toml +111 -0
  63. package/adapters/gemini/commands/flow/work/green.toml +159 -0
  64. package/adapters/gemini/commands/flow/work/query.toml +166 -0
  65. package/adapters/gemini/commands/flow/work/respond.toml +173 -0
  66. package/adapters/gemini/commands/flow/work/resume.toml +120 -0
  67. package/adapters/gemini/commands/flow/work/status.toml +124 -0
  68. package/adapters/gemini/commands/flow/work/try.toml +91 -0
  69. package/adapters/gemini/commands/flow/work/watch.toml +220 -0
  70. package/adapters/gemini/settings.snippet.json +11 -0
  71. package/adapters/hermes/CORE.md +522 -0
  72. package/adapters/hermes/PRIMITIVES.md +86 -0
  73. package/adapters/hermes/README.md +145 -0
  74. package/adapters/hermes/config.snippet.yaml +63 -0
  75. package/adapters/hermes/skills/flow-bug-fix/SKILL.md +171 -0
  76. package/adapters/hermes/skills/flow-bug-investigate/SKILL.md +216 -0
  77. package/adapters/hermes/skills/flow-bug-postmortem/SKILL.md +98 -0
  78. package/adapters/hermes/skills/flow-bug-review/SKILL.md +190 -0
  79. package/adapters/hermes/skills/flow-bug-ship/SKILL.md +187 -0
  80. package/adapters/hermes/skills/flow-bug-start/SKILL.md +212 -0
  81. package/adapters/hermes/skills/flow-bug-validate/SKILL.md +99 -0
  82. package/adapters/hermes/skills/flow-doctor/SKILL.md +254 -0
  83. package/adapters/hermes/skills/flow-feat-build/SKILL.md +350 -0
  84. package/adapters/hermes/skills/flow-feat-design/SKILL.md +399 -0
  85. package/adapters/hermes/skills/flow-feat-plan/SKILL.md +165 -0
  86. package/adapters/hermes/skills/flow-feat-review/SKILL.md +350 -0
  87. package/adapters/hermes/skills/flow-feat-ship/SKILL.md +417 -0
  88. package/adapters/hermes/skills/flow-feat-start/SKILL.md +289 -0
  89. package/adapters/hermes/skills/flow-feat-validate/SKILL.md +216 -0
  90. package/adapters/hermes/skills/flow-init/SKILL.md +153 -0
  91. package/adapters/hermes/skills/flow-news/SKILL.md +57 -0
  92. package/adapters/hermes/skills/flow-next/SKILL.md +55 -0
  93. package/adapters/hermes/skills/flow-work-README/SKILL.md +247 -0
  94. package/adapters/hermes/skills/flow-work-abandon/SKILL.md +103 -0
  95. package/adapters/hermes/skills/flow-work-clean/SKILL.md +228 -0
  96. package/adapters/hermes/skills/flow-work-daily/SKILL.md +114 -0
  97. package/adapters/hermes/skills/flow-work-green/SKILL.md +162 -0
  98. package/adapters/hermes/skills/flow-work-query/SKILL.md +169 -0
  99. package/adapters/hermes/skills/flow-work-respond/SKILL.md +176 -0
  100. package/adapters/hermes/skills/flow-work-resume/SKILL.md +123 -0
  101. package/adapters/hermes/skills/flow-work-status/SKILL.md +127 -0
  102. package/adapters/hermes/skills/flow-work-try/SKILL.md +94 -0
  103. package/adapters/hermes/skills/flow-work-watch/SKILL.md +223 -0
  104. package/adapters/install.sh +99 -0
  105. package/adapters/opencode/CORE.md +521 -0
  106. package/adapters/opencode/PRIMITIVES.md +118 -0
  107. package/adapters/opencode/README.md +113 -0
  108. package/adapters/opencode/commands/flow-bug-fix.md +169 -0
  109. package/adapters/opencode/commands/flow-bug-investigate.md +214 -0
  110. package/adapters/opencode/commands/flow-bug-postmortem.md +96 -0
  111. package/adapters/opencode/commands/flow-bug-review.md +188 -0
  112. package/adapters/opencode/commands/flow-bug-ship.md +185 -0
  113. package/adapters/opencode/commands/flow-bug-start.md +210 -0
  114. package/adapters/opencode/commands/flow-bug-validate.md +97 -0
  115. package/adapters/opencode/commands/flow-doctor.md +252 -0
  116. package/adapters/opencode/commands/flow-feat-build.md +348 -0
  117. package/adapters/opencode/commands/flow-feat-design.md +397 -0
  118. package/adapters/opencode/commands/flow-feat-plan.md +163 -0
  119. package/adapters/opencode/commands/flow-feat-review.md +348 -0
  120. package/adapters/opencode/commands/flow-feat-ship.md +415 -0
  121. package/adapters/opencode/commands/flow-feat-start.md +287 -0
  122. package/adapters/opencode/commands/flow-feat-validate.md +214 -0
  123. package/adapters/opencode/commands/flow-init.md +151 -0
  124. package/adapters/opencode/commands/flow-news.md +55 -0
  125. package/adapters/opencode/commands/flow-next.md +53 -0
  126. package/adapters/opencode/commands/flow-work-README.md +245 -0
  127. package/adapters/opencode/commands/flow-work-abandon.md +101 -0
  128. package/adapters/opencode/commands/flow-work-clean.md +226 -0
  129. package/adapters/opencode/commands/flow-work-daily.md +112 -0
  130. package/adapters/opencode/commands/flow-work-green.md +160 -0
  131. package/adapters/opencode/commands/flow-work-query.md +167 -0
  132. package/adapters/opencode/commands/flow-work-respond.md +174 -0
  133. package/adapters/opencode/commands/flow-work-resume.md +121 -0
  134. package/adapters/opencode/commands/flow-work-status.md +125 -0
  135. package/adapters/opencode/commands/flow-work-try.md +92 -0
  136. package/adapters/opencode/commands/flow-work-watch.md +221 -0
  137. package/adapters/opencode/opencode.json +8 -0
  138. package/bin/cli.mjs +222 -0
  139. package/package.json +43 -0
  140. package/plugins/flow/.claude-plugin/plugin.json +21 -0
  141. package/plugins/flow/CHANGELOG.md +1744 -0
  142. package/plugins/flow/examples/FLOW.template.md +324 -0
@@ -0,0 +1,350 @@
1
+ ---
2
+ name: flow-feat-build
3
+ description: "Implement the feature following the approved design and keep a running log"
4
+ ---
5
+
6
+ <!-- GENERATED by script/adapter-build.py from plugins/flow/commands/feat/build.md — do not edit; change the plugin file and run the script. -->
7
+
8
+ # `/flow-feat-build`
9
+
10
+ > **hermes adapter — how the Claude Code primitives named below map here.**
11
+ > - `AskUserQuestion` → ask in plain text with numbered options and wait for the reply.
12
+ > - `Agent <role>` / `Agent general-purpose` / subagents → `delegate_task`, which creates the child on the spot from the `goal` and `context` you give it: the name in `agents.<role>` in `FLOW.md` is a role to state in that prompt, not an agent to declare anywhere; empty → do it in this context.
13
+ > - Parallel fan-out → several `delegate_task` calls in one response, capped at `agents.fanout_max` (empty → 4) and, above that, by `delegation.max_concurrent_children` in `config.yaml` (default 10); `agents.fanout_tool` is Claude Code-only, ignore it.
14
+ > - `ScheduleWakeup` / `Monitor` / `/loop` → Hermes schedules itself: the `cronjob` tool, or `/cron add "every 30m" "<this command>"`. Each firing is a fresh session with no history, so the state still lives in `monitor.md` and the scheduled text must stand alone; retiring the job from inside a firing needs `cron.allow_agent_scheduling: true`.
15
+ > - `TaskCreate` → a markdown checklist in the phase artifact.
16
+ > - `Skill commit-commands:commit-push-pr` → `git add` · `git commit` · `git push -u origin HEAD` · the `git.cli` CLI (`gh pr create` / `glab mr create`).
17
+ > - `/model <value>` → Hermes's own `/model`; a subagent's model is `delegation.model` in `config.yaml`, one value for every child of a round.
18
+ > - `knowledge.*` roles → whatever tools `FLOW.md` names there; an MCP tool keeps its name, its server is declared under `mcp_servers` in `~/.hermes/config.yaml` (see `config.snippet.yaml`).
19
+ > - `$ARGUMENTS` → what the user typed after the skill name: Hermes takes everything from the first non-skill token on as the instruction.
20
+
21
+ Read `~/.claude/flow/CORE.hermes.md` first (shared rules: `FLOW.md` step 0, models, autonomy modes and hard gates, how a stop reads, `panel.json`, `00-summary.md`) — skip if you already read it in this session. **Models: the subagents it launches take `models.agents`.**
22
+
23
+ Implementation phase. Code is written here.
24
+
25
+ ## 1. Pre-flight
26
+
27
+ - Load `meta.json` by current branch. Read `meta.json` and `00-summary.md`; open in full only `03-design.md` (§"External contracts", verbatim) and the current MR/PR entry of `04-mr-plan.md`. (flow-core §5)
28
+ - `size` M/L: require both `03-design.md` **and** `04-mr-plan.md`. Plan missing → send to `/flow-feat-plan`; design missing → send to `/flow-feat-design`.
29
+ - `size` XS/S: may start without a design — ask the user for a 2-3 line note on what will be done and save it as a minimal `03-design.md`. No MR/PR plan (always 1 MR/PR).
30
+ - **If `meta.json.mrs` has more than one entry**: pick the **startable** MR/PR — the `pending` one with the **lowest `n` whose `depends_on` are all `merged`**. Dependencies still `pending`/`in_progress` → not startable, even with a low `n`. (No `wave`/`depends_on` — an older plan — → "first pending by `n`".)
31
+ - **Parallel siblings**: startable `pending` MRs/PRs in the **same `wave`** with no dependency between them can be built in parallel or as a train. `manual`: let the user choose which to take now (default: lowest `n`); `guided`/`auto`: take the lowest `n`, record the choice. Mark the chosen one `in_progress`.
32
+ - All `merged` → warn: feature is done, nothing to build.
33
+ - Some `pending` but **none** startable → start nothing: tell the user which MR/PR must merge to unlock the next wave, and stop.
34
+ - **Train/stacked**: this MR/PR needs its own branch stacked on the previous one — do **not** keep committing on the previous MR/PR's branch. `/flow-feat-ship §6.2` creates and links it when it chains here; if you arrived directly and are still on the previous branch, create it now per `/flow-feat-start §5` (explicit base = the previous MR/PR's branch, `--no-track`, worktree per `git.worktree`) and, for `tracker.tool: gh`, the linked-branch step `/flow-feat-start §5.5`. Record `stacked_on` in `meta.json`. The train does **not** wait for the previous MR/PR to merge.
35
+
36
+ ## 2. Business brief (before typing)
37
+
38
+ **Before loading skills, creating tasks, or any edits**, write a brief in **business** language (not technical) specific to **this concrete MR/PR** (the `in_progress` one in `meta.json.mrs`, not the full feature):
39
+
40
+ ```
41
+ Brief MR/PR #N: <title>
42
+
43
+ After this MR/PR:
44
+ - The user will be able to <X>.
45
+ - The system <will do Y / will stop doing Z>.
46
+ - <success metric if applicable>.
47
+
48
+ This MR/PR does NOT include:
49
+ - <piece Y that belongs to MR/PR #N+1>.
50
+ - <related functionality decided against>.
51
+ - <tempting scope that is out>.
52
+ ```
53
+
54
+ Rules for writing it:
55
+ - **Business language**: "the user will be able to filter campaigns by date", not "create the endpoint `GET /campaigns?from=...`".
56
+ - **Specific to this MR/PR**: with 4 MRs/PRs, the brief covers only what this one contributes — not the full feature.
57
+ - **"Does NOT include" is mandatory**, even if it seems redundant with `04-mr-plan.md`. If you do not know what to put, the plan is wrong.
58
+ - 3-5 bullets in each list.
59
+
60
+ **Ask the user with `AskUserQuestion`** whether the brief reflects what they expect — **hard gate, in every autonomy mode, `auto` included**: it is the last point where scope can be corrected before there is a diff to argue with.
61
+
62
+ In `guided`/`auto` this is one of the only two stops per MR/PR, so it carries the **full stop header** (flow-core §3) — ticket, size, phase, `MR #<n> of <N>`, plan state — followed by the brief. Options:
63
+ - **Yes, proceed** → start building.
64
+ - **No, something is extra or missing** → the user clarifies, adjust the brief, ask again. **Do not touch code** until the brief is confirmed.
65
+
66
+ Save the brief at the top of `05-implementation.md` under "## Brief MR/PR #N". It is the contract for the rest of the build: anything not in the brief goes through §2.4 before it is done.
67
+
68
+ ## 2.0bis Copy design contracts (verbatim, do not paraphrase)
69
+
70
+ **Before writing code**, open `03-design.md` and locate the **"External contracts"** section. For **each contract** declared there (HTTP body, header, route, event, column, metric), **copy it literally** into `05-implementation.md` under a new section:
71
+
72
+ ```markdown
73
+ ## Contracts to respect (copied verbatim from 03-design.md §"External contracts")
74
+
75
+ ### Contract N: <description>
76
+ - **Literal shape**:
77
+ <BLOCK COPIED AS-IS, no rewriting, no paraphrasing, no "I think it was like this">
78
+ - **Pattern deviation** (if applicable): <copied from design>
79
+ ```
80
+
81
+ Hard rules:
82
+ - **Copy, do not rewrite.** The contract must live in the file you are writing, so it wins when a repo pattern tempts you away from it.
83
+ - **If the design wrote the contract in prose** (no literal shape), convert it to literal format here and note it in the user report: "contract N was in prose in the design, I have converted it to literal — please confirm it is correct". Do not advance until confirmed.
84
+ - **If there is a "Pattern deviation" section**: copy it too — it reminds you at coding time not to mimic the repo pattern.
85
+ - **If the design says "none"** (no external surfaces), skip this step and record: "## Contracts to respect — none declared in design".
86
+
87
+ Without this copy, do not proceed to §2.1.
88
+
89
+ ## 2.1 Work
90
+
91
+ Apply the repo's `conventions` from `FLOW.md` (free text: layers, patterns, prohibitions) as written. Load project skills that encode them if the harness exposes any; otherwise the `conventions` text is the whole instruction.
92
+
93
+ **Comment discipline.** Comment only for a *why* the code cannot state (non-obvious constraint, workaround and its reason, subtle invariant). Do not narrate *what* the code does or restate the design; match the file's comment density. **Never write the ticket ID, task/step number, or "for MR #N" into a code comment** — traceability lives in the commit, branch and MR/PR.
94
+
95
+ **Borrowed code carries its reason.** When you lift a structure from another file (a `catch` block, guard clause, mapper, config stanza, test setup), record under "Decisions made during implementation" in `05-implementation.md` where it came from and **what makes it apply here** (the exception is actually thrown on this path, the guard's precondition can actually be false here, the mapped field exists on this shape). No nameable reason → do not copy it; write what this code needs or leave it out. Same anti-drift rule as §2.0bis, applied to code.
96
+
97
+ **A query is written against the schema, not against the mapping.** Before any data-access query (raw SQL, ORM query, query-builder chain, repository finder, aggregate, bulk write) counts as done, check:
98
+ - the index serving its filter *and* its order **in that direction** exists — read the schema, not the entity mapping;
99
+ - the bound is real; "the latest k per key" is not a global limit;
100
+ - both key columns of every join share type, length and charset/collation;
101
+ - no heavy column is read in a pass that only decides which rows survive.
102
+
103
+ Take the shape from the **Access paths** table in `03-design.md`; a query matching no row there is a design deviation to log. `data.explain_cmd` set in `FLOW.md` → get the plan now and paste it under "Access paths implemented" in `05-implementation.md` (spares `/flow-feat-review §3.6` the round trip); not set → say the plan is unverified. Do **not** invent an index or a collation change to make a query work: that is a schema change, a hard gate, back through the design.
104
+
105
+ **Multi-MR/PR build**: only what the current MR/PR covers per `04-mr-plan.md`. Code for a later MR/PR is scope creep: cut it or isolate it behind a feature flag / dead code temporarily per the plan; if it cannot be isolated, pause and return to `/flow-feat-plan` to cut it.
106
+
107
+ Execution mode:
108
+
109
+ - **Single-thread (XS/S/M)**: implement yourself, step by step; subagents only as point consultants when blocked — `agents.architecture` from `FLOW.md` for layer questions, `agents.persistence` for query/mapping questions (`Agent general-purpose` if either is empty).
110
+ - **Partial delegation (M/L with clear pieces)**: `Agent` for isolated endpoints, plus `agents.testing` from `FLOW.md` in parallel to prepare the test suite (`Agent general-purpose` if empty). Pass the full `03-design.md` in the prompt so agents do not invent things.
111
+
112
+ A brief here states the **output** as explicitly as the input (flow-core §6):
113
+ - **Name the path the agent writes**, and require it to **save after each finished piece, not at the end**. Code, tests and generated content are the deliverable; the report is not. Then **verify the file** instead of believing the report — a piece half-written on disk is recoverable, what only exists in the agent's context is lost the moment it is stopped.
114
+ - **End the brief with the report contract** — under `agents.report_max_words` (empty → 250): what it wrote, where, what it could not do. A report long enough for the harness to truncate reaches you as silence.
115
+ - **Give it a bounded first step.** A piece with no natural first move ("do the whole module") produces nothing for hours; split it by file or by numbered step until it has one.
116
+ - **Check the round at every stop of this command**, not only at the end: an agent past `agents.stall_after_minutes` (empty → 25) with nothing written to its path is stopped, split in two and relaunched.
117
+
118
+ Use `TaskCreate` to track the steps from the design's implementation plan. Mark each step `in_progress` when starting and `completed` when done — do not batch.
119
+
120
+ ### 2.1bis The premise this change rests on (any size, XS included)
121
+
122
+ `/flow-feat-design §6` challenges the beliefs a plan rests on — and XS never runs `design`. On a
123
+ small change, nobody contrasts the premise: `/flow-feat-review §6` will not, because it refutes
124
+ findings that were already reported and its gate needs M/L plus a diff over 150 lines. The
125
+ cheapness of the change is what closes every gate flow has, and a belief does not get safer because
126
+ the diff around it is short. Like the data-access duel (`/flow-feat-review §3.6`), this is a
127
+ **category, not a depth tier**.
128
+
129
+ **When it runs.** A premise qualifies only when all four hold:
130
+
131
+ - the implementation **depends** on it — take the belief away and the code is wrong, not merely unproven;
132
+ - it is about **code outside this diff**, a runtime behaviour, or an external contract;
133
+ - **nothing in the diff, `03-design.md` or `01-context.md` verifies it** — no test, no constraint, no plan;
134
+ - being wrong costs **data, money, a silent wrong result, or a security hole** — not a retry, a log line or a loud failure.
135
+
136
+ Fewer than four → it is a doubt, not a premise, and doubts do not get an agent: write it under
137
+ "Premises the change depends on" in §3 as the assumption it is and move on. **Once per MR/PR**: the
138
+ first qualifying premise gets the round, and a second one is recorded with what it would take to
139
+ settle it.
140
+
141
+ **How it runs.** One `Agent general-purpose`, read-only, refute-by-default, launched **before the
142
+ code that depends on the premise is finished** — a premise contested after the fact is a rewrite:
143
+
144
+ > You are a skeptic. The implementation of `<TICKET>` depends on this premise: `<premise, one sentence>`. It rests on `<file / system / contract>`, outside the diff under way. Try to REFUTE it: read the real code, schema, contract or test that would settle it, and answer FALSE (refuted), TRUE (holds — with what you read), or UNSETTLED (with what would settle it). The burden of proof is on the premise: do not argue from what is likely, and do not propose implementation. Report the premise, the evidence for and against, and what happens to the caller if it is false. Under `agents.report_max_words` words (empty → 250).
145
+
146
+ **Budget, and the autonomy rule.** It counts against `agents.budget_max` like any other round
147
+ (flow-core §6) and is **the first round this command gives up** when the budget cannot cover it —
148
+ said in one line, never silently skipped. `manual` → offer it with `AskUserQuestion` ("Challenge the
149
+ premise that X before building on it?"). `guided`/`auto` → run it and record it; it is flow
150
+ machinery, not a decision.
151
+
152
+ **The verdict, and the rule that makes it worth running.** **Refuted** → the brief or the design is
153
+ wrong, not the code: stop, say what fell, and go back (§2.4 for a brief, `/flow-feat-design` for a
154
+ contract) rather than patching around it. **Holds** → one row in §3 with what was read. **Unsettled
155
+ stays unsettled** — the same rule as the query duel's *no number, no win*: it is recorded as an open
156
+ premise, carried into the stop, and never promoted to an assumption by prose. `review` reads
157
+ `05-implementation.md` in full, so an open premise arrives there named instead of as a surprise.
158
+
159
+ ### 2.2 Checkpoints (local commits, gated by `autonomy.mode`)
160
+
161
+ The step's changes are **always reported before anything is recorded**. Who decides the commit depends on `autonomy.mode`:
162
+
163
+ - **`manual`** — the agent **does not run `git commit` on its own**. Commits are **opt-in from the user**: without explicit confirmation, changes stay in the working tree for the user to validate first.
164
+ - **`guided`** — ask **once**, at the first step; apply the answer to the rest of this build and record it in `05-implementation.md`. Do not re-ask per step.
165
+ - **`auto`** — commit the step's WIP yourself and continue. **Invoking a flow command with `autonomy.mode: auto` is the explicit authorization** the system rule (*never commit unless the user asks*) requires. It authorizes **only** WIP commits on the work branch: push and MR/PR creation remain hard gates in every mode.
166
+
167
+ **After completing each `TaskCreate` step**:
168
+
169
+ 1. **Mark the step `completed`** in `TaskCreate`.
170
+ 2. **Report to the user** a step summary (≤ 5 lines):
171
+ ```
172
+ Step N done: <description>
173
+ Files: <short list>
174
+ Diff: +<add> / -<del> lines
175
+ Suggested validation: <e.g. "run the unit test command for Foo" or "open the UI at /section">
176
+ ```
177
+ 3. **Then, per mode**: `guided`/`auto` → run `git add <files from step> && git commit -m "WIP <TICKET>: <step>" --no-verify` and start the next step without pausing — **the step summary is a report, not a question**; never append "shall I commit and move on?" (never-ask list, flow-core §2). `manual` → **do not commit**; wait for the user:
178
+ - **"Commit now"** / **"OK, continue"** → run the same `git add … && git commit …`, continue with the next step.
179
+ - **"Wait, I'll validate"** → stay still until the user returns and decides commit or adjustment.
180
+ - **"Something needs to change"** → adjust; the step's commit stays pending until OK.
181
+ - **"Continue without committing, we'll group later"** → next step without committing; changes accumulate in the working tree (fewer clean points if §2.3 cuts).
182
+
183
+ Rules when a commit does happen:
184
+ - One commit per step. Do not batch steps unless the user explicitly requests it.
185
+ - `--no-verify` **only for WIP commits** (slow hooks run in `/flow-feat-review` and in the final commit of `/flow-feat-ship`).
186
+ - WIP commits are squashed on merge when `git.squash` is `true`; they only need to be cuttable units.
187
+ - A step left halfway (interruption, change of focus) that gets committed: `WIP <TICKET>: <step> (partial)`.
188
+
189
+ In `manual`, not committing until the end loses the §2.3 cut granularity — the user's decision, not the agent's. The branch is never pushed without the §6 gate in `/flow-feat-ship`.
190
+
191
+ ### 2.3 Size thermometer and hot cut
192
+
193
+ **After each completed step** (whether committed or not), compare the real size against the estimate for the current MR/PR in `meta.json.mrs`. Check commits + staged + unstaged, not just commits:
194
+
195
+ ```bash
196
+ # Committed changes over the base branch:
197
+ git diff --shortstat <git.default_base>..HEAD # lines
198
+ git diff --name-only <git.default_base>..HEAD | wc -l # files
199
+
200
+ # Working tree changes (uncommitted):
201
+ git diff --shortstat HEAD # uncommitted lines
202
+ git status --short | wc -l # modified/untracked files
203
+ ```
204
+
205
+ Sum both sides to get the real total size of the current MR/PR.
206
+
207
+ Warning thresholds:
208
+ - **Real lines > `lines_est * 1.5`**, or
209
+ - **Real files > `files_est + 2`**.
210
+
211
+ If either is exceeded, **pause** and ask the user with `AskUserQuestion` (options, in this order):
212
+
213
+ 1. **Cut here (recommended if the current piece is coherent)**. What is built so far stays as this MR/PR; what remains of the plan goes into a new one inserted in `meta.json.mrs` right after. Zero code wasted.
214
+ 2. **Continue and record the overrun**. When the cut would be artificial. Note the deviation in `05-implementation.md` to calibrate `/flow-feat-plan` on future tickets.
215
+ 3. **Reopen plan**. Return to `/flow-feat-plan` to rethink the entire split. Only if the overrun shows the plan is wrong at a deeper level, not just that this MR/PR is slightly underestimated.
216
+
217
+ **None of the three is "make the diff smaller"** (flow-core §9). The estimate is a thermometer: an
218
+ overrun is answered by cutting at a coherent point or by recording it, never by deleting comments,
219
+ tests or blank lines, compressing readable code, or cutting mid-change to land under the number. The
220
+ same holds downhill — `/flow-feat-review §2.0` scales the review to the diff, so a diff trimmed to
221
+ slip under a threshold buys itself the review a smaller change had earned.
222
+
223
+ **Hot cut mechanics (option 1)**:
224
+
225
+ 0. **If there are uncommitted changes** in the working tree: warn the user and ask them to decide before cutting — commit what is done as a WIP for the corresponding step, or stash it (`git stash`) so it does not mix with the next MR/PR.
226
+ 1. Identify a cut point: the last WIP commit where the piece is coherent and mergeable (a closed sub-goal: "endpoint and DTO done", "migration applied", "flow X tests green"). Do not cut in the middle of a change.
227
+ 2. Edit `meta.json.mrs`:
228
+ - The current MR/PR keeps `n`, `title`, `wave` and `depends_on`, adjusts `lines_est` and `files_est` to actuals, and stays `in_progress`.
229
+ - Insert a new one with the next `n` (renumbering subsequent ones if any), `title` describing what remains, `status: "pending"`, `phases_done: []` (a fresh MR/PR earns its own review/validate), `depends_on: [n_current]`, `wave` = one after the current one, and new indicative `lines_est` and `files_est`. If you renumber subsequent entries, **update their `depends_on` references accordingly** so no `depends_on` points to a higher `n` than its own.
230
+ 3. Edit `04-mr-plan.md`: split the original entry in two, keeping the standalone-mergeable justification for both halves.
231
+ 4. Note in `05-implementation.md` under "Hot cut": date, reason, what stays and what moves to the next one.
232
+ 5. **Do not rewrite history with `git rebase`**: WIP commits belonging to the next MR/PR stay in the current branch. When building the next one, start from a new branch over the base and transfer them with `git cherry-pick` or equivalent — executed in `/flow-feat-ship` or when starting the next `/flow-feat-build`.
233
+
234
+ **If there was already a cut and overrun happens again**: ask the user before cutting again — a second cut on the same MR/PR signals the plan is wrong. The right option is probably **3 (reopen plan)**.
235
+
236
+ ### 2.4 Does something fall outside the brief?
237
+
238
+ If during the build the temptation arises to add something **not in the §2 brief** ("while I'm here…", "this test would also cover X…", "this rename would improve Y…"), **pause before doing it** and ask the user with `AskUserQuestion`:
239
+ - **Yes, add it to the brief** — update the brief in `05-implementation.md` and continue. (If the addition is large, consider §2.3: it could trigger a MR/PR cut.)
240
+ - **No, leave it out** — note it in the "Ideas for separate tickets" section of `05-implementation.md` **and append it to `meta.json.followups[]`** as `kind: "out-of-scope"`, `source: "build"` (flow-core §7): the section keeps it in context, the record is what survives the archive. **Only when it clears the bar of flow-core §7** — a named subject, a path that has actually been seen, and waiting costing more than doing it now; short of that the artifact section keeps it and `followups[]` never sees it. Continue with the original brief.
241
+
242
+ Anything unforeseen **always** goes through the user before entering code.
243
+
244
+ A correction the user makes here — *«not a listener, a message handler»*, *«never mock the repository in that layer»* — is a **convention** when it would apply to an unrelated ticket in this repo: one row in `meta.json.conventions_candidates[]` and under `## Conventions learned` in `05-implementation.md`, nothing asked (flow-core §8). `ship` offers it to `FLOW.md` once, at the end.
245
+
246
+ A **product decision** the build turns out to need is neither option — not scope to add, not work to park: ask it the moment it surfaces, in every mode, and write the answer under "Decisions made during implementation" (flow-core §7, `decision`). Only a decision the user explicitly defers becomes a `followups[]` entry. A gap in the repo's own machinery (a guard that did not bind, a floor with slack) is `kind: "tooling"`, headed for the debt log rather than the tracker.
247
+
248
+ ## 3. Log
249
+
250
+ Keep `.claude/work/<TICKET>/05-implementation.md` updated as you work (not at the end). Structure:
251
+
252
+ ```markdown
253
+ # Implementation <TICKET>
254
+
255
+ ## Brief MR/PR #N
256
+ <3-5 bullets of what the user will be able to do after this MR/PR, in business language>
257
+
258
+ **This MR/PR does NOT include**:
259
+ - <pieces that are out of scope>
260
+
261
+ ## Changes per file
262
+ - <file> — what changed and why (1 line each)
263
+
264
+ ## Decisions made during implementation
265
+ - Decision: …
266
+ - Why: …
267
+ - Discarded alternative: …
268
+
269
+ ## Premises the change depends on
270
+ <one row per premise put through §2.1bis, plus any belief recorded as an assumption without a round. Omit the section when the change depends on nothing outside its own diff — most builds.>
271
+
272
+ | Premise | Rests on | Verdict | Evidence, or what would settle it |
273
+ |---|---|---|---|
274
+ | the upstream normalises the address before it reaches us | `InboundMailer`, outside the diff | unsettled | no test covers the unnormalised path; needs one run against prod-shaped data |
275
+
276
+ ## Access paths implemented
277
+ <one row per query written or changed; omit the section if none. `Plan` is what `data.explain_cmd` returned, or "unverified" when the repo has no way to get one — never a guess.>
278
+
279
+ | Query (file:line) | Filter · order (direction) · bound | Index it uses | Plan |
280
+ |---|---|---|---|
281
+ | `FooRepository::findBar()` | `a IN (…)` · `b DESC` · 15 per key | `barIdx (a,b)` | backward index scan, 750 rows read |
282
+
283
+ ## Deviations from design
284
+ - Design said X → did Y because Z
285
+
286
+ ## Relevant commands executed
287
+ - <quality.style_fix from FLOW.md>
288
+ - <quality.db_update from FLOW.md>
289
+ - …
290
+
291
+ ## Pending
292
+ - [ ] …
293
+
294
+ ## Conventions learned
295
+ <rules the user taught here that would apply to any ticket in this repo, `C<n>` + the line in their own words + the stop it came from. Also `meta.json.conventions_candidates[]` (flow-core §8). Nothing is asked; `ship` offers them to `FLOW.md` once, at Close. Empty for most builds — a correction about this ticket is not a convention.>
296
+
297
+ ## Ideas for separate tickets
298
+ <things that came up during the build and were decided NOT to include; each with one line: `F<n>` + "what" + "why it makes sense as its own ticket". Each row is also a `meta.json.followups[]` entry (`kind: "out-of-scope"`, `source: "build"`) — flow-core §7, and only for what clears its bar: an unpretty-but-correct shape, a coupling with no symptom or a state that is not trimmed belongs in this section and nowhere else. Nothing is asked here; `ship` puts the survivors of one skeptic round to the user, once, at the end.>
299
+ ```
300
+
301
+ ## 4. Quality during implementation
302
+
303
+ As larger pieces are completed:
304
+
305
+ - Run `quality.style_fix` from `FLOW.md` to fix style; if empty, auto-discover (Makefile, npm scripts, Gradle, dotnet, Xcode, Flutter…).
306
+ - Run `quality.static_analysis` from `FLOW.md` when a piece is stable; if empty, auto-discover.
307
+ - If tests were added, run them individually with `quality.test_one` from `FLOW.md` (substituting `{FILTER}`); if empty, auto-discover. **A filtered run is judged by how many tests it executed, never by its exit code** — most runners exit `0` when the filter matches nothing (`OK, 0 tests`, `No tests ran`, `no tests to run`, `0 passed`). Read the executed count **and** test names: count `0`, or your new tests missing from the names → **the run did not happen**; treat as failure, fix the filter, run again. No count reported → drop the filter and run the whole test file. In "Relevant commands executed", record the count you saw, not just the command — "green" without a number is not evidence.
308
+
309
+ Do not do code review here — that is `/flow-feat-review`.
310
+
311
+ ## 4.1 Is the design still valid?
312
+
313
+ Review the "Deviations from design" section of `05-implementation.md`. If **any** of the following applies:
314
+
315
+ - **2+ significant deviations** (module change, different event contract, different entity, unforeseen new repository).
316
+ - **1 deviation that invalidates a decision** from the ADR-light in `03-design.md`.
317
+ - **A design piece appears that the prior inventory did not detect** and that changes the plan.
318
+ - **A primitive materialized with a different name/role than the design named it** (design said *Query*, code built a *Command*; design said *service*, code built a *handler* wired through a bus) — **vocabulary drift**: fix the design's naming (update `03-design.md`) or fix the code, now. `/flow-feat-review §5.5` and the reader judge the code, not the design's intent.
319
+
320
+ **Pause the build and return to `/flow-feat-design`** to update the document (and to `/flow-feat-plan` if it affects splitting). Do not keep implementing against a design that is no longer true — `/flow-feat-review` and `/flow-feat-validate` read `03-design.md` as truth.
321
+
322
+ Minor deviations (renames, local adjustments): note them and continue.
323
+
324
+ ## 4.2 Textual contract check (before closing)
325
+
326
+ If §2.0bis copied contracts into `05-implementation.md`, **before marking the build as done** compare the code against each cited contract. **This is not a test to run** — it is a deliberate textual comparison you make as the agent, not delegated to the test runner.
327
+
328
+ For each contract in "Contracts to respect":
329
+
330
+ 1. Locate in the code the construction of the shape (the controller array, the event constructor, the column migration, the metrics client call, etc.).
331
+ 2. Dump the **keys and nesting** that code produces (or the literal it emits, in the case of a header/route).
332
+ 3. Compare **key by key, character by character** against the literal quote copied in §2.0bis.
333
+ 4. If anything differs — a key in camelCase vs snake_case, a different nesting level, an extra or missing key, a singular vs plural suffix — **go back and edit the code** to match. Do not advance to close with a mismatch.
334
+
335
+ Record the result in `05-implementation.md` under "## Contract verification":
336
+
337
+ ```markdown
338
+ ## Contract verification (§4.2)
339
+ - Contract N "<description>": code produces <actual shape>, declaration states <declared shape>. ✅ matches / ❌ adjusted in commit X.
340
+ ```
341
+
342
+ If there were no copied contracts (design said "none"), skip this step and record: "## Contract verification — N/A (no external contracts)".
343
+
344
+ ## 5. Close
345
+
346
+ - Update `meta.json`: `phase = "build"`, add to `phases_done`.
347
+ - Multi-MR/PR build: leave the current MR/PR `in_progress` in `meta.json.mrs` (it becomes `merged` when `/flow-feat-ship` confirms the merge). **Also add `build` to that MR/PR's own `phases_done`** (its `mrs[]` entry) — the per-MR/PR marker the downstream gates read.
348
+ - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5).
349
+ - Report **following the stop header** (flow-core §3), then in bullets: files touched (high level), pending items, **result of §4.2 (contracts verified)**, and **any premise left unsettled by §2.1bis** — one line, in the language of what breaks if it is false. An open premise the user never hears about is an assumption they were not asked about. Next command: `/flow-feat-review` — in `guided`/`auto` say so in the `I need:` line ("nothing, chaining into review"), never as a question.
350
+ - **Autonomy handoff.** The summary is a report, not the end of the flow. `manual`: stop and propose `/flow-feat-review` with a single `AskUserQuestion` (recommended option by default); invoke it only on confirmation, never make the user type it. `guided`/`auto`: **chain into `/flow-feat-review` automatically** in this same turn, without asking — never end the turn with the next command as a suggestion.