flow-workflows 0.105.0 → 0.107.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 (43) hide show
  1. package/adapters/codex/CORE.md +81 -8
  2. package/adapters/codex/skills/flow-bug-investigate/SKILL.md +1 -1
  3. package/adapters/codex/skills/flow-bug-postmortem/SKILL.md +1 -1
  4. package/adapters/codex/skills/flow-bug-ship/SKILL.md +13 -5
  5. package/adapters/codex/skills/flow-bug-validate/SKILL.md +1 -1
  6. package/adapters/codex/skills/flow-feat-build/SKILL.md +6 -3
  7. package/adapters/codex/skills/flow-feat-ship/SKILL.md +41 -19
  8. package/adapters/codex/skills/flow-feat-validate/SKILL.md +5 -2
  9. package/adapters/codex/skills/flow-work-green/SKILL.md +11 -7
  10. package/adapters/codex/skills/flow-work-respond/SKILL.md +6 -1
  11. package/adapters/gemini/CORE.md +81 -8
  12. package/adapters/gemini/commands/flow/bug/investigate.toml +1 -1
  13. package/adapters/gemini/commands/flow/bug/postmortem.toml +1 -1
  14. package/adapters/gemini/commands/flow/bug/ship.toml +13 -5
  15. package/adapters/gemini/commands/flow/bug/validate.toml +1 -1
  16. package/adapters/gemini/commands/flow/feat/build.toml +6 -3
  17. package/adapters/gemini/commands/flow/feat/ship.toml +41 -19
  18. package/adapters/gemini/commands/flow/feat/validate.toml +5 -2
  19. package/adapters/gemini/commands/flow/work/green.toml +11 -7
  20. package/adapters/gemini/commands/flow/work/respond.toml +6 -1
  21. package/adapters/hermes/CORE.md +81 -8
  22. package/adapters/hermes/skills/flow-bug-investigate/SKILL.md +1 -1
  23. package/adapters/hermes/skills/flow-bug-postmortem/SKILL.md +1 -1
  24. package/adapters/hermes/skills/flow-bug-ship/SKILL.md +13 -5
  25. package/adapters/hermes/skills/flow-bug-validate/SKILL.md +1 -1
  26. package/adapters/hermes/skills/flow-feat-build/SKILL.md +6 -3
  27. package/adapters/hermes/skills/flow-feat-ship/SKILL.md +41 -19
  28. package/adapters/hermes/skills/flow-feat-validate/SKILL.md +5 -2
  29. package/adapters/hermes/skills/flow-work-green/SKILL.md +11 -7
  30. package/adapters/hermes/skills/flow-work-respond/SKILL.md +6 -1
  31. package/adapters/opencode/CORE.md +81 -8
  32. package/adapters/opencode/commands/flow-bug-investigate.md +1 -1
  33. package/adapters/opencode/commands/flow-bug-postmortem.md +1 -1
  34. package/adapters/opencode/commands/flow-bug-ship.md +13 -5
  35. package/adapters/opencode/commands/flow-bug-validate.md +1 -1
  36. package/adapters/opencode/commands/flow-feat-build.md +6 -3
  37. package/adapters/opencode/commands/flow-feat-ship.md +41 -19
  38. package/adapters/opencode/commands/flow-feat-validate.md +5 -2
  39. package/adapters/opencode/commands/flow-work-green.md +11 -7
  40. package/adapters/opencode/commands/flow-work-respond.md +6 -1
  41. package/package.json +1 -1
  42. package/plugins/flow/.claude-plugin/plugin.json +1 -1
  43. package/plugins/flow/CHANGELOG.md +40 -0
@@ -16,7 +16,7 @@ Every `/flow-*` command assumes these rules. They are stated once, here, so a co
16
16
  carries what is specific to its phase. Read this once per session; a command that says "load
17
17
  `flow-core`" means this file.
18
18
 
19
- **This file belongs to flow `0.105.0`.** Compare it once, at the start of the session, against
19
+ **This file belongs to flow `0.107.0`.** Compare it once, at the start of the session, against
20
20
  `version` in `~/.claude/flow/.claude-plugin/plugin.json`. The two differing means the session
21
21
  is running a **mixture** — the commands from one copy of the plugin, these shared rules from another
22
22
  — which is exactly what happens when a branch or a release candidate is loaded over an installed
@@ -155,8 +155,9 @@ a command relies on is simply absent in that session, and nothing else will repo
155
155
  artifact only; no `read_staging` → the artifacts are the staging; no `save` →
156
156
  the consolidation appends to `KNOWLEDGE.md` at the repo root. Per-call timeout
157
157
  `knowledge.timeout_s` (empty = 2 s); a failure or timeout → continue without it, silently.
158
- **How a consolidation runs** (`ship`, `postmortem`, `abandon`, and the offer in `/flow-work-daily`
159
- when `read_staging` has entries). No role set at all → say so in one line and stop:
158
+ **How a consolidation runs** (`ship` — before its commit, so the findings travel in the work's own
159
+ MR/PR —, `postmortem`, `abandon`, and the offer in `/flow-work-daily` when `read_staging` has
160
+ entries). No role set at all → say so in one line and stop:
160
161
 
161
162
  1. **Read the staging** for this branch with `knowledge.read_staging`; the role empty → the "why"
162
163
  findings already written in this work's artifacts (`03-design.md` ADR-light and challenges,
@@ -173,12 +174,34 @@ when `read_staging` has entries). No role set at all → say so in one line and
173
174
  `## <topic>` heading — the finding, its evidence line, the date and the branch. Creating that file
174
175
  the first time edits the tree, so it is asked once, in every mode; appending to an existing one is
175
176
  recorded, not asked.
