@garygentry/feature-forge 0.2.14 → 0.3.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 (227) hide show
  1. package/README.md +6 -3
  2. package/adapters/GENERATION-REPORT.md +20 -0
  3. package/adapters/claude/.feature-forge-bundle.json +1 -1
  4. package/adapters/claude/references/forge-config-schema.json +2 -2
  5. package/adapters/claude/scripts/forge-root.sh +47 -3
  6. package/adapters/claude/scripts/forge-session.py +30 -8
  7. package/adapters/claude/skills/forge-4-backlog/references/forge-config-schema.json +2 -2
  8. package/adapters/claude/skills/forge-5-loop/references/forge-config-schema.json +2 -2
  9. package/adapters/claude/skills/forge-guide/references/forge-config-schema.json +2 -2
  10. package/adapters/codex/.feature-forge-bundle.json +1 -1
  11. package/adapters/codex/references/forge-config-schema.json +2 -2
  12. package/adapters/codex/scripts/forge-root.sh +47 -3
  13. package/adapters/codex/scripts/forge-session.py +30 -8
  14. package/adapters/codex/skills/forge-4-backlog/references/forge-config-schema.json +2 -2
  15. package/adapters/codex/skills/forge-5-loop/references/forge-config-schema.json +2 -2
  16. package/adapters/codex/skills/forge-guide/references/forge-config-schema.json +2 -2
  17. package/adapters/copilot/.feature-forge-bundle.json +1 -1
  18. package/adapters/copilot/references/forge-config-schema.json +2 -2
  19. package/adapters/copilot/scripts/forge-root.sh +47 -3
  20. package/adapters/copilot/scripts/forge-session.py +30 -8
  21. package/adapters/copilot/skills/forge-4-backlog/references/forge-config-schema.json +2 -2
  22. package/adapters/copilot/skills/forge-5-loop/references/forge-config-schema.json +2 -2
  23. package/adapters/copilot/skills/forge-guide/references/forge-config-schema.json +2 -2
  24. package/adapters/cursor/.feature-forge-bundle.json +1 -1
  25. package/adapters/cursor/references/forge-config-schema.json +2 -2
  26. package/adapters/cursor/scripts/forge-root.sh +47 -3
  27. package/adapters/cursor/scripts/forge-session.py +30 -8
  28. package/adapters/cursor/skills/forge-4-backlog/references/forge-config-schema.json +2 -2
  29. package/adapters/cursor/skills/forge-5-loop/references/forge-config-schema.json +2 -2
  30. package/adapters/cursor/skills/forge-guide/references/forge-config-schema.json +2 -2
  31. package/adapters/gemini/.feature-forge-bundle.json +1 -1
  32. package/adapters/gemini/gemini-extension.json +1 -1
  33. package/adapters/gemini/references/forge-config-schema.json +2 -2
  34. package/adapters/gemini/scripts/forge-root.sh +47 -3
  35. package/adapters/gemini/scripts/forge-session.py +30 -8
  36. package/adapters/gemini/skills/forge-4-backlog/references/forge-config-schema.json +2 -2
  37. package/adapters/gemini/skills/forge-5-loop/references/forge-config-schema.json +2 -2
  38. package/adapters/gemini/skills/forge-guide/references/forge-config-schema.json +2 -2
  39. package/adapters/pi/.feature-forge-bundle.json +6 -0
  40. package/adapters/pi/agents/forge-researcher.md +139 -0
  41. package/adapters/pi/agents/forge-spec-writer.md +116 -0
  42. package/adapters/pi/agents/forge-verifier.md +126 -0
  43. package/adapters/pi/extensions/ask-user-question/LICENSE +21 -0
  44. package/adapters/pi/extensions/ask-user-question/README.md +91 -0
  45. package/adapters/pi/extensions/ask-user-question/ask-user-question.ts +298 -0
  46. package/adapters/pi/extensions/ask-user-question/config.ts +78 -0
  47. package/adapters/pi/extensions/ask-user-question/events.ts +57 -0
  48. package/adapters/pi/extensions/ask-user-question/index.ts +61 -0
  49. package/adapters/pi/extensions/ask-user-question/locales/de.json +27 -0
  50. package/adapters/pi/extensions/ask-user-question/locales/en.json +27 -0
  51. package/adapters/pi/extensions/ask-user-question/locales/es.json +27 -0
  52. package/adapters/pi/extensions/ask-user-question/locales/fr.json +27 -0
  53. package/adapters/pi/extensions/ask-user-question/locales/pt-BR.json +27 -0
  54. package/adapters/pi/extensions/ask-user-question/locales/pt.json +27 -0
  55. package/adapters/pi/extensions/ask-user-question/locales/ru.json +27 -0
  56. package/adapters/pi/extensions/ask-user-question/locales/uk.json +27 -0
  57. package/adapters/pi/extensions/ask-user-question/locales/zh.json +29 -0
  58. package/adapters/pi/extensions/ask-user-question/reconcile.ts +49 -0
  59. package/adapters/pi/extensions/ask-user-question/rpc-fallback.ts +168 -0
  60. package/adapters/pi/extensions/ask-user-question/state/build-questionnaire.ts +302 -0
  61. package/adapters/pi/extensions/ask-user-question/state/i18n-bridge.ts +53 -0
  62. package/adapters/pi/extensions/ask-user-question/state/key-router.ts +277 -0
  63. package/adapters/pi/extensions/ask-user-question/state/questionnaire-session.ts +234 -0
  64. package/adapters/pi/extensions/ask-user-question/state/row-intent.ts +145 -0
  65. package/adapters/pi/extensions/ask-user-question/state/selectors/contract.ts +26 -0
  66. package/adapters/pi/extensions/ask-user-question/state/selectors/derivations.ts +42 -0
  67. package/adapters/pi/extensions/ask-user-question/state/selectors/focus.ts +19 -0
  68. package/adapters/pi/extensions/ask-user-question/state/selectors/projections.ts +101 -0
  69. package/adapters/pi/extensions/ask-user-question/state/state-reducer.ts +292 -0
  70. package/adapters/pi/extensions/ask-user-question/state/state.ts +55 -0
  71. package/adapters/pi/extensions/ask-user-question/tool/format-answer.ts +31 -0
  72. package/adapters/pi/extensions/ask-user-question/tool/response-envelope.ts +49 -0
  73. package/adapters/pi/extensions/ask-user-question/tool/types.ts +147 -0
  74. package/adapters/pi/extensions/ask-user-question/tool/validate-questionnaire.ts +58 -0
  75. package/adapters/pi/extensions/ask-user-question/vendor-config-shim.ts +65 -0
  76. package/adapters/pi/extensions/ask-user-question/view/component-binding.ts +47 -0
  77. package/adapters/pi/extensions/ask-user-question/view/components/inline-input.ts +98 -0
  78. package/adapters/pi/extensions/ask-user-question/view/components/multi-select-view.ts +193 -0
  79. package/adapters/pi/extensions/ask-user-question/view/components/option-list-view.ts +70 -0
  80. package/adapters/pi/extensions/ask-user-question/view/components/preview/markdown-content-cache.ts +79 -0
  81. package/adapters/pi/extensions/ask-user-question/view/components/preview/preview-block-renderer.ts +111 -0
  82. package/adapters/pi/extensions/ask-user-question/view/components/preview/preview-box-renderer.ts +88 -0
  83. package/adapters/pi/extensions/ask-user-question/view/components/preview/preview-layout-decider.ts +202 -0
  84. package/adapters/pi/extensions/ask-user-question/view/components/preview/preview-pane.ts +228 -0
  85. package/adapters/pi/extensions/ask-user-question/view/components/submit-picker.ts +67 -0
  86. package/adapters/pi/extensions/ask-user-question/view/components/tab-bar.ts +59 -0
  87. package/adapters/pi/extensions/ask-user-question/view/components/wrapping-select.ts +293 -0
  88. package/adapters/pi/extensions/ask-user-question/view/dialog-builder.ts +224 -0
  89. package/adapters/pi/extensions/ask-user-question/view/props-adapter.ts +125 -0
  90. package/adapters/pi/extensions/ask-user-question/view/stateful-view.ts +26 -0
  91. package/adapters/pi/extensions/ask-user-question/view/tab-components.ts +18 -0
  92. package/adapters/pi/extensions/ask-user-question/view/tab-content-strategy.ts +252 -0
  93. package/adapters/pi/package.json +26 -0
  94. package/adapters/pi/references/epic-manifest-schema.json +125 -0
  95. package/adapters/pi/references/forge-config-schema.json +236 -0
  96. package/adapters/pi/references/pipeline-state-schema.json +191 -0
  97. package/adapters/pi/references/portable-root.md +71 -0
  98. package/adapters/pi/references/process-overview.md +143 -0
  99. package/adapters/pi/references/ralph-loop-contract.md +221 -0
  100. package/adapters/pi/references/shared-conventions.md +295 -0
  101. package/adapters/pi/references/skill-frontmatter.schema.json +17 -0
  102. package/adapters/pi/references/stack-resolution.md +54 -0
  103. package/adapters/pi/references/stacks/_generic.md +111 -0
  104. package/adapters/pi/references/stacks/go.md +157 -0
  105. package/adapters/pi/references/stacks/python.md +184 -0
  106. package/adapters/pi/references/stacks/rust.md +170 -0
  107. package/adapters/pi/references/stacks/typescript.md +134 -0
  108. package/adapters/pi/references/stage-exit-protocol.md +258 -0
  109. package/adapters/pi/references/templates/specs-hygiene/AGENTS.md +32 -0
  110. package/adapters/pi/references/templates/specs-hygiene/CLAUDE.md +31 -0
  111. package/adapters/pi/references/vendor-construct-inventory.md +50 -0
  112. package/adapters/pi/scripts/epic-manifest.py +1694 -0
  113. package/adapters/pi/scripts/forge-bootstrap.py +1070 -0
  114. package/adapters/pi/scripts/forge-init.sh +58 -0
  115. package/adapters/pi/scripts/forge-root.sh +179 -0
  116. package/adapters/pi/scripts/forge-session.py +1888 -0
  117. package/adapters/pi/scripts/validate-traceability.py +150 -0
  118. package/adapters/pi/skills/forge/SKILL.md +243 -0
  119. package/adapters/pi/skills/forge/references/pipeline-state-schema.json +191 -0
  120. package/adapters/pi/skills/forge/references/process-overview.md +143 -0
  121. package/adapters/pi/skills/forge/references/shared-conventions.md +295 -0
  122. package/adapters/pi/skills/forge/references/stage-exit-protocol.md +258 -0
  123. package/adapters/pi/skills/forge-0-epic/SKILL.md +308 -0
  124. package/adapters/pi/skills/forge-0-epic/references/edit-mode.md +266 -0
  125. package/adapters/pi/skills/forge-0-epic/references/epic-manifest-subcommands.md +75 -0
  126. package/adapters/pi/skills/forge-0-epic/references/pipeline-state-schema.json +191 -0
  127. package/adapters/pi/skills/forge-0-epic/references/portable-root.md +71 -0
  128. package/adapters/pi/skills/forge-0-epic/references/shared-conventions.md +295 -0
  129. package/adapters/pi/skills/forge-0-epic/references/stage-exit-protocol.md +258 -0
  130. package/adapters/pi/skills/forge-1-prd/SKILL.md +164 -0
  131. package/adapters/pi/skills/forge-1-prd/references/pipeline-state-schema.json +191 -0
  132. package/adapters/pi/skills/forge-1-prd/references/prd-template.md +106 -0
  133. package/adapters/pi/skills/forge-1-prd/references/shared-conventions.md +295 -0
  134. package/adapters/pi/skills/forge-1-prd/references/stage-exit-protocol.md +258 -0
  135. package/adapters/pi/skills/forge-2-tech/SKILL.md +225 -0
  136. package/adapters/pi/skills/forge-2-tech/references/pipeline-state-schema.json +191 -0
  137. package/adapters/pi/skills/forge-2-tech/references/shared-conventions.md +295 -0
  138. package/adapters/pi/skills/forge-2-tech/references/stack-discovery-checklist.md +95 -0
  139. package/adapters/pi/skills/forge-2-tech/references/stack-resolution.md +54 -0
  140. package/adapters/pi/skills/forge-2-tech/references/stacks/_generic.md +111 -0
  141. package/adapters/pi/skills/forge-2-tech/references/stacks/go.md +157 -0
  142. package/adapters/pi/skills/forge-2-tech/references/stacks/python.md +184 -0
  143. package/adapters/pi/skills/forge-2-tech/references/stacks/rust.md +170 -0
  144. package/adapters/pi/skills/forge-2-tech/references/stacks/typescript.md +134 -0
  145. package/adapters/pi/skills/forge-2-tech/references/stage-exit-protocol.md +258 -0
  146. package/adapters/pi/skills/forge-3-specs/SKILL.md +178 -0
  147. package/adapters/pi/skills/forge-3-specs/references/pipeline-state-schema.json +191 -0
  148. package/adapters/pi/skills/forge-3-specs/references/shared-conventions.md +295 -0
  149. package/adapters/pi/skills/forge-3-specs/references/spec-archetypes.md +106 -0
  150. package/adapters/pi/skills/forge-3-specs/references/spec-examples.md +71 -0
  151. package/adapters/pi/skills/forge-3-specs/references/stacks/_generic.md +111 -0
  152. package/adapters/pi/skills/forge-3-specs/references/stacks/go.md +157 -0
  153. package/adapters/pi/skills/forge-3-specs/references/stacks/python.md +184 -0
  154. package/adapters/pi/skills/forge-3-specs/references/stacks/rust.md +170 -0
  155. package/adapters/pi/skills/forge-3-specs/references/stacks/typescript.md +134 -0
  156. package/adapters/pi/skills/forge-3-specs/references/stage-exit-protocol.md +258 -0
  157. package/adapters/pi/skills/forge-4-backlog/SKILL.md +175 -0
  158. package/adapters/pi/skills/forge-4-backlog/references/forge-config-schema.json +236 -0
  159. package/adapters/pi/skills/forge-4-backlog/references/pipeline-state-schema.json +191 -0
  160. package/adapters/pi/skills/forge-4-backlog/references/shared-conventions.md +295 -0
  161. package/adapters/pi/skills/forge-4-backlog/references/stage-exit-protocol.md +258 -0
  162. package/adapters/pi/skills/forge-5-loop/SKILL.md +314 -0
  163. package/adapters/pi/skills/forge-5-loop/references/forge-config-schema.json +236 -0
  164. package/adapters/pi/skills/forge-5-loop/references/ralph-loop-contract.md +221 -0
  165. package/adapters/pi/skills/forge-5-loop/references/result-reporting.md +85 -0
  166. package/adapters/pi/skills/forge-5-loop/references/runner-contract.md +341 -0
  167. package/adapters/pi/skills/forge-5-loop/references/shared-conventions.md +295 -0
  168. package/adapters/pi/skills/forge-5-loop/references/stage-exit-protocol.md +258 -0
  169. package/adapters/pi/skills/forge-6-docs/SKILL.md +202 -0
  170. package/adapters/pi/skills/forge-6-docs/references/doc-conventions.md +126 -0
  171. package/adapters/pi/skills/forge-6-docs/references/pipeline-state-schema.json +191 -0
  172. package/adapters/pi/skills/forge-6-docs/references/shared-conventions.md +295 -0
  173. package/adapters/pi/skills/forge-bootstrap/SKILL.md +250 -0
  174. package/adapters/pi/skills/forge-bootstrap/references/templates/ci/github-actions.yml +12 -0
  175. package/adapters/pi/skills/forge-bootstrap/references/templates/generic/run.sh +3 -0
  176. package/adapters/pi/skills/forge-bootstrap/references/templates/generic/test.sh +13 -0
  177. package/adapters/pi/skills/forge-bootstrap/references/templates/go/go.mod +3 -0
  178. package/adapters/pi/skills/forge-bootstrap/references/templates/go/main.go +12 -0
  179. package/adapters/pi/skills/forge-bootstrap/references/templates/go/main_test.go +11 -0
  180. package/adapters/pi/skills/forge-bootstrap/references/templates/hygiene/AGENTS.md +35 -0
  181. package/adapters/pi/skills/forge-bootstrap/references/templates/hygiene/CLAUDE.md +36 -0
  182. package/adapters/pi/skills/forge-bootstrap/references/templates/hygiene/README.md +11 -0
  183. package/adapters/pi/skills/forge-bootstrap/references/templates/licenses/Apache-2.0/LICENSE +198 -0
  184. package/adapters/pi/skills/forge-bootstrap/references/templates/licenses/MIT/LICENSE +21 -0
  185. package/adapters/pi/skills/forge-bootstrap/references/templates/python/pyproject.toml +24 -0
  186. package/adapters/pi/skills/forge-bootstrap/references/templates/python/src/{{PKG}}/__init__.py +5 -0
  187. package/adapters/pi/skills/forge-bootstrap/references/templates/python/src/{{PKG}}/main.py +13 -0
  188. package/adapters/pi/skills/forge-bootstrap/references/templates/python/tests/test_smoke.py +8 -0
  189. package/adapters/pi/skills/forge-bootstrap/references/templates/rust/Cargo.toml +15 -0
  190. package/adapters/pi/skills/forge-bootstrap/references/templates/rust/src/lib.rs +7 -0
  191. package/adapters/pi/skills/forge-bootstrap/references/templates/rust/src/main.rs +5 -0
  192. package/adapters/pi/skills/forge-bootstrap/references/templates/rust/tests/smoke.rs +6 -0
  193. package/adapters/pi/skills/forge-bootstrap/references/templates/typescript/package.json +15 -0
  194. package/adapters/pi/skills/forge-bootstrap/references/templates/typescript/src/index.ts +4 -0
  195. package/adapters/pi/skills/forge-bootstrap/references/templates/typescript/test/smoke.test.ts +6 -0
  196. package/adapters/pi/skills/forge-bootstrap/references/templates/typescript/tsconfig.json +14 -0
  197. package/adapters/pi/skills/forge-fix/SKILL.md +98 -0
  198. package/adapters/pi/skills/forge-fix/references/shared-conventions.md +295 -0
  199. package/adapters/pi/skills/forge-fix/references/stage-exit-protocol.md +258 -0
  200. package/adapters/pi/skills/forge-guide/SKILL.md +192 -0
  201. package/adapters/pi/skills/forge-guide/references/forge-config-schema.json +236 -0
  202. package/adapters/pi/skills/forge-guide/references/process-overview.md +143 -0
  203. package/adapters/pi/skills/forge-guide/references/ralph-loop-contract.md +221 -0
  204. package/adapters/pi/skills/forge-guide/references/shared-conventions.md +295 -0
  205. package/adapters/pi/skills/forge-guide/references/stack-resolution.md +54 -0
  206. package/adapters/pi/skills/forge-guide/references/stacks/_generic.md +111 -0
  207. package/adapters/pi/skills/forge-guide/references/stacks/go.md +157 -0
  208. package/adapters/pi/skills/forge-guide/references/stacks/python.md +184 -0
  209. package/adapters/pi/skills/forge-guide/references/stacks/rust.md +170 -0
  210. package/adapters/pi/skills/forge-guide/references/stacks/typescript.md +134 -0
  211. package/adapters/pi/skills/forge-init/SKILL.md +72 -0
  212. package/adapters/pi/skills/forge-verify/SKILL.md +273 -0
  213. package/adapters/pi/skills/forge-verify/references/pipeline-state-schema.json +191 -0
  214. package/adapters/pi/skills/forge-verify/references/shared-conventions.md +295 -0
  215. package/adapters/pi/skills/forge-verify/references/verification-checklists.md +477 -0
  216. package/dist/agent-targets.d.ts +1 -1
  217. package/dist/agent-targets.js +23 -3
  218. package/dist/detect.d.ts +1 -1
  219. package/dist/detect.js +2 -1
  220. package/dist/manifest.d.ts +1 -1
  221. package/dist/manifest.js +2 -2
  222. package/dist/placements.js +5 -1
  223. package/dist/rauf.d.ts +4 -4
  224. package/dist/rauf.js +3 -3
  225. package/dist/types.d.ts +31 -6
  226. package/dist/types.js +6 -3
  227. package/package.json +14 -3
