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-review
3
+ description: "Mandatory multi-agent code review before shipping"
4
+ ---
5
+
6
+ <!-- GENERATED by script/adapter-build.py from plugins/flow/commands/feat/review.md — do not edit; change the plugin file and run the script. -->
7
+
8
+ # `$flow-feat-review`
9
+
10
+ > **codex 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 → the subagent declared under `[agents.<name>]` in `~/.codex/config.toml`; the name comes from `agents.<role>` in `FLOW.md`, empty → do it in this context.
13
+ > - Parallel fan-out → several subagents in one response, capped at `agents.fanout_max` (empty → 4); `agents.fanout_tool` is Claude Code-only, ignore it.
14
+ > - `ScheduleWakeup` / `Monitor` / `/loop` → not available in-session: run one cycle, persist state in `monitor.md`, let the user schedule `codex exec "<command>"` with cron or Codex automations.
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>` → the `--model` flag at launch (or `/model` if your Codex version has it).
18
+ > - `knowledge.*` roles → whatever tools `FLOW.md` names there; an MCP tool keeps its name, its server is declared under `[mcp_servers.<name>]` in `config.toml` (see `config.snippet.toml`).
19
+ > - `$ARGUMENTS` → whatever the user typed after the skill name, empty if nothing — Codex substitutes nothing, so read it off their message.
20
+
21
+ Read `~/.claude/flow/CORE.codex.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`; its parallel rounds take `models.workers`.**
22
+
23
+ Mandatory review phase. **`$flow-feat-ship` cannot run without passing through here and resolving blockers.**
24
+
25
+ ## 1. Pre-flight
26
+
27
+ - Read `meta.json` and `00-summary.md`; open in full only the design's "External contracts" (`03-design.md`) and `05-implementation.md`. (flow-core §5) The diff itself is read from git.
28
+ - **A premise left open by `build` §2.1bis is an input to this review, not a note.** Every row of "Premises the change depends on" whose verdict is `unsettled` enters §6 as an **ambiguous finding** (it rests, by construction, on code outside the diff) and is named in §7 whether or not the gate opened. A premise the build could not settle and the review does not mention is one the MR/PR ships as a fact.
29
+ - Require `build` in `phases_done`. **In a multi-MR/PR work** (`meta.json.mrs` has >1 entry) require `build` in the **current `in_progress` MR/PR's** own `phases_done` (its `mrs[]` entry) — a previous MR/PR's `build` does not count. If missing, send the user to `$flow-feat-build` and stop.
30
+ - Check that `git diff` has real changes. None → warn and stop.
31
+
32
+ ## 2. Invoke the code reviews
33
+
34
+ Scope for every reviewer: the full feature work against the base branch (committed + working tree — commits are opt-in).
35
+
36
+ ### 2.0 Resolve review depth (scale to *this diff* and the risk)
37
+ Read `quality.review_depth` from `FLOW.md` (`proportional` | `full` | `light`; empty → `proportional`) and `meta.json.size`. This decides **what §2.1 launches and at which effort**. Built-in `code-review` effort ladder: **low < medium < high < xhigh < max** (lower = fewer, higher-confidence findings; higher = broader coverage, may surface uncertain ones).
38
+
39
+ **The tier is resolved against the diff in front of you, not against the size of the feature.**
40
+ `meta.json.size` describes the whole work; in a multi-MR/PR train every MR/PR inherits it, so a
41
+ 41-line third MR/PR gets reviewed as the L its feature is — the single largest source of wasted
42
+ review in this plugin. Measure the real diff (`git diff --shortstat <git.default_base>...HEAD`, plus
43
+ the working tree) and derive its own size:
44
+
45
+ | Changed lines in this diff | Diff size |
46
+ |---|---|
47
+ | ≤ 150 | XS |
48
+ | 151-600 | S |
49
+ | 601-1500 | M |
50
+ | > 1500 | L |
51
+
52
+ **Effective size = the lower of `meta.json.size` and the diff size**, and every size-gated step in
53
+ this command (§3.5, §5.5, §6) reads the effective size, not the recorded one. The diff pointing
54
+ *higher* than the recorded size is worth one line in `06-review.md` (the work may be misclassified),
55
+ not a heavier review. The **sensitive-surface bump below applies on top of the effective size and is
56
+ never scaled away** — a 12-line change to an authorization check still gets the panel.
57
+
58
+ **The threshold is visible in the artifact, because it is the one number with an incentive on it.**
59
+ A diff of 148 lines is reviewed at `medium` with no panel and closes §6's gate; one of 160 gets the
60
+ panel. When the measured diff lands **within 10% under** a threshold that changed the tier (135-150,
61
+ 541-600, 1351-1500), say so in one line of `06-review.md`, beside the effective size. It is not an
62
+ accusation and it changes no tier — it is the only place a reader can see that the review they are
63
+ holding was selected by a number, and it is what makes flow-core §9 (the diff reports the change; the
64
+ change is never shaped to fit the number) checkable after the fact rather than merely stated.
65
+
66
+ - **`full`** (any size): built-in `code-review` at **xhigh** + the project panel. Skip the tiering below.
67
+ - **`light`** (any size): built-in `code-review` (or `quality.review_skill`) **only**, at **medium** effort. No project panel, no §3 reinforcements, no §6 skeptic fan-out. The sensitive-surface bump still applies: a sensitive surface upgrades `light` to the `proportional` tier for that work.
68
+ - **`proportional`** (default), base effort by size:
69
+
70
+ | Size | Built-in `code-review` | Project panel (`review_skill`/`reviewers`) |
71
+ |---|---|---|
72
+ | XS | **medium** | do **not** launch |
73
+ | S | **high** | only if the diff touches a sensitive surface; otherwise the built-in alone is the review |
74
+ | M | **high** | full panel |
75
+ | L | **xhigh** | full panel |
76
+
77
+ - **Sensitive-surface bump** (proportional, any size): the diff touches a sensitive surface → **raise the built-in effort one tier** (medium→high→xhigh→**max**) and always run the panel. S/M on a sensitive surface → **xhigh**; **L on a sensitive surface → `max`**.
78
+
79
+ **Sensitive surface** = the generic categories — authentication/authorization, secrets/credentials, payments/billing, personal or otherwise sensitive data, a public API/contract shape, or a DB migration/schema change — **plus** every glob in `quality.sensitive_paths` from `FLOW.md`. The key is **additive**: it names what is sensitive in *this* repo and nowhere in that list (an internal event or message contract consumers depend on, a pricing or entitlement table, a consent flow, a feature-flag resolver), and a repo that declares its own surfaces never loses the ones it never thought about.
80
+
81
+ **A sensitive path is not yet a sensitive diff, and this is where the precision comes from** — not from a shorter list. The bump asks what the change *does* there, not where it lives. It applies when the diff touches **control flow, or the data that reaches a person, a charge or a stored record** — a new guard, a new `catch`, a changed condition, a changed value, a changed contract. It does **not** apply when the diff moves **observability alone**: a log level, a log channel, the text of a message, a metric, a comment. That diff gets the review its size already earned. Mixed diff → not observability-only, so it bumps. Say which of the two it was in one line; a diff demoted here is the one place a missed defect is expensive, so the line is not optional.
82
+
83
+ **Query changes do not belong here.** §3.6 already duels every query the diff adds or modifies, at every size, whatever this section resolved — routing them through the bump would buy a second opinion on prose where §3.6 buys a plan.
84
+
85
+ Record in `06-review.md` which tier and effort ran and why (e.g. "L + DB migration → built-in at `max` + panel"; "S, `src/**/Payment/**` but log level only → no bump, built-in at `high`").
86
+
87
+ ### 2.0b Resolve the agent budget (the ceiling is the command's, not the round's)
88
+ This command is the widest fan-out in the plugin: a panel, area reinforcements, a coverage sweep that
89
+ relaunches reviewers, a query duel, two blinded audits and one skeptic per ambiguous finding. Each
90
+ round respects `agents.fanout_max` and the *command* still ends up an order of magnitude over what
91
+ anyone asked for. Read `agents.budget_max` from `FLOW.md` (empty → **12**; `0` = no ceiling) and hold
92
+ every round in §2.1-§6 against it (flow-core §6): count before launching, launch what fits, report
93
+ what the cap dropped.
94
+
95
+ **Give-up order when the budget runs out** — drop from the top, never from the bottom:
96
+
97
+ 1. **§3.5 completeness sweep** — the most expensive phase and the one whose absence is easiest to state.
98
+ 2. **§6 skeptic verification** — a filter against over-reporting; without it findings ship unverified, marked as such.
99
+ 3. **§5.5 idiom audit**.
100
+ 4. **§3 area reinforcements** — the least covered elsewhere goes last.
101
+
102
+ **Never dropped for budget**: the built-in `code-review` (§2.1.1), the panel the §2.0 tier selected
103
+ (§2.1.2), the query duel (§3.6) and the blinded contract check (§5) — those four are the review. If
104
+ the budget cannot cover them, the budget is misconfigured: say so in one line and run them anyway.
105
+
106
+ **Say what the round will run on.** Most of what this command launches has no agent of its own —
107
+ the skeptics (§6), the coverage auditor (§3.5), the contract verifier (§5) — so with the fan-out
108
+ key empty they inherit this thread's model, whatever that is, fifteen at a time. Per flow-core §1:
109
+ one line before the first wide round naming the count and the fact that they inherit, and the same
110
+ fact on the artifact's `Agent models` line. Name the key (`models.workers`, then `models.agents`),
111
+ never a model.
112
+
113
+ ### 2.1 Launch and consolidate
114
+ Launch the reviewers selected in §2.0 and **consolidate their findings into a single deduplicated report**:
115
+
116
+ 1. **Built-in `code-review`** (the Claude Code one, no prefix), at the §2.0 effort. Single pass over the local diff: correctness failures + reuse/simplification/efficiency.
117
+ 2. **Project panel** (only when §2.0 selected it): read `quality.review_skill` from `FLOW.md`.
118
+ - `review_skill` set → invoke that skill with `03-design.md` as additional context. Scope: `git diff <git.default_base>...HEAD`, plus uncommitted working-tree changes.
119
+ - `review_skill` empty, `quality.reviewers` has entries → launch each agent in parallel as a panel, same context and scope.
120
+ - Both empty → step 1 already covers this pass; launch nothing more.
121
+
122
+ Launch the panel **as defined** — whole roster, no hand-picked subset, no substitutions (each member owns a category nothing else repeats). An agent that genuinely cannot run → record it in §8 `Agents launched` with the reason.
123
+
124
+ **Every brief you write here ends with the report contract of flow-core §6** — `agents.report_max_words` (empty → 250), findings only, one line each as `file:line` + what is wrong + the fix. This file's own prompts (§3.5, §4, §5.5) already carry theirs; the panel briefs are yours to write, and an uncapped one is truncated in transit and reaches you looking exactly like a reviewer that found nothing. The built-in `code-review` takes no brief — bound it with the §2.0 effort tier and hold it to the same fan-out deadline (flow-core §6): over a large diff it is the likeliest member of this round to stall before its first sentence.
125
+
126
+ When both run, deduplicate overlapping correctness/simplification findings (count each once). The `review_skill` specialists (offensive/defensive security, silent failures, architecture) are not repeated in later phases.
127
+
128
+ ### 2.2 Design truth vs design rationale (do not inherit rationalizations)
129
+ `03-design.md` goes to reviewers as context, with unequal authority:
130
+ - **Contracts and acceptance criteria are truth** — verify the code meets them.
131
+ - **Pattern/architecture decisions and their justifications** (the ADR-light "Why" column, *"respects bounded contexts"*, *"for consistency"*) are **hypotheses, not axioms** — refute them when the code tells a different story. Every "Why" is a claim to test, never a reason to stop looking.
132
+
133
+ **This applies to the briefs you write, too.** A decision already taken goes to the reviewer as **context**, never as a scope exclusion: *"X is decided — tell me what consequences it has that we have not seen"*, never *"do not report X"*.
134
+
135
+ ## 3. Targeted reinforcements
136
+
137
+ Only what §2 does **not** already cover; skipped entirely under `light` (§2.0). Same report contract as §2.1 (flow-core §6) on every brief. If the feature touches these areas, additionally launch **in parallel**:
138
+
139
+ - **Any repeated call that leaves the process** (external API, HTTP, cache, filesystem) → `agents.performance` from `FLOW.md` on the changed files; empty → skip. Have it cover what **each failed iteration** sets off downstream (publishes, enqueues, disables, logs), not just the happy path's cost. **Queries are not covered here** — §3.6 owns them.
140
+ - Workers / message queues → `agents.queues` from `FLOW.md`: no `flush()` in a loop; workers registered per the project convention (`FLOW.md` section `conventions`); empty → skip.
141
+ - Frontend → interface code changed: `agents.frontend` from `FLOW.md` for the code and `agents.testing` for the tests that came with it; either empty → skip that one.
142
+
143
+ ## 3.5. Completeness sweep (anti-abandonment, M/L only)
144
+
145
+ Counters a reviewer abandoning a large diff early. **Only if `meta.json.size` is M or L**, and only
146
+ if §2.0b's budget still covers it (it is the first phase dropped).
147
+
148
+ **It runs after §2-§3 are consolidated, never in parallel with them.** The whole phase is an audit of
149
+ *what the other reviewers covered*; launched before their findings exist, its only possible input is
150
+ the diff itself, and then it is not an auditor but one more reviewer — the most expensive of the
151
+ round, reading everything the others already read. If you are tempted to start it early to save
152
+ wall-clock, that is the tell: wait.
153
+
154
+ Loop, maximum **2 rounds**:
155
+
156
+ 1. **Worklist**: `git diff --stat <git.default_base>...HEAD` → list of changed files/areas.
157
+ 2. **Coverage map**: from the consolidated §2-§3 findings, mark which files/areas received at least one finding or were explicitly examined.
158
+ 3. **Completeness critic (1 agent, blinded and text-only)**: `Agent general-purpose` (takes `models.agents` like every other subagent here), passing **only** the full diff file list (step 1) and, per §2-§3 reviewer, one line on what it covered. **Do not** pass the detailed findings, the design, or the diff. This agent compares two lists and answers in three sentences; it opens no file, runs no `git diff`, reads no code. An agent here that is still working after a few minutes is not being thorough — it was handed the wrong job, and the fix is to kill it and re-launch with the two lists alone. Prompt:
159
+
160
+ > You are a coverage auditor for a code review. I give you (1) the list of files changed in this diff and (2) a one-line summary per reviewer of what area each one covered. Your only task: name the files or areas in list 1 that **no** reviewer in list 2 examined, and any claim a reviewer accepted as correct without verifying. **Work only from these two lists — do not open files, do not read the diff, do not inspect the repository.** Do not opine on existing findings. Output: list of concrete gaps (`file/area` + why it deserves a second look) or exactly "none". Under 150 words.
161
+
162
+ 4. **Fresh gaps named** → relaunch a targeted round **only on those files/areas**, with the applicable `quality.review_skill` reviewers and their **paths constrained to the named gaps** (a reviewer relaunched over the whole diff is the phase's failure mode, not its purpose). Cap the round at `agents.fanout_max` and at what §2.0b's budget leaves; more gaps than that → take the most consequential and record the rest as gaps. Merge and deduplicate against the consolidated findings.
163
+ 5. **Repeat 2-4** until a round returns "none" **or** 2 rounds are reached **or** the budget is spent.
164
+ 6. **No silent truncation**: gaps still flagged after 2 rounds or left by the budget → **record them literally** in the output under "Areas not covered after 2 rounds" with their reason.
165
+
166
+ Sweep findings enter the normal flow: §4, §5, §6 like any other.
167
+
168
+ ## 3.6 Data-access duel (queries are tried on their plan, not their prose)
169
+
170
+ A query's cost lives in its **execution plan** (existing indexes, column order/direction, join types and collations, real cardinality) — none of it in the diff, so no reading reviewer covers it.
171
+
172
+ **When it runs.** The diff **adds or modifies** a query — raw SQL, ORM query language, query-builder chain, repository finder, a relation traversed in a loop, an aggregate/count, a bulk write, a migration or index change, or the equivalent read against a search engine or key-value store. **Any size, XS included** (a category, not a depth tier). **Not** for renames, reformats, or a query moved without changing filter, order, bound, joins or columns — say so in one line and skip.
173
+
174
+ **How it runs.** Follow **`$flow-work-query`** over the queries in the diff: its **§2 fact sheet** (call site and frequency, filter, order **with direction**, bound and global vs per key, both sides of every join with real types and collations, heavy columns, expected cardinality with source, indexes read from the schema not the mapping); its **§3 duel** (challenger blinded to the design's rationale walking the twelve-item checklist, defence answering with plans and numbers, main agent judging); its **§4 measurement** when the schema alone cannot settle it, gated as that command gates it; its **§5 verdict** shape — one recommendation with the number behind it.
175
+
176
+ Judging rules: **no number, no win** (unresolved is recorded unresolved, never split in prose); **no dogma in either direction** ("N small queries is an N+1" and "one batched query always wins" both need a measurement); **a defect that predates the diff is declared and ticketed separately**, never used to bless the diff nor dragged into it.
177
+
178
+ **A modified query is judged against its own past, not only against its rivals.** For every query the diff *changes* (as opposed to adds), the duel carries the **base row** — the same query on `git merge-base HEAD <git.default_base>`, measured in the same sandbox with the same seed (`$flow-work-query` §4). Without it the table cannot say whether this diff made things better or worse, which is the one thing a reviewer wants from it.
179
+
180
+ Verdicts as findings: **change** = blocker, through §6; **regressed** = blocker unless `03-design.md` justifies the trade, in which case it is stated and published; **schema / follow-up** → proposed ticket in the output **and a `followups[]` entry** (flow-core §7); **unresolved** → recorded literally with the open question (as §3.5). A `change` verdict resting on a measured plan is already confirmed — no §6 skeptic.
181
+
182
+ ## 4. Over-engineering audit (fit + YAGNI)
183
+
184
+ **Second barrier against over-engineering** (the first is the challenger in `$flow-feat-design`). Independent of §2: look for what is **unnecessary**, not what is missing.
185
+
186
+ 1. **Locate every defensive mechanism in the diff**: validation, guard, retry, lock, fallback, cache, idempotency, circuit breaker, queue, flag.
187
+ 2. **Find its row** in the "Defensive mechanisms and their justification" table in `03-design.md`.
188
+ - **No row** → blocker (slipped past the design filter). Ask: what real and present scenario in the project justifies it?
189
+ - **Row with a hypothetical scenario** ("just in case", "it could happen that…", "in the future") → blocker of type "unnecessary".
190
+ 3. **Verify the scenario against the code, not paper**: can the flow reach that state? Does an upstream already prevent it? A quota/constraint already bound it? Is it redundant with something existing? If `knowledge.search` is set, query it when the scenario depends on domain rules.
191
+ 4. **Key question per piece**: *"if I remove this, what breaks in the project — today, not in a hypothetical future?"*. Honest answer "nothing that can really happen" → over-engineering finding.
192
+
193
+ "Unnecessary" findings go to Blockers with a concrete proposal: "remove X — protects against Y, which cannot happen because Z (evidence)".
194
+
195
+ ## 5. Double-blind contract verification
196
+
197
+ If `05-implementation.md` has a "Contracts to respect" section, launch an `Agent general-purpose` with a **deliberately blinded** prompt — it receives exactly two things:
198
+
199
+ > You are a contract reviewer. You must say whether the diff meets some literal contracts I give you. **You have no access to the rest of the design, the controller context, the brief, or the implementation explanations.** Only:
200
+ >
201
+ > 1. **Contracts to respect** (copied verbatim from design):
202
+ > <PASTE here the "Contracts to respect" section from `05-implementation.md` as-is, without reformatting>
203
+ >
204
+ > 2. **Diff of relevant files**: the shape constructions (JSON arrays, JsonSerializable, events, headers, routes, columns, metrics) from the changed files:
205
+ > <PASTE here only the diff hunks that touch shape construction, not the full file>
206
+ >
207
+ > Your only task: for **each contract** in block 1, tell me whether the code in block 2 produces **exactly** that shape — key by key, nesting by nesting, same case, same singular/plural. Output: table `| Contract | Matches (yes/no) | If not: what differs |`. Under 200 words. Do not rationalize mismatches ("maybe they meant X"): if it differs, say so.
208
+
209
+ Blinded because full code or design lets the agent rationalize the mismatch from nearby justifications.
210
+
211
+ Any "no" → blocker: a broken-contract finding with the concrete fix proposal.
212
+
213
+ No "Contracts to respect" (build recorded "N/A") → skip this step.
214
+
215
+ ## 5.5 Idiom / primitive audit (blind to the design's rationale)
216
+
217
+ §2-§3 check whether the code **respects the design's boundaries**, not whether the design **picked the right primitive** (a "Command" that only reads, a handler injecting the bus just to call another handler). This pass asks the fresh senior reviewer's first-read question, **blinded** to the design's prose like §5.
218
+
219
+ **When to run**: only if the diff **introduces new architectural pieces** (new classes, new wiring, new use of a stack primitive — not renames or tweaks). Then: **always on M/L**; on **S** only if it introduces such pieces or touches a sensitive surface; **skip on XS**. Launch the `agents.architecture` agent from `FLOW.md` (or `Agent general-purpose` if empty) with this self-contained brief:
220
+
221
+ > You audit the **idiom** of the new code — not its correctness, not whether it respects the design. You receive ONLY: (1) the new/changed architectural pieces of this diff (new classes, their constructor dependencies, how they are wired), and (2) the project's primitive vocabulary from its conventions — `FLOW.md` `conventions` **plus every `text` in `meta.json.conventions_candidates[]`**, which is what the user has taught during *this* work and is not in the file yet (flow-core §8). **You do NOT receive the design document or its justifications.** If a choice was rationalized in prose elsewhere, that rationale is exactly what you must not inherit — your value is asking "why does this exist?" *without* the paper answer.
222
+ >
223
+ > For each new piece, ask what a fresh senior reviewer asks on first read:
224
+ > - **Does this class do what its role/name promises?** A `Command`/`Query` doing the opposite (a command that only reads, a query that mutates); a `Service`/`Finder` that is a thin pass-through; a `Handler` with no handling logic.
225
+ > - **Why does it depend on what it depends on?** Especially: an entry-point primitive (bus, dispatcher) injected only to call *another* handler (handler-to-handler dispatch); a bus used as glue between two internal pieces instead of as an entry point; an interface whose only consumer is another handler.
226
+ > - **Is there a simpler, more honest primitive?** If the piece is a service disguised as something else, name the primitive it should be.
227
+ > - **Lost type/contract**: a return typed `mixed`/`object` patched with a `@var` docblock is a signal the wrong seam was chosen.
228
+ >
229
+ > Output: per finding, `file:line`, the smell in one line, and the honest alternative primitive. Say nothing about pieces that are idiomatic. Do not invent smells to fill space — "the new pieces are idiomatic" is a valid, good result. Under 250 words.
230
+
231
+ Findings enter the normal flow: §6, then the output. Blinded for the same reason as §5. A rule learned in `build` is therefore enforced in the review of the same MR/PR, not of the next one; a correction the user makes *here* is captured the same way (flow-core §8) and reaches `ship`.
232
+
233
+ ## 6. Adversarial finding verification (parallel fan-out, optional)
234
+
235
+ A filter against over-reporting, not a second review; narrow gate. Never runs under `light` (§2.0).
236
+
237
+ **When it runs.** All three conditions:
238
+
239
+ | Condition | Threshold |
240
+ |---|---|
241
+ | Size | the **effective size** of §2.0 is **M or L** |
242
+ | Diff | the MR/PR diff is **over 150 changed lines** |
243
+ | Findings | **≥ 4** ambiguous findings across §2-§5 |
244
+ | Budget | §2.0b's budget still covers a round (§6 is the second phase dropped) |
245
+
246
+ Read the real diff (`git diff --stat` against the target branch), not the recorded size.
247
+
248
+ When all three hold: in **`manual`**, offer it with `AskUserQuestion` ("Verify the ambiguous findings with skeptics in parallel? Discards false positives before you go fix them."). In **`guided`/`auto`, do not ask** — flow mechanics: run it and note in `06-review.md` that you did.
249
+
250
+ **What gets verified — only the ambiguous ones.** A defect visible in the diff is already confirmed. Verify only findings resting on code *outside* the diff, a runtime behaviour, or an unchecked convention. Everything else goes straight to the output.
251
+
252
+ **How wide.** Read `agents.fanout_max` from `FLOW.md` (empty → **4**), and take the lower of that and what §2.0b's budget leaves. **One skeptic per finding, in parallel, capped at that number** — more ambiguous findings than the cap: verify the most consequential ones, pass the rest through unverified, marked as such. A finding is discarded when its skeptic refutes it.
253
+
254
+ **The cap counts agents, not findings.** Handing one skeptic three related findings is fine and often better; launching one agent per finding *because each is cheap* is not — twelve `Verify Vn` agents under a cap of four is a breach of the cap, not a way to cover more ground. If the ambiguous findings do not fit, group them into `fanout_max` briefs or leave the remainder unverified and say so; never widen the round.
255
+
256
+ > You are a skeptic. This is a code review finding on the project: file `<file:line>`, problem: `<description>`, proposal: `<proposal>`. Try to REFUTE it: read the real code and say whether the problem is NOT real (refuted) or is real (stands). The burden of proof is on the finding — when the evidence is genuinely ambiguous, refute. Be concrete about why, citing what you read.
257
+
258
+ Refuted findings leave blockers/suggestions and go under "Discarded by verification" with the reason. **One skeptic, not three** — a wrongly-discarded finding stays visible in the artifact.
259
+
260
+ `agents.fanout_tool` set in `FLOW.md` → run the verification through that tool; gate, ceiling and one-skeptic rule unchanged (see `agents` in `FLOW.md` and `examples/FLOW.template.md`).
261
+
262
+ Not run for XS/S, small diffs, or fewer than 4 ambiguous findings. When skipped, say so in one line of `06-review.md` — skipped and clean are not the same result.
263
+
264
+ ## 7. Local quality gates
265
+
266
+ Read `quality.*` from `FLOW.md`. Empty → auto-discover equivalent commands (Makefile, npm/composer scripts, Gradle, dotnet, Xcode, Flutter…) and note what you use.
267
+
268
+ Launch in parallel (background if slow):
269
+ - `quality.style_fix`
270
+ - `quality.static_analysis`
271
+ - `quality.test_one` (if there are new tests, with the appropriate filter)
272
+
273
+ Collect the results.
274
+
275
+ ## 8. Output
276
+
277
+ Write `.claude/work/<TICKET>/06-review.md`. The `Cost:` line of `## Summary` is mandatory, and the stop header body shows the same cost line once — so the user sees what the review cost.
278
+
279
+ ```markdown
280
+ # Code review <TICKET>
281
+
282
+ ## Summary
283
+ - Review tier: <full | proportional | light — which reviewers ran, at what built-in effort (medium/high/xhigh/max), and why, per §2.0>
284
+ - Effective size: <diff size (N changed lines) vs `meta.json.size`, which of the two the tier used, and — when the diff pointed higher — that the work may be misclassified. When the diff landed within 10% under a tier threshold, say so here (§2.0).>
285
+ - Agent models: <the value of `models.workers`/`models.agents` when set; otherwise "inherited from this thread" — plus, when the panel ran, that agents named in `agents.<role>` kept the model their own definition sets. The values as they are, no judgement on them>
286
+ - Cost: <n>/<budget_max> subagents launched (<k> reviewers · <m> reinforcements · <s> skeptics), tier <light|proportional|full>, effort <medium|high|xhigh|max>
287
+ - Agents launched: <ran vs defined — `N/M` of the `review_skill`/`reviewers` roster, naming any that did not run (with the reason) and any substitution; "built-in only" if §2.0 selected no panel>
288
+ - Completeness rounds (M/L): N
289
+ - Critical findings (block ship): N
290
+ - Suggestion findings: M
291
+
292
+ ## Areas not covered after 2 rounds
293
+ <only if §3.5 still had gaps after exhausting the cap; literal list with reason, or "none">
294
+
295
+ ## Skipped for budget
296
+ <the phases §2.0b's give-up order dropped because the budget ran out, one line each with what was not looked at, or "none">
297
+
298
+ ## Data-access duel
299
+ <one row per query added or modified by the diff, per §3.6; "no queries touched" if none, or "renames only" when the change did not alter filter/order/bound/joins/columns>
300
+
301
+ | Query (file:line) | New/mod | Bound | Index used / plan | Rows read → returned | vs base | Verdict | Evidence |
302
+ |---|---|---|---|---|---|---|---|
303
+ | `FooRepository::findBar()` | modified | per key, 15 | `barIdx` (a,b) backward scan | 750 → 162 | 41k → 750 read, 8–9 ms vs 120–131 ms | ✅ ok, improved | plan, 3 runs |
304
+ | `BazRepository::latest()` | new | none | full scan, order not indexed | 63k → 15 | — (new) | ❌ change | plan |
305
+ | `QuxRepository::search()` | modified | per key, 50 | same index, extra join | 900 → 50 | 11–14 ms vs 10–13 ms | ✅ ok, no measurable change | plan, 3 runs |
306
+
307
+ - Measured: <how — realistic data set / dev database / schema only / not measured, and why>
308
+ - Unresolved: <the specific question left open, or "none">
309
+ - Schema / follow-up: <predating defects and schema-level fixes, with the proposed ticket, or "none">
310
+
311
+ ## Double-blind contract verification
312
+ - Contracts compared: N
313
+ - Mismatches: <list or "none">
314
+
315
+ ## Over-engineering (fit + YAGNI)
316
+ - Defensive mechanisms in diff: <list>
317
+ - Without justification in `03-design.md` or with hypothetical scenario: <list, or "none">
318
+ - Proposed trimming: <what to remove and why, or "nothing to remove">
319
+
320
+ ## Discarded by adversarial verification
321
+ <only if §6 was run; list of refuted findings with reason, or "not applicable">
322
+ <if the `fanout_max` cap left ambiguous findings unverified, list them here as "unverified (cap)">
323
+ <if §6 did not run, one line saying which condition did not hold — size, diff size, or count>
324
+
325
+ ## Blockers (must-fix)
326
+ 1. [file:line] description + concrete proposal
327
+
328
+ ## Suggestions (nice-to-have)
329
+ 1. [file:line] description
330
+
331
+ ## Quality gates
332
+ - style_fix: ✅ / ❌
333
+ - static_analysis: ✅ / ❌
334
+ - modified tests: ✅ / ❌
335
+
336
+ ## Next step
337
+ <if there are blockers: "resolve, then another review round">
338
+ <if none: "validate">
339
+ ```
340
+
341
+ ## 9. Close
342
+
343
+ - Blockers → **do not advance `phase`**. Leave `phase = "build"`; the user resolves them.
344
+ - No blockers → `phase = "review"`, add to `phases_done`. **In a multi-MR/PR work**, also add `review` to the current `in_progress` MR/PR's own `phases_done` (its `mrs[]` entry) — `$flow-feat-ship §1` gates on it per MR/PR.
345
+ - **Record *what* you reviewed**, in the same write: `reviewed_sha` = `git rev-parse HEAD`, work-level and — in a multi-MR/PR work — in this MR/PR's `mrs[]` entry too. `phases_done` says a review *happened*; the sha says which tree, and `$flow-feat-ship §1` compares it before pushing. Write it whenever the phase advances, never when it does not: a review that ended in blockers reviewed nothing that stands.
346
+ - **Stage what the review taught** (`knowledge.stage` set; silence by default). Review is where a project teaches the most and, until now, the one phase that never staged — a work with three review rounds and seventeen blockers produced zero knowledge cards because nothing asked for them while they were in context. Candidates are findings about the **domain or the codebase's real behaviour**, not about this diff: a library that does other than its name says, a test disguise that kept the suite green over a live defect, a module rule the reviewers had to cite from its own prose, a measurement. A blocker fixed here is not knowledge; *why it was written wrong* may be. Same evidence rule as `$flow-feat-design` §8 — one line of evidence per finding or it is not staged. One call per finding, one line to the user («Staged N finding(s) for `ship`»). Never `knowledge.save` here.
347
+ - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5).
348
+ - **Configuration this phase earned the right to ask about** (flow-core §0, `manual` only, at most one key per work, as an extra option on this same stop — never a question of its own): a role the panel had to improvise on an M/L or sensitive diff → `agents.<role>`; a `Cost:` line that went over `agents.budget_max` → `quality.review_depth`. In `guided`/`auto` neither is asked: the default is taken and recorded in `meta.json.defaults_used[]`.
349
+ - Report findings and next step **following the stop header** (flow-core §3); include the `Cost:` line once. Body: the findings that **survived** verification and what you did with each — a blocker, an applied fix, a rejection with its reason. Corrections to the reviewers' own reports go to `06-review.md`, not here.
350
+ - **Autonomy handoff.** Only when there are **no blockers and no unresolved high-severity findings** — with any of those, stop in every mode (hard gate). Clean: in `manual`, propose `$flow-feat-validate` with a single `AskUserQuestion` and invoke it on confirmation; in `guided`/`auto`, **chain into `$flow-feat-validate` automatically** in this same turn. Never chain into `$flow-feat-ship` from here — ship is reached through `validate`.