176
- 4. **Report** in one line: *"Created N · Updated M · Conflicts resolved J"*, or *"Appended N
177
- finding(s) to KNOWLEDGE.md"*.
178
- 5. **Clear the staging** for the branch afterwards, when the store has that notion.
177
+ 4. **Land the writes in the work's tree** — only with `meta.json.worktree` set, and only for a work
178
+ that will still ship its branch (`ship`, `postmortem`, the `daily` offer; never `abandon`, whose
179
+ worktree is about to go). A `knowledge.save` tool is started once per session, resolves the repo
180
+ from the directory it started in and takes no root in its call, so what it writes lands in the
181
+ **main checkout**, standing on another branch; flow is the only party that knows a worktree
182
+ exists, so flow moves it. Before the first `save`, read the main checkout's
183
+ `git -C <main checkout> status --porcelain` and keep it. After the last one, the files written
184
+ are what each result names (a `file_written`, a path) or, where it names none, the paths new in
185
+ that status since the snapshot — never a path that was already there. Copy each one to the same
186
+ relative path in the worktree, then take it out of the main checkout: delete an untracked file,
187
+ `git -C <main checkout> checkout -- <path>` a tracked one. A path that already differs in the
188
+ worktree is not overwritten: ask (`AskUserQuestion`). Record the paths in
189
+ `meta.json.knowledge.files`; they ride the work's next commit like any change (a `ship` puts them
190
+ in its own commit), and the main checkout is left as it was found.
191
+ 5. **Report** in one line: *"Created N · Updated M · Conflicts resolved J"*, or *"Appended N
192
+ finding(s) to KNOWLEDGE.md"* — plus, after step 4, *"moved to the branch: <paths>"*.
193
+ 6. **Record the outcome** in `meta.json.knowledge`: `{ "status": "consolidated" | "declined" |
194
+ "later" | "failed" | "nothing", "phase": "<phase>", "files": [...] }`. Every consolidation point
195
+ writes it, an offer turned down included: it is how `ship` knows whether the work's knowledge is
196
+ still owed (`/flow-feat-ship` §2, *Domain knowledge*), and a decision that lives only in the
197
+ conversation is lost with it.
198
+ 7. **Clear the staging** for the branch, when the store has that notion: after a consolidation that
199
+ saved, and in any case once the work reaches `phase = "done"` (`ship`'s Close) — a draft left
200
+ in staging after its findings shipped is offered again by `daily` as if nothing had been saved.
179
201
 
180
202
  A tool call that fails is **reported, never swallowed** — this is the one knowledge path that is
181
- explicit rather than degrading in silence.
203
+ explicit rather than degrading in silence. It records `failed` (step 6), and the work ships without
204
+ those files rather than not shipping.
182
205
 
183
206
  - `notes.<command>` (or `notes.all`) → mandatory extra instructions for that command.
184
207
  - Key names, merge rules, and defaults: the template shipped with the plugin
@@ -425,7 +448,7 @@ person asking for changes, a ticket that already has code — is `/flow-work-run
425
448
  | Writing a DB schema change, index or migration — in any phase, a review's own fixes included — or applying one (`validate`) | question `migration`, before the first line of it is written or run — except in `respond` and `green`, where it is blocked: a schema change agreed after the MR/PR exists goes back through `build`. Writing one whose every object `approved-schema.md` lists is not asked (§2, a schema approved with the study) |
426
449
  | `review` with blockers or high-severity findings | question `high_findings` |
427
450
  | `validate` with a criterion `unproven` | blocked — the phase does not advance and does not chain |
428
- | `validate` with a red suite | **One exception, and it is measured, never judged**: every failing test also fails, under the same name, on the base (`git merge-base HEAD <git.default_base>`, run in a detached worktree), none of them lives in a file this diff touches, and none is the test that proves an acceptance criterion. **The base runs the way HEAD went red**: the same command (the whole suite when the whole suite went red, never the failing file alone), and a test that is red in the whole suite but green on its own is load- or order-dependent, so one run on each side proves nothing — run the whole suite three times on HEAD and three on the base, and write each side's red count and that test's duration in every run. Red on the base as often as on HEAD → the exception holds: record `{"key":"unattended:validate-red-base","default":"<n> red on HEAD and on base <short sha>: <test names>","phase":"validate"}` and advance; `ship` lists those tests under "Not verified — needs a human". Green on the base and red on HEAD, even once in three → this diff made it, whatever a single base run said (a suspect flake, below, gets five more runs first); its repair step says so, with both sides' counts and how much slower the failing runs were, and the fix is what this diff adds under concurrency (a lock, a pool, a timer, a background loop), never a longer timeout or a retry. **A suspect flake is measured again before it is blamed**: a test red in exactly one of HEAD's three runs (the run that first went red is not one of them), in none of the base's, in a file this diff does not touch, green when run on its own, and not the test that proves an acceptance criterion. When at least one test is red in HEAD's three runs and every such test is one, run the whole suite five more times on HEAD — not on the base, whose three runs already said 0 — and write each run's red tests and the suspects' durations. Nothing red in any of the five → record `{"key":"unattended:validate-flaky","default":"<test name>: red 1/3 then 0/5 on HEAD, 0/3 on base <short sha>","phase":"validate"}` per test and advance; `ship` lists them under "Not verified — needs a human". Anything red in the five, or a red test that is not a suspect → this diff made it, and the repair rounds below follow: every red test, suspects included, goes to the repair rounds and counts in their `<n>`. The five runs are only ever more runs: a test is never rerun alone in their place, retried, skipped or loosened. Short of the exception and of a flake that held, **repair rounds while they make progress, at most three per MR/PR**: each round is a heading under this MR/PR's plan (`05-implementation.md` / `04-fix.md`), `### Red suite at validate (unattended), round <k>: <n> red`. No such heading yet, or the last one's `<n>` above the count red now and `<k>` below 3 → write the next heading with one unticked step per failing test (its name and the first line of its failure), each ending *fix the code, or update an assertion whose expected value this MR/PR's design or fix changed — never delete, skip or loosen a test*; record `{"key":"unattended:validate-red-loop","default":"round <k>, <n> red: <test names>","phase":"validate"}`, leave `phase = build` (`fix`) and chain into `/flow-feat-build` (`/flow-bug-fix`) — whose steps then run through the phases that follow it as always, review and validate included. A review of that round treats a test the round deleted, skipped or loosened as a blocker. A round that did not lower the count, or a third round still red → blocked, naming the tests still red and the count each round left |
451
+ | `validate` with a red suite | **One exception, and it is measured, never judged**: every failing test also fails, under the same name, on the base (`git merge-base HEAD <git.default_base>`, run in a detached worktree), none of them lives in a file this diff touches, and none is the test that proves an acceptance criterion. **The base runs the way HEAD went red**: the same command (the whole suite when the whole suite went red, never the failing file alone), and a test that is red in the whole suite but green on its own is load- or order-dependent, so one run on each side proves nothing — run the whole suite three times on HEAD and three on the base, and write each side's red count and that test's duration in every run. **Before either record below, the cause is looked for** (§11, a red test outside the change): a test that would take the base exception or the flake record and whose cause §11 identifies is not excused — it goes to the repair rounds below, its step naming the cause, and counts in their `<n>`; only a test whose cause is not identified takes a record, and **a pass that sends any test to a repair round writes no record at all** — the others are measured again at the next validate, so the pass has one ending. Red on the base as often as on HEAD → the exception holds: record `{"key":"unattended:validate-red-base","default":"<n> red on HEAD and on base <short sha>: <test names>","phase":"validate"}` and advance; `ship` lists those tests under "Not verified — needs a human". Green on the base and red on HEAD, even once in three → this diff made it, whatever a single base run said (a suspect flake, below, gets five more runs first); its repair step says so, with both sides' counts and how much slower the failing runs were, and the fix is what this diff adds under concurrency (a lock, a pool, a timer, a background loop), never a longer timeout or a retry — unless §11 finds the fragility in the test itself (it counts ticks the diff's extra load now delays): then the test is the step, fixed as §11 says. **A suspect flake is measured again before it is blamed**: a test red in exactly one of HEAD's three runs (the run that first went red is not one of them), in none of the base's, in a file this diff does not touch, green when run on its own, and not the test that proves an acceptance criterion. When at least one test is red in HEAD's three runs and every such test is one, run the whole suite five more times on HEAD — not on the base, whose three runs already said 0 — and write each run's red tests and the suspects' durations. Nothing red in any of the five → record `{"key":"unattended:validate-flaky","default":"<test name>: red 1/3 then 0/5 on HEAD, 0/3 on base <short sha>","phase":"validate"}` per test and advance; `ship` lists them under "Not verified — needs a human". Anything red in the five, or a red test that is not a suspect → this diff made it, and the repair rounds below follow: every red test, suspects included, goes to the repair rounds and counts in their `<n>`. The five runs are only ever more runs: a test is never rerun alone in their place, retried, skipped or loosened. Short of the exception and of a flake that held, **repair rounds while they make progress, at most three per MR/PR**: each round is a heading under this MR/PR's plan (`05-implementation.md` / `04-fix.md`), `### Red suite at validate (unattended), round <k>: <n> red`. No such heading yet, or the last one's `<n>` above the count red now and `<k>` below 3 → write the next heading with one unticked step per failing test (its name and the first line of its failure), each ending *fix the code, or update an assertion whose expected value this MR/PR's design or fix changed, or — for a test §11 found fragile — make it assert on the result it meant to prove; never delete, skip, retry or loosen a test, and never lengthen a timeout*; record `{"key":"unattended:validate-red-loop","default":"round <k>, <n> red: <test names>","phase":"validate"}`, leave `phase = build` (`fix`) and chain into `/flow-feat-build` (`/flow-bug-fix`) — whose steps then run through the phases that follow it as always, review and validate included. A review of that round treats a test the round deleted, skipped or loosened as a blocker; a fragile test rewritten to assert on the same result, as §11 allows, is not loosened. A round that did not lower the count, or a third round still red → blocked, naming the tests still red, the count each round left and, for each, what a person does next |
429
452
  | A product decision (§7 `decision`) | question `decision` |
430
453
  | Clarifying questions on the ticket (`start`) | question `clarify` — after the branch and the work folder exist, with the questions also written to `01-context.md` |
431
454
  | An unanswered high-severity challenge (`design`, `investigate`) | question `design_challenge` / `investigation_challenge` |
@@ -1408,3 +1431,53 @@ before and after:
1408
1431
 
1409
1432
  Bugs do not link: a bug repairs something already delivered, and the roadmap tracks what is still to
1410
1433
  deliver. A bug that *is* a roadmap item is started as a feature.