@@ -0,0 +1,258 @@
1
+ # Stage Exit Protocol
2
+
3
+ The single source of truth for how every forge **authoring** stage closes. It
4
+ replaces the old ad-hoc "Next steps:" bullet lists with one fixed, correctly-ordered
5
+ sequence: **verify (if missing or stale) → `/clear` → run the next command.**
6
+
7
+ Two principles this protocol encodes (do not relitigate — they are locked product
8
+ decisions):
9
+
10
+ 1. **Clearing is recommended on its own merits at every stage boundary** — a clean
11
+ start for the next stage — *not* as a proxy for a full context window. Window
12
+ fullness only changes *how emphatically* the clear is recommended, never *whether*
13
+ it is.
14
+ 2. **Verify happens before the clear, never after** — in the authoring session, whether
15
+ manual **or** auto. Verify's clean-room subagent is dispatched from the *current*
16
+ session, so the findings digest and any fix decision land where the context to act on
17
+ them still exists. This holds for auto-verify too: the stage skill dispatches the
18
+ clean-room verify (and any autoFix) at stage end, in-session, before the exit — it is
19
+ **not** deferred to the navigator, which runs *after* the `/clear` with none of the
20
+ authoring context. Clearing first throws that context away.
21
+
22
+ ## How this file is used
23
+
24
+ The five authoring stages (`forge-0-epic` … `forge-4-backlog`) close with the
25
+ **Scripted Stage Exit**: a short stamped block (below) that runs
26
+ `forge-session.py stage-exit`, obeys the DIRECTIVES it prints per the **directive
27
+ contract** in this file, and prints the script-emitted NEXT-STEPS block verbatim as the
28
+ absolute last output. All the conditional logic the old prose blocks asked the model to
29
+ compute (effective auto-verify, freshness collapse, gate selection, host wording) now
30
+ lives in the script, deterministically; only genuinely interactive work (clean-room
31
+ subagent dispatch, `AskUserQuestion` gates) remains prose — specified once here, not
32
+ per stage.
33
+
34
+ The loop (`forge-5-loop`) keeps its bespoke exits: it stamps the **standard block**
35
+ (step-6 epic-member handoff) and the **warm variant** (all-done closing) below,
36
+ verbatim. `forge-6-docs` is **terminal** — it stamps no exit block.
37
+
38
+ A drift-guard test (`tests/test_stage_exit_protocol.py`) asserts each stamp site still
39
+ contains its block, so an edit here must be mirrored into every stamp site (and
40
+ vice-versa).
41
+
42
+ ## Stamp sites
43
+
44
+ | Stamp site | Block |
45
+ |---|---|
46
+ | `forge-0-epic` … `forge-4-backlog` | scripted-stage-exit stamp |
47
+ | `forge-5-loop` (step-6 epic-member handoff) | standard |
48
+ | `forge-5-loop` (all-done closing → docs) | warm |
49
+
50
+ The scripted stamp fills one build-time slot, `{stage-exit-args}` — the per-stage
51
+ argument list (e.g. `--feature "{feature}" --stage forge-2-tech`; the epic stage passes
52
+ `--feature "{epic}" --stage forge-0-epic --next-feature "{first-actionable-feature}"`).
53
+ `{feature}` / `{epic}` / `{specsDir}` / `{first-actionable-feature}` remain runtime
54
+ placeholders the skill resolves before running the command, exactly as elsewhere.
55
+
56
+ <!-- BEGIN: scripted-stage-exit-stamp -->
57
+ **Close this stage with the Scripted Stage Exit** (contract: `references/stage-exit-protocol.md`; do not improvise a "Next steps" list). Run:
58
+
59
+ ```bash
60
+ R="$(bash -c 'for d in "${CLAUDE_PLUGIN_ROOT:-}" "$HOME"/.claude/skills/feature-forge "$HOME"/.claude/plugins/cache/*/feature-forge/* "$HOME"/.claude/plugins/*/feature-forge "$HOME"/.agents/skills/feature-forge ./.agents/skills/feature-forge; do [ -x "$d/scripts/forge-root.sh" ] && exec "$d/scripts/forge-root.sh"; done')"
61
+ [ -n "$R" ] || { echo "feature-forge: cannot locate plugin root" >&2; exit 1; }
62
+ python3 "$R/scripts/forge-session.py" stage-exit {stage-exit-args} --specs-dir "{specsDir}" --host claude
63
+ ```
64
+
65
+ Obey the DIRECTIVES it prints, in order, per the directive contract: `runInStageVerify: true` → dispatch the in-stage clean-room verify now (honoring `autoFixEligible`); `verifyGate: "standard"` → present the Standard Verify Gate; `verifyGate: "manual-print"` → print the `verifyCommand` for the user; non-empty `invalidAutoVerifyKeys` → print a one-line warning. Then **print the NEXT-STEPS block verbatim as your absolute last output — nothing after its sentinel line.**
66
+ <!-- END: scripted-stage-exit-stamp -->
67
+
68
+ ## Directive contract
69
+
70
+ `stage-exit` emits a DIRECTIVES object and a NEXT-STEPS block. The skill executes the
71
+ directives **in this order**; the script has already computed every conditional, so a
72
+ directive is an instruction, not a question to re-derive.
73
+
74
+ ### `invalidAutoVerifyKeys` (non-empty)
75
+
76
+ Print a one-line warning first (e.g. "⚠️ forge.config.json `autoVerifyStages` has
77
+ unknown keys: … — they are ignored; fix the typo").
78
+
79
+ ### `runInStageVerify: true` — in-stage auto-verify {stageNoun}
80
+
81
+ Auto-verify is effective for this stage and verification is outstanding — verify **now,
82
+ in this session** (principle #2 applied to auto-verify: the digest and any fix decision
83
+ land here, where the authoring context still exists — not deferred to a post-`/clear`
84
+ navigator):
85
+
86
+ 1. **Clean-room verify (require-clean).** Dispatch the clean-room `forge-verifier`
87
+ subagent from this session in require-clean mode — the same path the navigator uses
88
+ (`skills/forge-verify/SKILL.md`). Dispatch it **synchronously and await its digest
89
+ inline** — do **not** run it in the background or announce it as "still running";
90
+ the digest and any fix decision must land in this session. It inherits none of this
91
+ session's context, so no `/clear` is needed and only a compact digest returns.
92
+ **Clean-room unavailable** (no `Agent` tool, `forge-verifier` not dispatchable) **or
93
+ a non-answer returned** (the verifier returned a placeholder / "still running" /
94
+ delegation message instead of a findings block): do **not** run inline and do **not**
95
+ silently accept the non-answer as a pass — leave verify **pending** so the navigator
96
+ catch-up fires on a later Claude-host `/skill:forge`, print the
97
+ `verifyCommand` for the user to run, and continue to the NEXT-STEPS block.
98
+ 2. **Verify passed / no findings** → the fresh verify state is recorded by the
99
+ clean-room run; continue to the NEXT-STEPS block.
100
+ 3. **Verify found findings** →
101
+ - **`autoFixEligible: true` AND the findings document has zero unresolved decision
102
+ points** → chain `feature-forge:forge-fix` in-session (it owns its own commit +
103
+ step tracking), then run a **mandatory re-verify** in require-clean mode. Continue
104
+ to the NEXT-STEPS block only if the re-verify passes. On any precondition miss, a
105
+ forge-fix early stop, or a red re-verify, fall through to the digest gate below —
106
+ never a silent partial mutation. (`autoFixEligible` already folds in the config
107
+ `autoFix` flag and the clean-tree precondition; a dirty tree or
108
+ `gitCommitAfterStage: false` arrives here as `false`.)
109
+ - **`autoFixEligible: false`, or unresolved decision points** → surface a **compact
110
+ findings digest** as text, then present the gate via `AskUserQuestion`: **Run
111
+ `forge-fix` now** *(recommended — you are in-context and the digest is right
112
+ here)* / **Clear + advance anyway** (leave the findings for later) / **Stop
113
+ here**. Do **not** hard-stop and do **not** silently walk past. Act on the choice,
114
+ then continue to the NEXT-STEPS block.
115
+
116
+ ### `verifyGate: "standard"` — the Standard Verify Gate
117
+
118
+ Auto-verify is off for this stage and verification is outstanding (`verifyState` is
119
+ `never`, `stale`, or `failing`). Verify **now, before clearing**, using
120
+ `AskUserQuestion` with exactly these three options — but only when the host has a
121
+ question mechanism **and** the clean-room path is available (the `Agent` tool plus a
122
+ dispatchable `forge-verifier` subagent); otherwise degrade exactly as `manual-print`
123
+ below:
124
+
125
+ - **Verify {stageNoun} now** *(recommended)* — dispatch the clean-room `forge-verifier`
126
+ subagent from this session in require-clean mode; the digest returns here so any fix
127
+ decision keeps its context. One-time — it does **not** change config.
128
+ - **Verify now + enable auto-verify going forward** — verify now **and** patch
129
+ `"autoVerify": true` into `forge.config.json` in place (preserve formatting and every
130
+ other key) so future stages verify automatically, no prompt. This complements the
131
+ `forge-init` opt-in. **Do not auto-commit this config change** — treat it like
132
+ `notes`: a user-facing edit the user commits on their own cadence, never folded into
133
+ a stage's artifact commit.
134
+ - **Skip for now** — go straight to the NEXT-STEPS block without verifying. Record this
135
+ stage's verify status as `"skipped"` in pipeline state (mirroring the existing skip
136
+ handling) **only** on an explicit skip — a skip does not go stale.
137
+
138
+ If verify runs and finds findings, handle them exactly as in the in-stage flow above
139
+ (digest + `AskUserQuestion` gate; `autoFixEligible` applies unchanged).
140
+
141
+ ### `verifyGate: "manual-print"`
142
+
143
+ Verification is outstanding but the host cannot present the gate or dispatch
144
+ clean-room. Do **not** run verify inline — print the `verifyCommand` for the user to
145
+ run (mirroring `autoInvokeNextStage`), offer the auto-verify enable as plain text only
146
+ if a config write is possible, and continue to the NEXT-STEPS block. Verify state stays
147
+ outstanding, so the navigator catch-up can fire later.
148
+
149
+ ### `verifyGate: "none"`
150
+
151
+ Verification is already resolved (fresh or explicitly skipped) or the in-stage run
152
+ above covers it. Say so in one line and continue to the NEXT-STEPS block.
153
+
154
+ ### `epicReconcile` (epic backflow — present only when there are open requests)
155
+
156
+ Emitted only when the exiting member carries `open` `epicChangeRequests` (recorded by
157
+ `forge-1-prd`/`forge-2-tech` when the epic *decomposition* itself must change — see
158
+ `references/pipeline-state-schema.json`). Absent on the common path and for standalone
159
+ features. The script has already folded the routing into the NEXT-STEPS block, so this
160
+ directive is informational — you do **not** re-derive the wording:
161
+
162
+ - `required: true` (at least one `blocksCurrent: true` request) — the NEXT-STEPS block's
163
+ fenced **primary** command is the epic reconcile command
164
+ (`/skill:forge-0-epic {epic}`), and the normal next stage is demoted to a
165
+ follow-up line ("After reconciling, continue with …"). This is *reconcile-before-specs*:
166
+ proceeding would author artifacts against a decomposition that is about to change. It is
167
+ strongest when exiting `forge-2-tech` (next is `forge-3-specs`, the point of no cheap
168
+ return).
169
+ - `reminder: true` (only `blocksCurrent: false` requests) — normal next-stage routing is
170
+ unchanged; the block appends a non-blocking reminder line ("You also flagged N epic
171
+ change(s) to reconcile when convenient …"). This is *finish-then-edit*.
172
+
173
+ Either way the added lines are host-neutral (no literal `/clear`) and sit **above** the
174
+ sentinel; just print the NEXT-STEPS block verbatim as always.
175
+
176
+ ### Deferred decisions — do not solicit next-stage decisions at this exit
177
+
178
+ Each stage owns its own decisions. At a stage exit, do **not** pull a *later* stage's
179
+ decision forward — do not ask the user (or decide unilaterally) something that properly
180
+ belongs to the next stage's interview (e.g. at `forge-1-prd` exit, don't settle the
181
+ concrete cache backend that `forge-2-tech` will design). Soliciting it here guesses ahead
182
+ of the stage that owns the context, and the answer has nowhere durable to live.
183
+
184
+ Instead, when you notice a decision that belongs downstream, **record it structurally** as
185
+ a `deferredDecisions[]` entry on this feature's `.pipeline-state.json` (schema in
186
+ `references/pipeline-state-schema.json`; same direct-edit path as `notes` /
187
+ `epicChangeRequests[]`): `question` (phrased for the target stage), optional `rationale`
188
+ and `targetStage`, `raisedBy` (this stage), `raisedAt` (ISO-8601 UTC), `status: "open"`.
189
+ This keeps the exit focused on *this* stage's next-step routing while carrying the open
190
+ question forward for the owning stage to resolve (it flips `status` to `addressed` when it
191
+ does). Prefer a `deferredDecisions[]` entry over stuffing the same thing into the free-text
192
+ `notes` string. This is a recording affordance, not a gate: never block the exit on it.
193
+
194
+ ### The NEXT-STEPS block (always last)
195
+
196
+ Print the script's NEXT-STEPS block **verbatim as your absolute last output**. Nothing
197
+ follows its final sentinel line (`─ forge: end of stage ─`) — no caveats, no summary,
198
+ no sign-off. The block already carries the `/clear` recommendation (host-aware wording
199
+ via `--host`) and the exact next command, so trailing prose can only push the user's
200
+ next action out of view.
201
+
202
+ ---
203
+
204
+ ## Standard block
205
+
206
+ Stamped at the loop's step-6 epic-member handoff (finishing feature A → starting
207
+ feature B's PRD). It self-adapts: step 1's verify gate only fires when verification is
208
+ actually outstanding, so at a boundary where verify already ran (or was explicitly
209
+ skipped, or auto-verify is on) it silently collapses to just the `/clear` →
210
+ next-command steps.
211
+
212
+ Slots: `{stage}` (a lowercase noun phrase), `{verify-command}`, `{next-command}`.
213
+
214
+ <!-- BEGIN: standard-exit-block -->
215
+ **This stage is done — walk the user through the Stage Exit Protocol** before moving on. The order is fixed, and step 2 is something only the user can do:
216
+
217
+ 1. **Verify {stage} first — if it isn't already verified.** If verify already ran in this session — via the in-stage auto-verify on the authoring stages, or the interactive impl-verify offered above on the loop — or is already fresh on record, or the stage was explicitly skipped, say so and go straight to step 2. Only when `autoVerify` is off for this stage **and** verify is **missing or stale** do you present the **Standard Verify Gate**: verify **now, before clearing**, using `AskUserQuestion` with exactly these three options — but only when the host has a question mechanism **and** the clean-room path is available (the `Agent` tool plus a dispatchable `forge-verifier` subagent):
218
+ - **Verify {stage} now** *(recommended)* — dispatch the clean-room `forge-verifier` subagent from this session in require-clean mode; the digest returns here so any fix decision keeps its context. One-time — it does **not** change config.
219
+ - **Verify now + enable auto-verify going forward** — verify now **and** patch `"autoVerify": true` into `forge.config.json` in place (preserve formatting and every other key) so future stages verify automatically, no prompt. This complements the `forge-init` opt-in. **Do not auto-commit this config change** — treat it like `notes`: a user-facing edit the user commits on their own cadence, never folded into a stage's artifact commit.
220
+ - **Skip for now** — go straight to `/clear` and the next command without verifying. Record this stage's verify status as `"skipped"` in pipeline state (mirroring the existing skip handling) **only** on an explicit skip — a skip does not go stale.
221
+
222
+ **Host / clean-room fallback (not a user-selectable option):** if the question mechanism, the `Agent` tool, or the `forge-verifier` subagent is unavailable, do **not** run clean-room — degrade to printing `{verify-command}` for the user to run inline/manually (mirroring `autoInvokeNextStage`), and offer the auto-verify enable as plain text only if a config write is possible.
223
+ 2. **Then `/clear`.** Recommended **unconditionally** at this boundary for a clean start — independent of how full the context window is. Every artifact is on disk, so the work survives the clear. **I can't `/clear` for you — you have to run it yourself.**
224
+ 3. **Then run the next command** in the fresh session — or re-run `/skill:forge` to let the navigator resume from disk:
225
+
226
+ ```
227
+ {next-command}
228
+ ```
229
+ <!-- END: standard-exit-block -->
230
+
231
+ ---
232
+
233
+ ## Warm-acceptable variant
234
+
235
+ Stamp this only at the `forge-5-loop → forge-6-docs` boundary (the all-done result
236
+ report). Here clearing is **optional**: the docs stage benefits from the still-warm
237
+ context of what the loop actually did, and impl-verify is already offered interactively
238
+ by the loop itself, so this block defers rather than re-presenting a gate.
239
+
240
+ > **Note — no literal `/clear` here.** The warm block lives in `result-reporting.md`, a
241
+ > skill-*own* reference that the adapter build copies **verbatim** (unlike skill bodies,
242
+ > it is not host-term translated), so a literal `/clear` would reach non-Claude adapters
243
+ > undegraded. The warm variant says "clearing is optional" anyway, so it is phrased
244
+ > host-neutrally without the token on purpose — do not reintroduce `/clear` here. (The
245
+ > standard block *does* use `/clear`; that is fine because every standard stamp site is a
246
+ > skill **body**, where `scripts/build-adapters.py` degrades it.)
247
+
248
+ <!-- BEGIN: warm-exit-block -->
249
+ **The loop is complete — this is the one boundary where clearing before the next stage is optional.**
250
+
251
+ 1. **Verify is already offered above.** Impl-verify is offered interactively right after this report (Step 5b for a standalone feature, Step 6.1 for an epic member) — run it there rather than as a second gate. It runs clean-room, so it needs no fresh session.
252
+ 2. **Clearing is optional here — warm is fine.** `forge-6-docs` benefits from the still-warm context of what the loop actually did, so continuing in this same session is the easy default. A cold start also works — every artifact is on disk — but there is no need to force it.
253
+ 3. **Then run the next command** — in this warm session, or a fresh one if you prefer:
254
+
255
+ ```
256
+ {next-command}
257
+ ```
258
+ <!-- END: warm-exit-block -->
@@ -0,0 +1,178 @@
1
+ ---
2
+ # GENERATED — DO NOT EDIT. Source: skills/forge-3-specs/SKILL.md. Regenerate: python3 scripts/build-adapters.py
3
+ name: forge-3-specs
4
+ description: Generate numbered implementation spec documents from PRD and tech spec in the forge pipeline. Use when user runs /skill:forge-3-specs or asks to create detailed implementation specs for a forge feature after tech spec completion. Do NOT trigger for general specification writing, design docs, or implementation planning outside the forge pipeline.
5
+ ---
6
+
7
+ # forge-3-specs — Implementation Spec Suite Generator
8
+
9
+ Generate a comprehensive suite of numbered implementation specification documents that provide everything needed to implement a feature.
10
+
11
+ ## Prerequisites
12
+
13
+ Read and follow `references/shared-conventions.md` for feature name validation, configuration reading, and force mode handling before proceeding.
14
+
15
+ **Turn structure reminder:** Output analysis/context as text, then route ALL questions through `AskUserQuestion`. Never embed questions in text output — the user will not be prompted and the session will stall.
16
+
17
+ ## Step 1: Validate Prerequisites
18
+
19
+ **Resolve the feature directory first** via the **Feature Directory Resolution** block in `references/shared-conventions.md`, setting `{resolvedFeatureDir}`.
20
+
21
+ **Prerequisite check:** Read `{resolvedFeatureDir}/.pipeline-state.json`. If not in force mode, both `forge-1-prd` and `forge-2-tech` must be `complete`. If not, STOP and tell the user which prerequisites are missing.
22
+
23
+ After the prerequisite check, invoke the **Stage-Entry Guard** block in `references/shared-conventions.md` with `{stage}` = `forge-3-specs`. Because this stage writes a suite incrementally, the guard's **interrupted** arm uses the `stages.forge-3-specs.artifacts` array (already updated after each spec file — Step 3) to resume from the first unwritten document rather than regenerating the whole suite.
24
+
25
+ Read both `{resolvedFeatureDir}/PRD.md` and `{resolvedFeatureDir}/tech-spec.md` into context.
26
+
27
+ After reading the PRD and tech spec, invoke the **Epic Context Injection** block in `references/shared-conventions.md`. It self-gates on the resolved feature's `epic` back-pointer: for a standalone feature it is a no-op; for an epic member it loads EPIC.md, this feature's charter, and the completed direct dependencies' specs into context before the spec suite is planned.
28
+
29
+ ## Step 2: Examine Existing Context
30
+
31
+ 1. **Read the PRD and tech spec thoroughly**: These are your source of truth
32
+ 2. **Examine the existing codebase**: Look at how other packages are structured, what patterns they follow, what types they export
33
+ 3. **Check other features' implementation specs**: Look at `{specsDir}/*/[0-9][0-9]-*.md` AND `{specsDir}/*/*/[0-9][0-9]-*.md` (depth-2, for epic-nested features) for consistency in format and depth. Subject to the **feature-shaped-dir bound**: only treat a matched directory as a feature if it directly contains a `.pipeline-state.json` (per the Feature Directory Resolution block) — ignore `EPIC.md` directories and other non-feature subtrees. Flat-only trees gain no new matches from the depth-2 glob, so standalone behavior is unchanged (REQ-COMPAT-01).
34
+ 4. **Read integration target code**: For every package listed as an integration point in the tech spec, read its actual source — types, exports, patterns. For every integration point, include the EXACT function signature and import path you read from the source code. Include the file path where you found it. If you cannot locate an expected export, say so explicitly: 'WARNING: Could not locate X export in {module} — verify this exists before implementing.'
35
+ 5. **Read spec examples**: Read `references/spec-examples.md` for the expected depth and quality of spec sections. These examples are your quality bar.
36
+
37
+ ## Step 3: Plan the Document Suite
38
+
39
+ Read `references/spec-archetypes.md` for the menu of document types.
40
+
41
+ Based on the feature's complexity, propose a document plan to the user before writing. Output the document list as text, then use `AskUserQuestion` for the question — do NOT include the question in your text output.
42
+
43
+ **Example text output (no question here):**
44
+ ```
45
+ I'll create the following spec documents for {feature}:
46
+
47
+ Required:
48
+ 00-core-definitions.md — Type definitions, error hierarchy, shared contracts
49
+ 01-architecture-layout.md — Directory structure, exports map, dependency graph
50
+ NN-testing-strategy.md — Test approach, coverage targets, fixture patterns
51
+
52
+ Feature-specific:
53
+ 02-{subsystem-a}.md — {Brief description}
54
+ 03-{subsystem-b}.md — {Brief description}
55
+ 04-integration-points.md — Integration with existing project modules
56
+ ```
57
+
58
+ **Then call `AskUserQuestion`** following the **Decision Support** protocol in `references/shared-conventions.md`: recommend this plan as the default (it's your evidence-backed read of the feature's complexity) and name the trade-off so the user can push back knowingly — more documents means finer separation of concerns but more to keep in sync; fewer means tighter docs but risks one document carrying multiple concerns. Lead with: "I recommend this plan. Add or remove any documents?" Note the guidance below — resist splitting a concern into a sub-50-line document.
59
+
60
+ **Incremental artifact tracking:** After each spec document is written (by you or a writer subagent), immediately update the `artifacts` array in `.pipeline-state.json` with the new file path. This enables crash recovery if the session is interrupted mid-suite (see shared-conventions.md "Stage-Entry Guard").
61
+
62
+ ## Step 4: Write the Spec Suite
63
+
64
+ The suite has a hard internal dependency: every domain/integration doc references the
65
+ shared types and layout from `00-core-definitions.md` and `01-architecture-layout.md`.
66
+ So author in two phases — a sequential foundation, then a parallel fan-out.
67
+
68
+ ### 4a. Foundation pass (sequential, you author)
69
+
70
+ Write `00-core-definitions.md` and `01-architecture-layout.md` yourself, in the main
71
+ session, **before** anything else. Every later document depends on these shared types
72
+ and the directory/exports map, so they must exist and be stable first.
73
+
74
+ ### 4b. Domain fan-out (parallel `forge-spec-writer` subagents)
75
+
76
+ Once the foundation is written, dispatch the remaining numbered docs in parallel — **one
77
+ `forge-spec-writer` subagent per document, in a single message with multiple subagent
78
+ calls** (the `superpowers:dispatching-parallel-agents` pattern). Each writer is given:
79
+ - the PRD and tech-spec,
80
+ - the just-written `00-core-definitions.md` and `01-architecture-layout.md` (so it builds
81
+ on the shared types, not its own),
82
+ - the stack profile path `references/stacks/{stack}.md` (if `stack` is set in config),
83
+ - the quality bar in `references/spec-examples.md`,
84
+ - the **exact single filename it must write** and the archetype slice (from
85
+ `references/spec-archetypes.md`) it covers.
86
+ - **(epic members only — additive context):** the relevant `EPIC.md` Contracts section(s)
87
+ for this feature, and the `tech-spec.md` of each completed direct dependency at {paths} — so
88
+ the doc is written against real upstream contracts, not guesses.
89
+
90
+ Each writer authors **only its one assigned file** and returns a short **manifest** of
91
+ the `REQ-XXX-NN` IDs it covered (feeds Step 5 traceability). Author `NN-testing-strategy.md`
92
+ last (it can be its own writer, or you author it once the others' shapes are known).
93
+
94
+ **Fallback (no subagents available):** author the documents yourself in batches of 3–5,
95
+ foundation first; after each batch, optionally commit
96
+ (`git add {specsDir}/{feature}/ && git commit -m "{commitPrefix}({feature}): specs batch {n}"`)
97
+ and re-read only `00-core-definitions.md` plus the upstream docs the next batch needs —
98
+ do not reload everything. This keeps quality up under context pressure.
99
+
100
+ ### Quality requirements (every document, whoever writes it)
101
+
102
+ 1. Number sequentially: `00-`, `01-`, `02-`, etc.
103
+ 2. Every implementation detail MUST trace to either a PRD requirement (REQ-XXX-NN) or a tech-spec decision
104
+ 3. Before the body, include a `## Requirement Coverage` table mapping every REQ-XXX-NN this document covers to the section that implements it
105
+ 4. Include complete type definitions, data structures, and function signatures in the project's language — not pseudocode. If a stack profile exists at `references/stacks/{stack}.md` (where `{stack}` comes from `forge.config.json`), follow its conventions for type definitions, error hierarchies, and documentation comments.
106
+ 5. Include error handling for every operation
107
+ 6. Include example usage where it aids clarity
108
+ 7. Cross-reference other spec documents by filename when one document depends on definitions from another
109
+
110
+ ### Document Conventions
111
+
112
+ - Filename format: `{specsDir}/{feature}/##-<descriptive-name>.md`
113
+ - Each document should be self-contained enough that an engineer could implement it without reading other spec docs (though cross-references help for context)
114
+ - Include a "Dependencies" section listing which other spec docs must be implemented first
115
+ - Include a "Verification" section describing how to confirm the implementation matches the spec
116
+
117
+ ## Step 5: Cross-Reference Validation
118
+
119
+ Before writing `TRACEABILITY.md` or running the stage exit, invoke the **Stage-Completion Re-check** block in `references/shared-conventions.md` with `{stage}` = `forge-3-specs` — a resumed mid-stage continuation must not overwrite a committed `TRACEABILITY.md` or re-fire a finished exit.
120
+
121
+ After writing all documents, verify:
122
+
123
+ 1. Every PRD requirement has coverage in at least one spec document
124
+ 2. Every tech-spec decision is reflected in the implementation specs
125
+ 3. Cross-references between spec documents are consistent (no broken references)
126
+ 4. Type definitions used across documents are consistent
127
+ 5. No orphaned implementation details that don't trace to requirements
128
+ 6. Produce a traceability matrix: a markdown table mapping every REQ-XXX-NN from the PRD to the spec document and section that implements it. Write this to `{resolvedFeatureDir}/TRACEABILITY.md`
129
+
130
+ List any gaps or inconsistencies found and resolve them.
131
+
132
+ ## Step 6: Review with User
133
+
134
+ Present a summary of all documents created as text, with key decisions highlighted. Then use `AskUserQuestion` to collect feedback — do NOT include these questions in your text output:
135
+
136
+ "1. Does the level of detail match what you need? 2. Any areas that need more depth? 3. Any missing subsystems or concerns?"
137
+
138
+ ## Step 7: Update Pipeline State and Commit
139
+
140
+ Write pipeline state conforming to `references/pipeline-state-schema.json`.
141
+
142
+ 1. Update `{resolvedFeatureDir}/.pipeline-state.json`:
143
+ - Set `currentStage` to `forge-4-backlog` (or verification if they want to verify first)
144
+ - Record all created files in `artifacts`, including `TRACEABILITY.md`
145
+ - Set `stages.forge-3-specs.basedOnVersions` to `{"forge-1-prd": <current version>, "forge-2-tech": <current version>}`
146
+ - Check downstream stages (forge-4-backlog, forge-5-loop, forge-6-docs). If any have `basedOnVersions` referencing older versions, set their status to `stale`
147
+ 2. **Offer a note — don't force one.** As a statement (not a blocking question), let the user know they can jot anything worth preserving across sessions and you'll store it in the `notes` field. If they volunteer something, store it; otherwise proceed.
148
+ 3. If `gitCommitAfterStage` is true, follow the Git Commit Protocol in `references/shared-conventions.md`: stage files, attempt commit with message `"{commitPrefix}({feature}): complete implementation specs v{n}"` (marking `stages.forge-3-specs.status` `complete` with `commitHash: null` in that commit), then record the artifact-commit hash via the protocol's two-commit follow-up (never `--amend`) only on success. If commit fails, leave status as `in-progress`.
149
+ 4. **Close with the Stage Exit Protocol** (single-sourced in `references/stage-exit-protocol.md`; do not improvise a "Next steps" list). Specs feed every downstream stage, so the verify gate matters here:
150
+
151
+ **Close this stage with the Scripted Stage Exit** (contract: `references/stage-exit-protocol.md`; do not improvise a "Next steps" list). Run:
152
+
153
+ ```bash
154
+ R="$(bash -c 'for d in "${FEATURE_FORGE_ROOT:-}" "$HOME"/.claude/skills/feature-forge "$HOME"/.claude/plugins/cache/*/feature-forge/* "$HOME"/.claude/plugins/*/feature-forge "$HOME"/.agents/skills/feature-forge ./.agents/skills/feature-forge; do [ -x "$d/scripts/forge-root.sh" ] && exec "$d/scripts/forge-root.sh"; done')"
155
+ [ -n "$R" ] || { echo "feature-forge: cannot locate plugin root" >&2; exit 1; }
156
+ python3 "$R/scripts/forge-session.py" stage-exit --feature "{feature}" --stage forge-3-specs --specs-dir "{specsDir}" --host pi
157
+ ```
158
+
159
+ Obey the DIRECTIVES it prints, in order, per the directive contract: `runInStageVerify: true` → dispatch the in-stage clean-room verify now (honoring `autoFixEligible`); `verifyGate: "standard"` → present the Standard Verify Gate; `verifyGate: "manual-print"` → print the `verifyCommand` for the user; non-empty `invalidAutoVerifyKeys` → print a one-line warning. Then **print the NEXT-STEPS block verbatim as your absolute last output — nothing after its sentinel line.**
160
+
161
+ ## Gotchas
162
+
163
+ - Don't create specs for things that are already fully specified in the tech spec. If the tech spec has complete type definitions, the implementation spec should reference them, not duplicate them.
164
+ - Every spec document should include complete type definitions and function signatures in the project's language with documentation comments. The backlog generator and implementing engineer depend on these being exact, not approximate.
165
+ - Resist the urge to create too many documents. Each document should represent a major concern. If a "document" would be under 50 lines, it probably belongs as a section in another document.
166
+ - Watch for implicit dependencies between subsystems. If subsystem A's types are used by subsystem B, the spec should explicitly state this and ensure the types are defined in the shared types document.
167
+ - If the feature is large, the spec suite might be 8-12 documents. If it's simple, 3-4 is fine. Match complexity to the feature, not a fixed template.
168
+
169
+ ---
170
+
171
+ ## Host execution notes (Pi)
172
+
173
+ This Pi bundle preserves Claude's `AskUserQuestion` references because it ships a Pi compatibility extension registering an `AskUserQuestion` tool. On Pi:
174
+
175
+ - **User input:** use `AskUserQuestion` for genuine user decisions. It supports multiple questions, option descriptions, recommended ordering, multi-select, previews, and free-form Other/custom answers.
176
+ - **Skill dispatch:** Pi uses `/skill:<name>` commands. If you cannot invoke a skill directly, print the exact `/skill:<name> ...` command for the user to run.
177
+ - **Subagents:** this bundle declares its custom agents (`forge-researcher`, `forge-spec-writer`, `forge-verifier`) as package agents. If a `subagent` tool is registered, dispatch one with `{ agent: "forge-verifier", task: "..." }`, or fan several out concurrently with `{ tasks: [{ agent: "forge-spec-writer", task: "..." }, ...] }`. If no `subagent` tool is available, run that step inline yourself.
178
+ - **Background / monitoring:** run long-lived commands in the foreground and report progress as it arrives.
@@ -0,0 +1,191 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Feature Forge Pipeline State",
4
+ "description": "Tracks pipeline progress for a single feature across sessions. Lives at {specsDir}/{feature}/.pipeline-state.json",
5
+ "type": "object",
6
+ "required": ["feature", "createdAt", "updatedAt", "currentStage", "stages", "pipelineStatus"],
7
+ "properties": {
8
+ "pipelineStatus": {
9
+ "type": "string",
10
+ "enum": ["active", "paused", "abandoned"],
11
+ "default": "active"
12
+ },
13
+ "feature": {
14
+ "type": "string",
15
+ "description": "Feature name (matches directory name under specsDir)"
16
+ },
17
+ "epic": {
18
+ "type": "string",
19
+ "description": "Back-pointer to the owning epic's name. Absent for standalone features. The epic-manifest.json is canonical on conflict (REQ-STATE-01)."
20
+ },
21
+ "branch": {
22
+ "type": "string",
23
+ "description": "Git branch this feature's pipeline work is intended to land on, recorded by the Branch Setup block (shared-conventions.md) at the entry stage. Absent when the project isn't a git repo or branchPerFeature is false. Downstream stages and forge-5-loop compare the current branch against this to detect drift back onto the default branch before committing."
24
+ },
25
+ "createdAt": {
26
+ "type": "string",
27
+ "format": "date-time"
28
+ },
29
+ "updatedAt": {
30
+ "type": "string",
31
+ "format": "date-time"
32
+ },
33
+ "currentStage": {
34
+ "type": "string",
35
+ "enum": ["forge-1-prd", "forge-2-tech", "forge-3-specs", "forge-4-backlog", "forge-5-loop", "forge-6-docs", "complete", "forge-verify-prd", "forge-verify-tech", "forge-verify-specs", "forge-verify-backlog", "forge-verify-impl", "forge-0-epic", "forge-verify-epic"],
36
+ "description": "Where the pipeline IS: the most recently started stage — its `stages[<currentStage>].status` is `in-progress` while that stage is being authored, then `complete` once its artifacts are committed. A stage skill sets this to its own id when it starts. This is deliberately NOT 'the next stage to run': the next stage is DERIVED, never stored — it is the first production stage whose `stages[].status` is not `complete` (see `next_stage()` in forge-session.py, surfaced as the navigator/doctor `nextStage`). Consumers that need 'what runs next' compute it from `stages[].status`, not from this field. `complete` here means the whole pipeline is done. (Legacy/absent value: tools fall back to the derived next stage for display only — `build_rows` in forge-session.py.)"
37
+ },
38
+ "notes": {
39
+ "type": "string",
40
+ "description": "Free-form notes persisted between sessions (user can add context before stepping away)"
41
+ },
42
+ "epicChangeRequests": {
43
+ "type": "array",
44
+ "description": "Epic-level change requests raised by a member stage (forge-1-prd/forge-2-tech) when the epic DECOMPOSITION itself must change — distinct from the same-feature `notes` parking lot. Read by forge-0-epic edit mode (which applies them) and by forge-session stage-exit (which routes the exit on `blocksCurrent`). Absent/empty for standalone features. Additive/optional: legacy states without it validate unchanged.",
45
+ "items": {
46
+ "type": "object",
47
+ "required": ["kind", "target", "rationale", "blocksCurrent", "raisedBy", "raisedAt", "status"],
48
+ "additionalProperties": false,
49
+ "properties": {
50
+ "kind": {
51
+ "type": "string",
52
+ "enum": ["add-feature", "redep", "move-boundary", "split"],
53
+ "description": "The decomposition change. add-feature/redep map 1:1 onto edit-mode mutators; move-boundary/split are composite (applied guided-manual in v1)."
54
+ },
55
+ "target": {
56
+ "type": "string",
57
+ "description": "The sibling feature to add, or the feature/boundary affected."
58
+ },
59
+ "rationale": {
60
+ "type": "string",
61
+ "description": "Why the epic must change; seeds the edit-mode charter/prompt when applied."
62
+ },
63
+ "blocksCurrent": {
64
+ "type": "boolean",
65
+ "description": "true → the current feature's next stage would build on a soon-to-change decomposition (pause-now: reconcile before proceeding). false → a peer/downstream change (finish-then-edit). Drives stage-exit routing."
66
+ },
67
+ "raisedBy": {
68
+ "type": "string",
69
+ "enum": ["forge-1-prd", "forge-2-tech"],
70
+ "description": "The stage that detected the epic-level concern."
71
+ },
72
+ "raisedAt": { "type": "string", "format": "date-time" },
73
+ "status": {
74
+ "type": "string",
75
+ "enum": ["open", "applied", "dismissed"],
76
+ "default": "open",
77
+ "description": "Lifecycle: open → applied|dismissed. Only forge-0-epic edit mode flips open→applied/dismissed; recording stages only create open entries; navigator/verify only read."
78
+ }
79
+ }
80
+ }
81
+ },
82
+ "deferredDecisions": {
83
+ "type": "array",
84
+ "description": "Same-feature decisions deliberately postponed to a LATER stage of THIS feature — a structured alternative to burying them in the free-text `notes` string. Distinct from `notes` (unstructured scratch) and from `epicChangeRequests[]` (the epic DECOMPOSITION must change). Use this when a stage would otherwise be tempted to solicit a decision that properly belongs to a downstream stage (e.g. forge-1-prd deferring the concrete cache backend to forge-2-tech): record it here instead of asking now (see the deferred-decisions rule in `references/stage-exit-protocol.md`), and the target stage addresses it. Additive/optional: legacy states without it validate unchanged.",
85
+ "items": {
86
+ "type": "object",
87
+ "required": ["question", "raisedBy", "raisedAt", "status"],
88
+ "additionalProperties": false,
89
+ "properties": {
90
+ "question": {
91
+ "type": "string",
92
+ "description": "The decision being deferred, phrased as a concrete question for the target stage to answer."
93
+ },
94
+ "rationale": {
95
+ "type": "string",
96
+ "description": "Why it is deferred rather than decided now (e.g. depends on information the target stage produces)."
97
+ },
98
+ "targetStage": {
99
+ "type": "string",
100
+ "enum": ["forge-1-prd", "forge-2-tech", "forge-3-specs", "forge-4-backlog", "forge-5-loop", "forge-6-docs"],
101
+ "description": "The stage that should resolve this decision. Omit when unknown/any-later-stage."
102
+ },
103
+ "raisedBy": {
104
+ "type": "string",
105
+ "enum": ["forge-1-prd", "forge-2-tech", "forge-3-specs", "forge-4-backlog"],
106
+ "description": "The stage that deferred the decision."
107
+ },
108
+ "raisedAt": { "type": "string", "format": "date-time" },
109
+ "status": {
110
+ "type": "string",
111
+ "enum": ["open", "addressed", "dismissed"],
112
+ "default": "open",
113
+ "description": "Lifecycle: open → addressed|dismissed. The target stage flips open→addressed when it resolves the decision (or dismissed if it no longer applies); recording stages only create open entries."
114
+ }
115
+ }
116
+ }
117
+ },
118
+ "stages": {
119
+ "type": "object",
120
+ "properties": {
121
+ "forge-0-epic": { "$ref": "#/definitions/stageEntry" },
122
+ "forge-verify-epic": { "$ref": "#/definitions/verifyEntry" },
123
+ "forge-1-prd": { "$ref": "#/definitions/stageEntry" },
124
+ "forge-2-tech": { "$ref": "#/definitions/stageEntry" },
125
+ "forge-3-specs": { "$ref": "#/definitions/stageEntry" },
126
+ "forge-verify-specs": { "$ref": "#/definitions/verifyEntry" },
127
+ "forge-4-backlog": { "$ref": "#/definitions/stageEntry" },
128
+ "forge-verify-backlog": { "$ref": "#/definitions/verifyEntry" },
129
+ "forge-5-loop": { "$ref": "#/definitions/stageEntry" },
130
+ "forge-6-docs": { "$ref": "#/definitions/stageEntry" },
131
+ "forge-verify-impl": { "$ref": "#/definitions/verifyEntry" },
132
+ "forge-verify-prd": { "$ref": "#/definitions/verifyEntry" },
133
+ "forge-verify-tech": { "$ref": "#/definitions/verifyEntry" }
134
+ }
135
+ }
136
+ },
137
+ "definitions": {
138
+ "stageEntry": {
139
+ "type": "object",
140
+ "required": ["status"],
141
+ "properties": {
142
+ "status": {
143
+ "type": "string",
144
+ "enum": ["pending", "in-progress", "complete", "stale"]
145
+ },
146
+ "version": {
147
+ "type": "integer",
148
+ "description": "Incremented each time this stage's artifacts are revised"
149
+ },
150
+ "artifacts": {
151
+ "type": "array",
152
+ "items": { "type": "string" },
153
+ "description": "Relative paths to artifacts produced by this stage"
154
+ },
155
+ "startedAt": { "type": ["string", "null"], "format": "date-time" },
156
+ "completedAt": { "type": ["string", "null"], "format": "date-time" },
157
+ "commitHash": {
158
+ "type": ["string", "null"],
159
+ "description": "Git commit SHA of this stage's artifact commit (Commit 1 of the two-commit Git Commit Protocol in shared-conventions.md). Written by a small follow-up commit so it points at the artifact commit itself, never at an orphaned amend or the hash-recording commit. null until recorded (or when there was no new artifact commit)."
160
+ },
161
+ "basedOnVersions": {
162
+ "type": "object",
163
+ "description": "Upstream stage versions this artifact was built against",
164
+ "additionalProperties": { "type": "integer" }
165
+ }
166
+ }
167
+ },
168
+ "verifyEntry": {
169
+ "type": "object",
170
+ "required": ["status"],
171
+ "properties": {
172
+ "status": {
173
+ "type": "string",
174
+ "enum": ["pending", "passed", "findings-reported", "findings-applied", "skipped"]
175
+ },
176
+ "findingsFile": {
177
+ "type": ["string", "null"],
178
+ "description": "Path to the verification findings document"
179
+ },
180
+ "findingsCount": {
181
+ "type": ["integer", "null"],
182
+ "description": "Number of findings reported"
183
+ },
184
+ "verifiedAt": { "type": ["string", "null"], "format": "date-time" },
185
+ "fixedAt": { "type": ["string", "null"], "format": "date-time" },
186
+ "commitHash": { "type": ["string", "null"], "description": "Git commit SHA of the verify/fix artifact commit. Recorded via the two-commit Git Commit Protocol (shared-conventions.md) so it points at the artifact commit, never an orphaned amend." },
187
+ "verifiedStageVersion": { "type": ["integer", "null"], "description": "The production stage's `version` at the moment this verify was resolved. The navigator's freshness ledger compares it to the stage's current `version`: equal means the verify is fresh; a mismatch (artifact revised since) or an absent field (legacy state) means stale, so auto-verify re-fires. Recorded by forge-verify/forge-fix when writing a passed/findings-applied status." }
188
+ }
189
+ }
190
+ }
191
+ }