1434
+
1435
+ ## 11. A red test outside the change — find the cause before it is excused
1436
+
1437
+ A test this diff did not touch goes red, and every path flow has for it — the base exception and the
1438
+ flake record of `validate` (§2.1), a rerun in `green`, "not reproduced" in `respond` — hands it to a
1439
+ person. When flow can see why the test is red, handing it over is the wrong answer: the MR/PR has to
1440
+ go green to merge, so the fix is in scope whether or not the diff touched that test.
1441
+
1442
+ **Look for the cause first.** Read the test and the code it drives, and name the mechanism. Typical
1443
+ causes in the test: it asserts on **how many times** something ran (timer ticks, calls, retries)
1444
+ inside a wall-clock window instead of on what came out — when the count *is* the behaviour (retries, calls made), the count stays and the clock is what gets fixed (a fake or injected time source); it depends on the order tests run in; it
1445
+ reads state another test left behind (a shared fixture, a global, a file, a port); it sleeps and
1446
+ hopes. Typical causes in the code: a race, an await missing, a resource not released.
1447
+
1448
+ **Identified means evidence, not a story.** A cause is identified only when the diagnosis names it at
1449
+ `file:line` **and** either (a) a forced reproduction turns the test red on purpose — stall the timer,
1450
+ reorder the run, leave the shared state dirty, load the machine — or (b) the mechanism is in the
1451
+ assertion itself, plain to read (it counts ticks in a time window, it expects an order nobody
1452
+ guarantees). A plausible guess with neither is **not identified**, and is never acted on.
1453
+
1454
+ **Identified → a repair step in this MR/PR**, aimed where the cause is:
1455
+
1456
+ - **In the test** → the test is rewritten to prove the **same behaviour by its result**, not by its
1457
+ timing or its order. That is not loosening it: the assertion keeps its subject and gets a sturdier
1458
+ witness. Never delete, skip, retry or loosen it, and never lengthen a timeout or a sleep — each one
1459
+ hides the cause instead of removing it. Where (a) applied, the forced reproduction passes after the
1460
+ fix.
1461
+ - **In the code** → the step fixes the code; the test stays as it is.
1462
+ - **Proved by the whole suite**, never by `quality.test_one` alone — an order- or load-dependent test already passes on its own — plus the forced reproduction where (a) applied.
1463
+ - A fragile test in a file this diff touches is repaired the same way: it never had the exception to lose.
1464
+ - **Its own commit** — `Fix fragile test <name>: <cause in one line>` — never folded into another
1465
+ step's or round's commit, so a reviewer reads it alone.
1466
+ - **The MR/PR body says so**, under `## Also fixed`: `` `<test>` — <cause>; <what changed> `` —
1467
+ written by `ship` for a repair made before it (`/flow-feat-ship`, `/flow-bug-ship`); a repair made
1468
+ by `green` or `respond` on an MR/PR already open adds the line itself: to `publish-body.md` in
1469
+ `unattended`, otherwise to the MR/PR description with the push, shown at the push gate.
1470
+
1471
+ **Not identified → the path that already exists** (the base exception, the flake record, a rerun,
1472
+ `blocked`), and whatever that path leaves red says, in the slot it already has — the stop's
1473
+ `I need:`, the `blocked` reason, the "what to do" of a line under `## Not verified — needs a human` —
1474
+ **what the person does next**, in one plain line: *rerun CI; if `<test>` fails again, its cause is
1475
+ not in this change — open a ticket for it*, never only that the test is red.
1476
+
1477
+ **A CI failure that does not reproduce here** (`green`, or a CI log a person pasted into a review
1478
+ thread for `respond`) is diagnosed the same way, from its log and the test's code: a fragility
1479
+ identified → fix it as above and push it, even though it would not go red locally. Neither
1480
+ reproduced nor identified → change nothing for it and say so. In `unattended` that run ends with
1481
+ its usual closing order when it changed code (`publish`: the push reruns CI anyway); when it changed
1482
+ nothing, it ends `blocked`, its one-line reason starting `rerun CI: <job>[, <job>…]` — not
1483
+ reproduced, no cause found — so the orchestrator knows a rerun is all that is left.
@@ -223,7 +223,7 @@ If the bug turned out simpler or wider than `meta.json.size` says (multi-compone
223
223
  If `knowledge.stage` is set and the root cause reveals a **non-obvious "why"** about the domain (a false model assumption, a historical decision that no longer applies, an undocumented external-integration behaviour), stage it. Silence by default — only on a clear signal.
224
224
 
225
225
  - `knowledge.stage` with the finding and context, one call per finding.
226
- - Notify the user: "Staged X domain finding(s) to consolidate in `/flow-bug-postmortem`".
226
+ - Notify the user: "Staged X domain finding(s) to consolidate in `/flow-bug-postmortem`" (M/L) or "in `/flow-bug-ship`" (XS/S, whose route has no postmortem).
227
227
  - Never `knowledge.save` here — that belongs to the postmortem.
228
228
 
229
229
  ## 8. Close
@@ -87,7 +87,7 @@ Produce an honest analysis:
87
87
  1. Call `knowledge.read_staging` (empty → the findings recorded in `03-investigation.md`) — the findings staged in `/flow-bug-investigate` are the primary material.
88
88
  2. Review the postmortem for additional "why" items not staged at the time (business decisions, legal constraints, integrations, false model assumptions). The "what" (code, paths) is not saved.
89
89
  3. Combine staging + new findings. Empty or only obvious things → do not insist.
90
- 4. 1+ relevant findings → ask the user whether to save them. Yes → run the consolidation of flow-core §0, with the right angle (the lesson, not the code). No → do not insist.
90
+ 4. 1+ relevant findings → ask the user whether to save them. Yes → run the consolidation of flow-core §0, with the right angle (the lesson, not the code) — with a worktree, its step 4 moves the written files into it, left uncommitted for `/flow-bug-ship` §3.1 to commit with the fix. No → do not insist. Either way record the answer in `meta.json.knowledge` (flow-core §0 step 6): `ship` reads it to know the question was asked.
91
91
 
92
92
  Neither role set → skip this block silently.
93
93
 
@@ -19,13 +19,13 @@ description: Commit, push, MR/PR the fix
19
19
  Close the bug flow: commit, push, MR/PR. Same mechanics as `/flow-feat-ship`, with two differences:
20
20
 
21
21
  1. If `99-postmortem.md` exists, **include the link or the executive summary** in the MR/PR description.
22
- 2. The knowledge-consolidation offer was already made in `/flow-bug-postmortem` — do not ask again here.
22
+ 2. **Knowledge goes in the fix's own commit, decided where it was not decided yet.** `postmortem` in `phases_done` and `meta.json.knowledge.status` set → `/flow-bug-postmortem` §4 already answered it (and with a worktree, already moved the files into it): do not ask again; its `meta.json.knowledge.files` are staged with the fix in §3.1. Otherwise — a fix of size XS/S, whose route has no postmortem, or a postmortem from before this rule — run `/flow-feat-ship` §2 *Domain knowledge* here, with `03-investigation.md`, `04-fix.md`, `05-validation.md` and `06-review.md` as the artifacts it reads: the findings go into the §2 preview, and §3.1 consolidates them before the commit. Without this, what `investigate`, `validate` and `review` staged on a small fix was never saved, or went out later in an MR/PR of its own.
23
23
 
24
24
  **In `unattended`** (flow-core §2.1) this command asks nothing, pushes nothing and opens nothing —
25
25
  the same resolutions as `/flow-feat-ship`'s unattended paragraph, and its "In every mode" paragraph
26
26
  too, applied to the sections here: the MR/PR (§2–§3) is not confirmed and not created — its title
27
27
  and description go to `publish-title.md` / `publish-body.md` in the work folder, §3.1–§3.3 do not
28
- run, and pre-deploy SQL → question `migration`; §3.0's upstream on the base is unset with no push. The tree check (§0) re-runs what is behind `HEAD`
28
+ run, the knowledge of difference 2 is `Later` (recorded, as `/flow-feat-ship` says), and pre-deploy SQL → question `migration`; §3.0's upstream on the base is unset with no push. The tree check (§0) re-runs what is behind `HEAD`
29
29
  once per MR/PR, recorded as `/flow-feat-ship` says — here `validate` first, since it ran before the
30
30
  review, then the review on the delta — and is `blocked` after that. Every offer and survey at Close
31
31
  (§4) — follow-ups, conventions, archiving — is `Later`; "was it merged?" is not merged (`phase`
@@ -89,6 +89,9 @@ Template (in this order):
89
89
  <bullets from the "What is NOT touched" section of the Brief. Important so the reviewer knows the fix is minimal.>
90
90
  <then, if `meta.json.followups[]` has entries still `proposed` or `accepted`: one line each — the neighbouring bug, the similar-risk pattern, the prevention action — with its ticket id when one exists. Omit the block when there are none.>
91
91
 
92
+ ## Also fixed
93
+ <only when a test outside this fix went red and was repaired because its cause was identified (flow-core §11): one line each, `` `<test>` — <cause>; <what changed> ``. Omit the section otherwise.>
94
+
92
95
  ## Evidence
93
96
  <only if `.claude/work/<TICKET>/evidence/` has files and `quality.evidence` is not `off`. The **before** is what `03-investigation.md` captured when the failure was reproduced — the one moment it exists — and the **after** is §2.5 of `05-validation.md`. A bug fix is the change where a before/after pair carries the most: it *is* the argument. Same upload rules as `/flow-feat-ship`. Omit when there is nothing.>
94
97
 
@@ -144,6 +147,7 @@ Squash: <git.squash from FLOW.md>
144
147
  Target branch: <git.default_base>
145
148
  Issue link: <keyword that will appear in the body, e.g. "Closes #123" / "none — Jira links by title prefix">
146
149
  Pre-deploy (manual SQL): <"yes — N statements, a blocking thread will be opened" / "not applicable">
150
+ Knowledge: <N finding(s) saved before the commit, shipped in it — one line each / "N file(s) the postmortem saved, shipped in it"> (line only when there is any)
147
151
 
148
152
  Description:
149
153
  <full description rendered exactly as it will appear in the MR/PR>
@@ -155,6 +159,7 @@ If there is pre-deploy SQL, ask the user to **explicitly confirm that the block
155
159
  Then ask with `AskUserQuestion` (header: "Create {MR or PR}"):
156
160
 
157
161
  - **Create {MR or PR} with this content** → §3.
162
+ - **Create, without saving the knowledge** (only with findings gathered here) → §3 without the consolidation; `meta.json.knowledge.status: "later"`, offered again on the re-run as `/flow-feat-ship` §5 says.
158
163
  - **Edit before creating** → adjust what the user indicates, return to §2.
159
164
  - **Cancel** → stop without creating anything. Do not touch `meta.json`.
160
165
 
@@ -172,6 +177,8 @@ Only here — with the content approved in §2 — invoke `Skill commit-commands
172
177
 
173
178
  Assign to `git.assignee` from FLOW.md (empty → unassigned). Squash per `git.squash`.
174
179
 
180
+ **Knowledge, before the commit — `/flow-feat-ship` §4.1's knowledge bullet, in full and unchanged**: findings approved in §2 → the consolidation of flow-core §0, step 4 moving the written files from the main checkout into the worktree; then those files, and any the postmortem already landed (`meta.json.knowledge.files`), are staged with the fix. A failed `save` → one line, `failed`, and the fix ships without them.
181
+
175
182
  **Record the URL the moment it exists**: write it into `meta.json` (the `mrs` entry if there is one) and refresh the panel (flow-core §4) right here, before §3.2 and before anything else can fail.
176
183
 
177
184
  **The pipeline the push starts is not watched from this thread — `/flow-feat-ship` §4.1, in full and unchanged**: close with CI reported as *running*, or delegate the wait to a supervisor subagent on `models.supervisors` (flow-core §6.5) with a deadline, taking back status and failing-job evidence only. A red pipeline is `/flow-work-green`'s to triage, never this command's.
@@ -189,7 +196,8 @@ posted as comments anchored on the changed lines of the MR/PR, confirmed in ever
189
196
 
190
197
  ## 4. Close
191
198
 
192
- - **A worktree does not own the tree its tools wrote into — `/flow-feat-ship` §5.5, in full and unchanged.** First, before anything below: `meta.json.worktree` not null → read the main checkout's `git status --porcelain`, name any paths it holds in one line as what they are (in the main checkout, not in the branch just pushed, and not necessarily put there by this run), and offer once to carry them over. A fix consolidates its knowledge one phase earlier, in `/flow-bug-postmortem` §4, so by the time this runs those writes have already happened and the branch has already been pushed — which is exactly the window this check exists to close.
199
+ - **A worktree does not own the tree its tools wrote into — `/flow-feat-ship` §5.5, in full and unchanged.** First, before anything below: `meta.json.worktree` not null → read the main checkout's `git status --porcelain`, name any paths it holds in one line as what they are (in the main checkout, not in the branch just pushed, and not necessarily put there by this run), and offer once to carry them over. The knowledge files are no longer the expected case — flow-core §0 step 4 moved them into the worktree before the commit, whether `postmortem` or §3.1 saved them — so what is left here is another tool's output, or a move that went wrong.
200
+ - **Knowledge still owed — `/flow-feat-ship` §5, in full and unchanged**: `meta.json.knowledge.status` `later` or `failed` → offered once on this re-run; onto the open branch, or a knowledge-only MR/PR once the fix merged.
193
201
  - Update `meta.json`: add `ship` to `phases_done`, update `updated_at`. **`phase` becomes `done` only once the MR/PR is confirmed merged** — creating it is not finishing it. Right after §3.1 it is open, so ask once with `AskUserQuestion` whether it has already been merged: **no** (the normal answer) → leave `phase = "ship"`; **yes** → `phase = "done"`. `/flow-work-green` and `/flow-work-respond` work on the open MR/PR; `/flow-work-clean` only sweeps what merged.
194
202
  - Refresh the panel: while the MR/PR is open its line is `wait` with the `link`; once merged it is `done`, and only then say there is nothing left here (`mark: "info"`, `style: "ok"`). Drop the `Decision` line either way.
195
203
  - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5).
@@ -198,10 +206,10 @@ posted as comments anchored on the changed lines of the MR/PR, confirmed in ever
198
206
  - **Cross-repo reminder**: for each `meta.json.related_repos` entry not `done`: *"you've shipped the `<this-repo>` part; `<repo>` still needs: `<scope>` → go there and run `/flow-bug-start <TICKET>` (or `/flow-feat-start`)"*. flow only reminds; this is not a hard gate.
199
207
  - **Cross-repo contract handoff**: for each such entry with `contract_handoff: "pending"` — the fix changed a surface that sibling consumes — hand the new shape over as `/flow-feat-ship` §6.3 (publish the **literal** shape to the tracker ticket, mandatory preview in every autonomy mode, then record `published → <location>`; versioned-file fallback when there is no tracker). A bug flow has no §"External contracts": take the literal from the fix itself — the actual key, code, route or event the code now emits — read it off the code, never from memory.
200
208
  - **Follow-up triage — `/flow-feat-ship` §6.4, in full and unchanged.** Read `meta.json.followups[]`; nothing `proposed` → skip silently. Otherwise §6.4 step 0 first — **3 or more candidates go to a skeptic** whose job is to refute that each deserves a ticket, and only the strongest `tracker.followup_ask_max` (empty → **2**) reach the user (flow-core §7) — then one batched `AskUserQuestion` (**Do it** / **Not worth it** / **Later**; `decision` entries asked as their question, `tooling` and everything `log`ged never asked), the accepted ones get their tracker issue created (outward-facing → **asks in every mode**), the logged ones nothing but `status: "logged"` in `meta.json`, then one offer to start the first. A bug flow is where the gate earns its keep: the prevention actions `/flow-bug-postmortem` wrote, the neighbouring bugs `/flow-bug-validate` found and the similar-risk patterns `/flow-bug-fix` flagged all land here — half a dozen of them, from one fix, and «similar risk elsewhere» that no skeptic ever read is exactly the entry that turns a closed bug into six open questions. Repeat for anything still `proposed` on the re-run that confirms the merge.
201
- - **Specialists created — `/flow-feat-ship` §5.1, in full and unchanged.** Read `meta.json.specialists[]` (flow-core §6.6); nothing `useful` and pending → skip silently. Otherwise one batched offer to save each as an agent, after the MR/PR and after the knowledge `/flow-bug-postmortem` §4 already consolidated — asked in every mode, never overwriting an agent that exists.
209
+ - **Specialists created — `/flow-feat-ship` §5.1, in full and unchanged.** Read `meta.json.specialists[]` (flow-core §6.6); nothing `useful` and pending → skip silently. Otherwise one batched offer to save each as an agent, after the MR/PR and the knowledge that shipped in it — asked in every mode, never overwriting an agent that exists.
202
210
  - **What the agents missed — `/flow-feat-ship` §5.2, in full and unchanged.** Read `meta.json.agent_lessons[]` (flow-core §6.7); `agents.learn: off` or nothing pending → skip silently. Otherwise one question per agent with the resulting lessons section, backup first, your agents asked in every mode.
203
211
  - **Conventions learned — `/flow-feat-ship` §6.4bis, in full and unchanged.** Read `meta.json.conventions_candidates[]` (flow-core §8); nothing pending → skip silently. Otherwise: drop what `FLOW.md` already says, then one batched `AskUserQuestion` (**Add to FLOW.md** / **Not a rule** / **Later**, or **Replace** when it contradicts a line that is there). Asked in every mode — it edits a file in the tree. A fix is where the corrections land hardest: *«never mock the repository in that layer»*, *«the regression test goes next to the unit test, not in the functional suite»* — said once inside `bug:fix`, and proposed again in the next incident unless they reach the file.
204
212
  - **Close the follow-up that started this work.** `meta.json.origin` set and this ship moved `phase` to `done` → open the originating work's `meta.json` (live folder or `_archive/`) and set that `followups[]` entry to `status: "done"`. Best-effort: the originating folder is gone or unreadable → warn in one line and continue, never block. Without this the entry stays `in_progress` forever and `status`/`daily` keep reporting work that is finished.
205
- - **Only once `phase` is `done`**: delete the candidate anchor `/flow-bug-review §1.5` left behind — `git update-ref -d refs/flow/candidate/<TICKET>`. No question: local, never pushed, and the gate that needed it has run.
213
+ - **Only once `phase` is `done`**: delete the candidate anchor `/flow-bug-review §1.5` left behind — `git update-ref -d refs/flow/candidate/<TICKET>`. No question: local, never pushed, and the gate that needed it has run. And clear the branch's staging as `/flow-feat-ship` §6.5 says (`consolidated`/`declined` only).
206
214
  - Ask whether to archive `.claude/work/<TICKET>/` to `.claude/work/_archive/`.
207
215
  - If `meta.json.worktree` is not null, offer `git worktree remove <worktree>` once the MR/PR is merged (`--force` only if the user confirms discarding remaining changes). Not before merge, not without confirmation.
@@ -95,7 +95,7 @@ this is the same gate as a red test.
95
95
 
96
96
  ## 5. Close
97
97
 
98
- - Red test, regressions, **or the original symptom still reproducible in §2.5** → `phase` stays at `fix`; the user iterates. A red gate stops in every mode except `unattended`, where flow-core §2.1 decides: every failing test also red on the base → its exception advances (the reproduction test lives in a file this diff touches, so it never qualifies); when every test red in HEAD's three runs is a suspect flake — red once in HEAD's three runs, never on the base, outside the files this diff touches, green on their own — those tests get that row's five more HEAD runs, their counts written in `05-validation.md`, and nothing red in them advances with `unattended:validate-flaky` (the reproduction test never qualifies here either); otherwise a repair round of that row — the failing tests become unticked steps of `04-fix.md`'s plan, `phase = fix`, chain into `/flow-bug-fix`, which chains back here; rounds go on while each lowers the red count, three at most, and one that does not, or a third still red → `blocked`, naming the tests still red. The original symptom still reproducible in §2.5 is not a failing test: `blocked`, naming it.
98
+ - Red test, regressions, **or the original symptom still reproducible in §2.5** → `phase` stays at `fix`; the user iterates. A red gate stops in every mode except `unattended`, where flow-core §2.1 decides — and before any test is excused there, its cause is looked for (flow-core §11): identified → a repair step, its own commit, never an exception or a flake record. Every failing test also red on the base → its exception advances (the reproduction test lives in a file this diff touches, so it never qualifies); when every test red in HEAD's three runs is a suspect flake — red once in HEAD's three runs, never on the base, outside the files this diff touches, green on their own — those tests get that row's five more HEAD runs, their counts written in `05-validation.md`, and nothing red in them advances with `unattended:validate-flaky` (the reproduction test never qualifies here either); otherwise a repair round of that row — the failing tests become unticked steps of `04-fix.md`'s plan, `phase = fix`, chain into `/flow-bug-fix`, which chains back here; rounds go on while each lowers the red count, three at most, and one that does not, or a third still red → `blocked`, naming the tests still red and, for each, what a person does next. The original symptom still reproducible in §2.5 is not a failing test: `blocked`, naming it.
99
99
  - Green → `phase = "validate"`, add to `phases_done`; in the same write record `validated_sha` = `git rev-parse HEAD` — the tree the regression test passed on, which `/flow-bug-ship §0` reads. Suggest `/flow-bug-review`.
100
100
  - **Other bugs detected become `followups[]` entries** (flow-core §7) when they clear its bar — a reproducible symptom with someone who suffers it, not «this looks fragile» — per the output template.
101
101
  - **Stage what the validation taught** (`knowledge.stage` set; silence by default): a mutation that stayed green, a disguise the scenario wore, a fixture that could not produce the case — findings about how this codebase is tested, not about this diff. Same rule and evidence line as the review's Close.
@@ -92,9 +92,12 @@ there → it is a question like any other.
92
92
  Chained from a review's `high_findings` *Fix them* → the findings are unticked steps at the end of
93
93
  this MR/PR's plan: build them in order, then chain into `/flow-feat-review`. Chained from a red
94
94
  suite at validate (flow-core §2.1) → the same, under the plan's latest `### Red suite at validate
95
- (unattended), round <k>` heading: one step per failing test, and a test reaches green by fixing the code or by an
96
- assertion this MR/PR's design changed — never by deleting, skipping or loosening it. Run each
97
- step's test with `quality.test_one` before ticking it.
95
+ (unattended), round <k>` heading: one step per failing test, and a test reaches green by fixing the code, by an
96
+ assertion this MR/PR's design changed, or — a step naming a fragile test's cause (flow-core §11) —
97
+ by making it assert on the result it meant to prove, in its own commit `Fix fragile test <name>:
98
+ <cause>`; never by deleting, skipping, retrying or loosening it, or by a longer timeout. Run each
99
+ step's test with `quality.test_one` before ticking it — and a §11 step with the whole suite plus its
100
+ forced reproduction, since an order- or load-dependent test already passes on its own.
98
101
 
99
102
  **The brief travels inside the question** (flow-core §3): the user reads it in the prompt they are answering, never by opening `05-implementation.md`. Write the file, run whatever you need, and *then* open the gate — **nothing runs between the brief and the question**, because a tool call after it is what lets a terminal fold the brief into one collapsed line, and the gate is answered blind. Options:
100
103
  - **Yes, proceed** → start building.
@@ -22,7 +22,7 @@ Read `~/.claude/flow/CORE.opencode.md` first (shared rules: `FLOW.md` step 0, mo
22
22
 
23
23
  **In `unattended`, before this phase's first step, read flow-core §2.1 whole — from its heading to the next section, unless it is already in your context whole; having read parts of it does not count** — the orchestrator command, the question stop and the way its answer comes back are all in it, and a phase that reads only part of it skips them.
24
24
 
25
- Closes the feature: commit, push, MR/PR (assigned per `git.assignee`, squash per `git.squash`, sections per `git.request_sections`) and an optional offer to consolidate knowledge.
25
+ Closes the feature: commit, push, MR/PR (assigned per `git.assignee`, squash per `git.squash`, sections per `git.request_sections`), with the domain knowledge the work learned approved in the same preview and shipped in the same commit.
26
26
 
27
27
  **In `unattended`** (flow-core §2.1) this command asks nothing, pushes nothing and opens nothing:
28
28
  it hands the finished MR/PR to the orchestrator, which pushes the branch and opens the draft. Each
@@ -46,8 +46,9 @@ place it would ask:
46
46
  continue and list them in the body.
47
47
  - **Posting anything else** — a contract handoff (§6.3) — → not posted; the handoff stays
48
48
  `pending`.
49
- - **The offers and surveys (§5, §5.1, §5.2, §5.5, §6.4, §6.4bis)** → `Later`; nothing written outside
50
- the work folder.
49
+ - **The offers and surveys (§2's *Domain knowledge*, §5, §5.1, §5.2, §5.5, §6.4, §6.4bis)** → `Later`;
50
+ nothing written outside the work folder. Knowledge left unsaved this way is recorded
51
+ (`meta.json.knowledge.status: "later"`), so the first attended `ship` of the work offers it again.
51
52
  - **"Was it merged?" (§6.1)** → not merged: the entry stays `in_progress` (a work with no `mrs`
52
53
  keeps `phase = "ship"`) until `publish` succeeds, below. **The parent merged first (§6.2.1)** → blocked, never
53
54
  force-push. **Train continuation (§6.2)** → not started: one MR/PR per unattended run (with
@@ -65,10 +66,14 @@ place it would ask:
65
66
 
66
67
  **In every mode**, criteria `07-validation.md` marks `not-verified-unattended` go into the body under
67
68
  `## Not verified — needs a human`, with what to do for each — and so do the tests the suite left red
68
- because they also fail on the base (`unattended:validate-red-base`): each name, and the base sha
69
- where it failed too — and the suspect flakes the run advanced past (`unattended:validate-flaky`), one line each:
70
- `` `<test>` — intermittent: red 1/3 then 0/5 on HEAD, 0/3 on base `<sha>`; not in a file this change touches `` — and the review findings an orchestrator's answer accepted unfixed
71
- (`06-review.md` "Answered (unattended)"), one line each. The §3 preview shows that section like
69
+ because they also fail on the base (`unattended:validate-red-base`): each name, the base sha
70
+ where it failed too, and what the person does next (flow-core §11) — and the suspect flakes the run advanced past (`unattended:validate-flaky`), one line each:
71
+ `` `<test>` — intermittent: red 1/3 then 0/5 on HEAD, 0/3 on base `<sha>`; not in a file this change touches; rerun CI, and if it fails again open a ticket for it `` — and the review findings an orchestrator's answer accepted unfixed
72
+ (`06-review.md` "Answered (unattended)"), one line each. A test outside the change that this
73
+ MR/PR repaired because its cause was identified (flow-core §11) — a repair step of a validate round,
74
+ or of `green`/`respond` — goes under `## Also fixed`, one line each:
75
+ `` `<test>` — <cause>; <what changed> ``, so the reviewer sees why a test this change did not need
76
+ was touched. The §3 preview shows that section like
72
77
  any other, and the person reading it is the check the run could not do. Entries of
73
78
  `auto-answers.md` for this MR/PR (`MR/PR <n>` in their heading, or all of them for a work with no
74
79
  `mrs`) — plus, while no `mrs[]` entry is `published` or `merged`, every entry whose heading names none: a study
@@ -82,7 +87,7 @@ the one taken checked (flow-core §2.1, the recommended answer).
82
87
  - Not met → refuse and send the user to the missing step (multi-MR/PR: `/flow-feat-review` or `/flow-feat-validate` **for this MR/PR**).
83
88
  - **The review has to be about the tree you are about to push.** `reviewed_sha` is the revision the reviewers **read** (`/flow-feat-review §1.5` froze it), not the one that phase ended on, so the round's own fixes are a real delta here rather than a match. Compare `meta.json.reviewed_sha` and `validated_sha` (this MR/PR's `mrs[]` entry in a multi-MR/PR work) against `git rev-parse HEAD`:
84
89
  - **Equal** → continue, nothing to report — **unless `fixed_sha` is set**, which says the review changed the tree after reading it and cannot then be equal to `HEAD`. That combination is a mismatch, not a match: the shas were recorded by two different mechanisms and one of them is wrong. Say so and treat it as Different below.
85
- - **The tree is dirty at this end** (`git status --porcelain` non-empty, ignoring untracked) → both shas describe committed history and the bytes about to be pushed are not in either. Name the paths and ask, exactly as Different does; a comparison of two identical shas over two different trees is the case the old gate passed over in silence.
90
+ - **The tree is dirty at this end** (`git status --porcelain` non-empty, ignoring untracked, and ignoring the paths in `meta.json.knowledge.files` — knowledge a `postmortem` or a `daily` offer already landed here, flow-core §0 step 4, which ships with this commit and is no code to review) → both shas describe committed history and the bytes about to be pushed are not in either. Name the paths and ask, exactly as Different does; a comparison of two identical shas over two different trees is the case the old gate passed over in silence.
86
91
  - **`reviewed_sha` does not resolve** (`git cat-file -e <sha>^{commit}`) — a candidate from a dirty tree whose anchor ref was deleted, or history rewritten since — → say so in one line and treat it as Absent. A gate that cannot read its own input must not report nothing wrong here.
87
92
  - **Absent** (work started before the shas were recorded) → say so in one line and continue. Absence is not a mismatch.
88
93
  - **Different** → read the delta (`git log --oneline <sha>..HEAD`, `git diff --stat <sha>..HEAD`) and judge it by **what it touches**, never by size. When `fixed_sha` is set, say in the same line that part of this delta is the review's own fixes: the user is judging what the reviewers never read, and where it came from is the first thing they need.
@@ -121,6 +126,16 @@ Decide first whether **this** MR/PR *completes* the issue: it does when, after i
121
126
 
122
127
  `meta.json.roadmap` set, or a stale item §10 counts as delivered, and `roadmap.mark` not `never` → decide the edit by flow-core §10, with the same *completes / intermediate* answer as the issue link above: the work's first MR/PR with more to come marks the item in progress, the completing one marks it done (with its children, and any parent left with every child done — never a milestone that states a closing criterion), an intermediate one touches nothing. Find the item by its `item` text with flow's annotation, or a table row's note, stripped; not found → no edit, and the stop says so. In a table, only the state cell and an empty ticket cell change. Not an intermediate MR/PR → also list the **stale items** §10 counts as delivered, to be marked done in the same edit. Decide it here, show it in the §3 preview, write it in §4.1 — never before approval.
123
128
 
129
+ ### Domain knowledge (decided with the MR/PR, written before its commit)
130
+
131
+ Only if `knowledge.read_staging` or `knowledge.save` is set; neither → skip without notifying (the artifacts already hold the findings). `meta.json.knowledge.status` already `consolidated` (a `daily` offer banked it mid-work) → nothing new to gather beyond what was staged since; `declined` → skip, it was answered.
132
+
133
+ 1. **Read the staging accumulated during the branch**: `knowledge.read_staging` (empty → what the artifacts recorded) — what `/flow-feat-design` and the other phases staged. Main material.
134
+ 2. **Review** `03-design.md`, `05-implementation.md`, `06-review.md` for "why" findings (domain decisions, legal constraints, integrations, business motivations) **not staged at the time**. The "what" (code, paths) is NOT saved.
135
+ 3. **Combine** into a short list, one line per finding. Empty or only code-derivable → no `Knowledge` line in §3 and `meta.json.knowledge.status: "nothing"` — silence by default.
136
+
137
+ Nothing is saved here. The list goes into the §3 preview and is approved with the MR/PR; §4.1 runs the consolidation (flow-core §0) **before the commit**, so the files it writes travel in the same commit as the change. Saving after the push is what left knowledge files sitting in a main checkout while the MR/PR merged without them.
138
+
124
139
  ### Referencing other MRs/PRs of the plan in the body (never `#<n>`)
125
140
 
126
141
  When the body mentions **another MR/PR of the delivery plan**, **never write `#<n>`** with `<n>` the plan order from `meta.json.mrs` — GitHub/GitLab auto-link it to whatever issue/PR carries that number (`#5 (closed)`).
@@ -204,6 +219,8 @@ Issue link: <keyword that will appear in the body, e.g. "Closes #123" / "Part of
204
219
  Pre-deploy (manual SQL): <"yes — N statements, a blocking thread will be opened" / "not applicable">
205
220
  Roadmap: <"<line now>" → "<line after>", one pair per line changed / "untouched — intermediate MR/PR" / "item not found"> (line only with a linked item or a stale one)
206
221
  <stale items: "<line now>" → "<line after>" — <evidence>; each one can be dropped from the edit> (only if any)
222
+ Knowledge: <N finding(s) saved before the commit, shipped in it:> (line only with a §2 list)
223
+ <- one line per finding>
207
224
 
208
225
  Description:
209
226
  <full description rendered exactly as it will appear in the MR/PR>
@@ -215,7 +232,8 @@ If there is pre-deploy SQL, ask the user to **explicitly confirm that the block
215
232
  The preview is the last thing before the question — **no tool call between them** (flow-core §3), or the block the user is meant to approve is the one their terminal folds away. Then ask with `AskUserQuestion` (header: "Create <MR or PR>"):
216
233
 
217
234
  - **Create with this content** → invoke §4.
218
- - **Edit before creating** → user says what to change (title, a section, both); adjust and return to §3 with the new preview.
235
+ - **Create, without saving the knowledge** (only with a `Knowledge` line) → invoke §4 and skip its consolidation; `meta.json.knowledge.status: "later"`, offered again by the re-run of this command (§5). A finding the user wants dropped rather than postponed is an *Edit*.
236
+ - **Edit before creating** → user says what to change (title, a section, a finding, any of them); adjust and return to §3 with the new preview.
219
237
  - **Cancel** → stop without creating anything. Do not touch `meta.json`. The user can return to `/flow-feat-ship` later.
220
238
 
221
239
  Do not push or invoke any creation command until the user has responded "Create with this content".
@@ -237,6 +255,7 @@ Only here — with the content approved in §3 — invoke `Skill commit-commands
237
255
 
238
256
  - `git.assignee` not empty → assign to that user. `git.squash` `true` → enable squash-before-merge.
239
257
  - **Roadmap mark approved in §3** → write it into the roadmap file **before** the commit, here in the worktree (a tracked file belongs to the branch, flow-core §0), so it ships in the same commit as the change. A git-ignored roadmap is edited in place in the main checkout instead, and the stop says it travelled in no MR/PR.
258
+ - **Knowledge approved in §3** → at the same point, before the commit: run the consolidation of flow-core §0 on the approved list, step 4 included — with `meta.json.worktree` set, every file `knowledge.save` wrote is moved from the main checkout into this worktree, so it is in the diff about to be committed and the main checkout is left as it was. Then stage what it wrote (`meta.json.knowledge.files`, or the `KNOWLEDGE.md` it appended) with the change — and the files an earlier phase already landed in this worktree (the same key), which are otherwise left uncommitted. A store that writes outside the repo leaves nothing to stage, and that is fine. A `save` that fails → report it in one line, `meta.json.knowledge.status: "failed"`, and the MR/PR goes out without those files; §5 offers them again.
240
259
  - `commit-push-pr` skill unavailable → commit and push manually and create the MR/PR with the `git.cli` CLI from `FLOW.md` — always with the content confirmed in §3.
241
260
 
242
261
  **Record the URL the moment it exists**: write it into this MR/PR's `meta.json.mrs` entry and refresh the panel (flow-core §4) right here, before §4.2 and before anything else can fail.
@@ -316,20 +335,22 @@ no measurable change, not a percentage.
316
335
  - Posting to the forge is outward-facing: show the comment and confirm with `AskUserQuestion`
317
336
  **in every `autonomy.mode`**, exactly like the description preview in §3.
318
337
 
319
- ## 5. Domain knowledge (offer)
338
+ ## 5. Knowledge still owed (re-run only)
320
339
 
321
- Only if `knowledge.read_staging` or `knowledge.save` is set; neither → skip without notifying (the artifacts already hold the findings). **Only if there is something non-obvious worth saving** (silence-by-default):
340
+ The knowledge normally left with the commit (§2, §4.1). This section is for the run where it did not: `meta.json.knowledge.status` is `later` or `failed` — postponed in §3, a `save` that failed, or an unattended run. Anything else → skip silently.
322
341
 
323
- 1. **Read the staging accumulated during the branch**: `knowledge.read_staging` (empty → what the artifacts recorded) — what `/flow-feat-design` (and other phases) already staged. Main material.
324
- 2. **Review** `03-design.md`, `05-implementation.md`, `06-review.md` for "why" findings (domain decisions, legal constraints, integrations, business motivations) **not staged at the time**. The "what" (code, paths) is NOT saved.
325
- 3. **Combine staging + new findings** into a short list. Empty or only code-derivable → do not insist.
326
- 4. 1+ relevant findings → ask the user whether to consolidate. Yes → run the consolidation of flow-core §0 (`read_staging`, then one decision and one `knowledge.save` per finding). No → do not insist.
342
+ On every re-run of this command (the one that confirms the merge included), offer it once with `AskUserQuestion`, listing the findings again from §2's steps: **Save them now** · **Not worth it** (→ `declined`, never offered again) · **Later** (stays). *Save them now* runs the consolidation of flow-core §0, then ships its files by the MR/PR's state:
343
+
344
+ - **Still open** → commit them onto this branch in the worktree and push; the MR/PR updates itself.
345
+ - **Merged** → a knowledge-only MR/PR: a fresh branch from `git.default_base` with this work's branch name, one commit, title `<TICKET> Domain knowledge from <the work's title>`, the same issue-link rule as §2 (`Part of`, never `Closes` — the issue is already done). It goes through §3's preview and §4.0's checks like any MR/PR: outward-facing, asked in every mode.
346
+
347
+ A store that writes outside the repo leaves no file to ship; then saving is the whole step.
327
348
 
328
349
  ## 5.1 Specialists created (offer)
329
350
 
330
351
  Read `meta.json.specialists[]` (flow-core §6.6). **No entry with `useful: true` and `status` unset
331
- or `"later"` → skip this section and say nothing.** It comes after §5 on purpose: the MR/PR is open,
332
- the knowledge is saved, and what is left is whether an agent this work improvised deserves a name.
352
+ or `"later"` → skip this section and say nothing.** It comes after the MR/PR on purpose: the MR/PR is open,
353
+ the knowledge shipped with it, and what is left is whether an agent this work improvised deserves a name.
333
354
 
334
355
  1. **A harness with no file-defined agents** → the section does not exist; say so in one line if
335
356
  there were useful specialists, so the brief is not mistaken for lost (it stays in `meta.json`).
@@ -377,7 +398,7 @@ exist get what this work showed they lacked.
377
398
 
378
399
  `meta.json.worktree` null → skip silently; there is nothing here that can go wrong.
379
400
 
380
- Everything above this line ran in a worktree, and several of the tools it called had no way of knowing that. A configured tool — `knowledge.save` is the first one this caught, and no key is special — is started once per session, resolves the repo from the directory it was started in, and takes no root in its call. A worktree is the same repo with another tree, so its output can land in the **main checkout**, which is standing on another branch, while the branch §4 just pushed goes out without it. Nothing in the invocation could have corrected that: flow is the only party that knows `meta.json.worktree` is set, and this is the only place that knows the push already happened.
401
+ Everything above this line ran in a worktree, and several of the tools it called had no way of knowing that. A configured tool is started once per session, resolves the repo from the directory it was started in, and takes no root in its call. A worktree is the same repo with another tree, so its output can land in the **main checkout**, which is standing on another branch, while the branch §4 just pushed goes out without it. `knowledge.save` was the first one this caught, and its writes are now moved into the worktree before the commit (flow-core §0 step 4); this check is the net for every other tool, and for a move that went wrong. Nothing in the invocation could have corrected that: flow is the only party that knows `meta.json.worktree` is set, and this is the only place that knows the push already happened.
381
402
 
382
403
  So, before the Close:
383
404
 
@@ -387,7 +408,7 @@ git -C "$(git rev-parse --path-format=absolute --git-common-dir)/.." status --po
387
408
 
388
409
  Empty → say nothing at all. Non-empty → **one line naming the paths**, and what it means in plain words: they are sitting in the main checkout, not in the branch that was pushed. Say it as a reading, never as an accusation — that checkout may have been dirty before this work started, and only the user can tell their own leftovers from what this run put there.
389
410
 
390
- Then offer once, with `AskUserQuestion` **in every autonomy mode** (it edits two trees): **carry them over** — copy the paths the user confirms into this worktree, commit onto the branch, push, and the MR/PR from §4 updates itself — or **leave them**, which is the right answer whenever what is sitting there belongs to the other branch. Either way the Close reports what was decided: a `ship` that quietly repaired two checkouts is worse than one that named the problem and left it standing.
411
+ Then offer once, with `AskUserQuestion` **in every autonomy mode** (it edits two trees): **carry them over** — copy the paths the user confirms into this worktree, take them out of the main checkout as flow-core §0 step 4 does, commit onto the branch with `git -C <worktree>` (a push launched from the main checkout's directory can be refused by a guard that sees the base branch there), push, and the MR/PR from §4 updates itself — or **leave them**, which is the right answer whenever what is sitting there belongs to the other branch. Either way the Close reports what was decided: a `ship` that quietly repaired two checkouts is worse than one that named the problem and left it standing.
391
412
 
392
413
  ## 6. Close
393
414
 
@@ -571,6 +592,7 @@ paste. Never a list here, and never a question: in `guided`/`auto` not asking is
571
592
 
572
593
  Only if `phase = "done"`:
573
594
  - Delete the candidate anchor `/flow-feat-review §1.5` left behind: `git update-ref -d refs/flow/candidate/<TICKET>`. It existed to stop the object being collected while the gate still needed it; the gate has run. No question — it is local, it was never pushed, and nothing reads it after this. Absent already → nothing to do.
595
+ - Clear this branch's staging (flow-core §0 step 7) when `meta.json.knowledge.status` is `consolidated` or `declined` and the store has that notion. No question: what it held is saved, or was refused. `later`/`failed` → leave it; §5 still owes it.
574
596
  - Ask whether to keep `.claude/work/<TICKET>/` or archive it (move to `.claude/work/_archive/`).
575
597
  - If `meta.json.worktree` is not null, offer to remove the worktree (from the main checkout) with `git worktree remove <worktree>` (`--force` only if it still has changes the user confirms discarding). Never without confirmation, never if the MR/PR is not yet merged.
576
598
 
@@ -231,13 +231,16 @@ Write `.claude/work/<TICKET>/07-validation.md`:
231
231
  failing tests on the base the way they went red on HEAD — the whole suite, three runs on each side
232
232
  for a test that is red in the suite and green on its own — and write each name, its result there,
233
233
  the run counts and the base sha under "Suite results" in `07-validation.md`. Calling a failure "pre-existing" without that run is not the
234
- exception — it is a red suite. Tests red once in HEAD's three runs, never on the base, outside the
234
+ exception — it is a red suite. **Before a test takes the exception or the flake record, its cause
235
+ is looked for** (flow-core §11, a red test outside the change): identified → it is not excused, it
236
+ becomes a step of the repair round below, named with its cause, fixed in its own commit and listed
237
+ under `## Also fixed` by `ship`. Tests red once in HEAD's three runs, never on the base, outside the
235
238
  files this diff touches, green on their own and proving no criterion are suspect flakes: when every test red in HEAD's three runs is one,
236
239
  five more whole-suite runs on HEAD decide — nothing red in them → `unattended:validate-flaky`, the
237
240
  counts under "Suite results", and the phase advances. Short of it, the red suite gets a repair round (the same row):
238
241
  the failing tests become unticked steps of this MR/PR's plan, `phase = build`, and the run
239
242
  chains into `/flow-feat-build`, then review and this phase again. Rounds go on while each lowers
240
243
  the red count, three at most; one that does not, or a third still red → `blocked`, naming the
241
- tests still red.
244
+ tests still red and, for each, what a person does next.
242
245
 
243
246
  In `guided`/`auto` this is, together with the brief in `/flow-feat-build §2`, **the only stop of the whole MR/PR** — everything between them ran without a person. It carries the **full stop header** and the body answers, in this order: what is green, what this MR/PR proves and what it does not, and what shipping it takes. Assume the user has read none of the build and review.
@@ -41,7 +41,7 @@ Read `~/.claude/flow/CORE.opencode.md` first (shared rules: `FLOW.md` step 0, mo
41
41
  2. Creating/switching a branch, or DB schema changes/migrations, if a fix requires them.
42
42
  3. **Re-triggering a pipeline or job on the remote** (CI resources; outward action).
43
43
  4. **Integrating the base branch** — any `git merge`/`git rebase` of `git.default_base` into the branch, and any history rewrite or force-push it implies (§5.C).
44
- 5. **Green-washing — NEVER, in any mode:** no rerun of a failed check hoping it passes; never disable, skip, `@skip`/`xit`, loosen a threshold, or delete a test/lint rule to force green; never resolve a conflict by blindly taking one side (`--ours`/`--theirs`, `checkout --theirs`, discarding the base's changes) — resolve by understanding both sides.
44
+ 5. **Green-washing — NEVER, in any mode:** no rerun of a failed check hoping it passes; never disable, skip, `@skip`/`xit`, loosen a threshold, or delete a test/lint rule to force green; never resolve a conflict by blindly taking one side (`--ours`/`--theirs`, `checkout --theirs`, discarding the base's changes) — resolve by understanding both sides. A fragile test rewritten to assert on the same result, as flow-core §11 allows, is not loosening it.
45
45
 
46
46
  **In `unattended`** (flow-core §2.1) — launched by `/flow-work-run` on `why = pipeline` or
47
47
  `why = conflict` — this command never touches the forge. Gate 5 holds exactly as written; the
@@ -55,8 +55,10 @@ others resolve this way:
55
55
  conflicts with `base`, which the orchestrator left in the checkout as `origin/<base>` at
56
56
  `base_sha`. That is the only blocker of the round — category C, nothing to triage. `origin/<base>`
57
57
  missing or not at `base_sha` → `blocked`: the run would merge a base nobody named.
58
- - **§3** — triage as written, recorded in `09-ci.md`. **K** (flaky / infra) → `blocked` with the
59
- evidence: the run has no rerun order, and the orchestrator owns reruns and the red-round limit.
58
+ - **§3** — triage as written, recorded in `09-ci.md`. **K** (flaky / infra) → when the round
59
+ changed no code, `blocked` with the evidence and a one-line reason starting `rerun CI: <job>[,
60
+ <job>…]` (flow-core §11): the run has no rerun order, and the orchestrator owns reruns and the
61
+ red-round limit; when the round changed code, its `publish` reruns CI anyway.
60
62
  **C** (conflict, behind base) on `why = pipeline`, and anything needing a rebase or force-push →
61
63
  `blocked`: the orchestrator brings the base in, and relaunches with `why = conflict` when it
62
64
  conflicts. A **human** blocker → `blocked`, naming who. **S** → fixed within
@@ -136,12 +138,14 @@ Categories:
136
138
  | **L — lint / style / format** | formatter or linter job red | mechanical auto-fix with `quality.style_fix` (or the repo's formatter) |
137
139
  | **T — test failure** | a unit/integration/functional/frontend test failed | **root-cause fix**: real regression → fix the code; behavior changed *on purpose* → update the test to the new contract (justified from the design) |
138
140
  | **Y — type / build / compile** | type-check (`static_analysis`) or build broke | fix the code/types |
139
- | **K — flaky / infra** | non-deterministic or CI-environment failure **not** caused by this diff (timeout, network, cache, runner) | do **not** green-wash; identify the evidence, propose a **confirmed** rerun (hard gate), and flag the flake |
141
+ | **K — flaky / infra** | non-deterministic or CI-environment failure **not** caused by this diff (timeout, network, cache, runner) **whose cause in the test or the code was looked for and not identified** (flow-core §11) | do **not** green-wash; identify the evidence, propose a **confirmed** rerun (hard gate), and flag the flake |
140
142
  | **S — quality gate / scope** | coverage threshold, security scan, a lint rule newly hitting legacy code | judgment call: fix within scope, or defer/config with justification — never touch unrelated code just to appease a gate without confirming |
141
143
  | **C — conflict / branch behind base** | the branch conflicts with `git.default_base`, or the host requires it updated before merging | integrate the base into the branch and **resolve each conflict on its merits** (§5.C) — hard gate before touching git history |
142
144
  | **H — human blocker** | draft/WIP, approvals missing, unresolved review threads, a required reviewer or check that only a person can clear | **not this command's job**: name it, say exactly what is needed and from whom, and route it (threads → `/flow-work-respond`; draft → offer to mark ready; approvals → the reviewers). Never work around it |
143
145
 
144
- **Root cause, not symptom.** Find *why* the check is red before changing anything. Never weaken what a test checks, never silence a type error with a blanket cast/ignore, never mark a real failure as flaky. A "fix" that hides the failure is not a fix — surface it.
146
+ **A test this diff did not touch is still this command's.** A red test that looks flaky is diagnosed before it is called K (flow-core §11): read its log tail and its code; a fragility identified there — it counts timer ticks, depends on order, reads another test's leftovers — or a cause in the code is **T**, fixed in this round even when it does not go red locally, in its own commit `Fix fragile test <name>: <cause>`, and the line for `## Also fixed` goes to the MR/PR description with the push (`publish-body.md` in `unattended`). Only a cause not identified stays K.
147
+
148
+ **Root cause, not symptom.** Find *why* the check is red before changing anything. Never weaken what a test checks (a flow-core §11 rewrite onto the same result is not weakening), never silence a type error with a blanket cast/ignore, never mark a real failure as flaky. A "fix" that hides the failure is not a fix — surface it.
145
149
 
146
150
  Present a **triage table**: `blocker → kind → category → probable cause (log or merge verdict) → proposed action`, **C** and **H** rows first (a conflict makes the pipeline result provisional — CI reruns on a different tree after integrating the base). In `manual`, let the user re-categorize any row (especially T-vs-K) before proceeding.
147
151
 
@@ -164,9 +168,9 @@ Only **base-integration**, **auto-fix** and **code-fix**:
164
168
 
165
169
  - **Design-invalidation first.** A test failure that shows the *design* was wrong → do not patch the test into agreement; update `03-design.md` **before** editing; if large, route back through `/flow-feat-build` / `/flow-bug-fix`.
166
170
  - **Delegate the edits** to the expert sub-agents (FLOW.md `agents`); the conductor stays on judgment. Repo conventions plus the **comment discipline** of `/flow-feat-build` — comments only for a non-obvious *why*, never a ticket ID or "for MR #N".
167
- - **Reproduce and verify locally — the tight loop.** Before pushing, re-run the failing check locally: L/style → `quality.style_fix`; T → `quality.test` (or `quality.test_one` scoped to the failing test); Y → `quality.static_analysis`. Empty command → auto-discover. Not reproducible locally (environment-only job) → say so, push and let CI re-verify (§6), stating that verification is remote.
171
+ - **Reproduce and verify locally — the tight loop.** Before pushing, re-run the failing check locally: L/style → `quality.style_fix`; T → `quality.test` (or `quality.test_one` scoped to the failing test); Y → `quality.static_analysis`. Empty command → auto-discover. Not reproducible locally (environment-only job) → say so, push and let CI re-verify (§6), stating that verification is remote. A fragile test fixed by flow-core §11 is checked with its forced reproduction when there is one, then pushed the same way.
168
172
  - **Re-run the review gate for non-trivial code-fixes.** More than a mechanical tweak → `quality.review_skill` (or built-in `code-review` if empty) on this round's diff before pushing. Pass the diagnosis as context, never as a scope exclusion (*"the cause was X"*, not *"skip X"*). High-severity findings block the push until addressed.
169
- - **Commits follow `autonomy.mode`.** After editing, **always** report a summary (files, lines, which job each edit turns green). `manual` → the user decides to commit or inspect first; do **not** `git commit` on your own. `guided`/`auto` → commit the round yourself, go straight to the §6 push gate (do not ask twice for one round). The push is a hard gate in **every** mode.
173
+ - **Commits follow `autonomy.mode`.** After editing, **always** report a summary (files, lines, which job each edit turns green). `manual` → the user decides to commit or inspect first; do **not** `git commit` on your own. `guided`/`auto` → commit the round yourself, go straight to the §6 push gate (do not ask twice for one round). A fragile-test repair (flow-core §11) is split into its own commit in every mode, and the round's summary names it as *also fixes fragile test `<name>`: <cause>*. The push is a hard gate in **every** mode.
170
174
 
171
175
  ### 5.C Integrate the base and resolve conflicts (category C)
172
176
 
@@ -99,7 +99,10 @@ back through it, and the hard gates above resolve this way:
99
99
  - **The one closing order**, after the WIP commit (flow-core §2.1): code changed this round →
100
100
  `publish` with the work's `publish-title.md` / `publish-body.md` (updated when the round changed
101
101
  what they say, and naming any thread whose reply failed) and no `--part/--of` — the MR/PR is
102
- already open (flow-core §2.1) — so the commits the replies name reach the branch; no code changed and every reply went
102
+ already open (flow-core §2.1) — so the commits the replies name reach the branch (and the push reruns CI, so a
103
+ failure nobody could explain needs nothing more); no code changed, every reply went out and a
104
+ thread carried a CI failure neither reproduced nor explained (§3) → `blocked`, its one-line reason
105
+ starting `rerun CI: <job>[, <job>…]` (flow-core §11); no code changed and every reply went
103
106
  out → `done`, the summary listing the threads answered; no code changed and a reply failed →
104
107
  `blocked`, naming those threads.
105
108
 
@@ -148,6 +151,8 @@ Categories:
148
151
  | **F — obsolete/done** | Already addressed, or no longer applies | reply pointing to where |
149
152
  | **G — data / performance objection** | The reviewer says a query is slow, unbounded, unindexed, or proposes a different query | **measure first** (§4.G), then reply with the plan |
150
153
 
154
+ **A thread that carries a CI failure** — a person pasted a failing job's log or a red test's output — is a **C** about that test, not an **A** to answer: reproduce it with `quality.test_one`; red → fix it on its merits, through flow-core §11 when the test is outside this diff. Not red here → diagnose it from the pasted log and the test's code (flow-core §11): a fragility identified (it counts timer ticks, depends on order, reads another test's leftovers) or a cause in the code → fix it in its own commit `Fix fragile test <name>: <cause>`, and the reply names that commit and the cause, and the line for `## Also fixed` goes to the MR/PR description with the push (`publish-body.md` in `unattended`). Neither → change nothing for it; the reply says it did not reproduce, that no cause was found in the test or the code, and what the person does next (*rerun CI; if it fails again, …*) — never a bare "not reproduced".
155
+
151
156
  Present a **triage table** to the user: `thread → location → category → proposed action → one-line rationale` — the map for the rest of the command. In `manual` mode, let the user re-categorize any row before proceeding.
152
157
 
153
158
  ## 4. Agree the response per thread (the debate)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-workflows",
3
- "version": "0.105.0",
3
+ "version": "0.107.0",
4
4
  "description": "Guided feat/bug workflows (start→ship), post-deploy monitoring and multi-agent code review, stack-agnostic. Each repo uses a shared FLOW.md plus optional harness overlay.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3,7 +3,7 @@
3
3
  "name": "flow",
4
4
  "displayName": "Flow — guided dev workflows",
5
5
  "description": "Guided feat/bug workflows (start→ship), post-deploy monitoring and multi-agent code review, stack-agnostic. Each repo uses a shared FLOW.md plus optional harness overlay.",
6
- "version": "0.105.0",
6
+ "version": "0.107.0",
7
7
  "author": {
8
8
  "name": "Alberto Vioque",
9
9
  "email": "mashware@gmail.com"