@garygentry/feature-forge 0.1.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 (231) hide show
  1. package/LICENSE +21 -0
  2. package/adapters/GENERATION-REPORT.md +128 -0
  3. package/adapters/claude/agents/forge-researcher.md +137 -0
  4. package/adapters/claude/agents/forge-spec-writer.md +115 -0
  5. package/adapters/claude/agents/forge-verifier.md +121 -0
  6. package/adapters/claude/references/epic-manifest-schema.json +120 -0
  7. package/adapters/claude/references/forge-config-schema.json +166 -0
  8. package/adapters/claude/references/pipeline-state-schema.json +110 -0
  9. package/adapters/claude/references/portable-root.md +56 -0
  10. package/adapters/claude/references/process-overview.md +123 -0
  11. package/adapters/claude/references/ralph-loop-contract.md +221 -0
  12. package/adapters/claude/references/shared-conventions.md +144 -0
  13. package/adapters/claude/references/skill-frontmatter.schema.json +17 -0
  14. package/adapters/claude/references/stack-resolution.md +51 -0
  15. package/adapters/claude/references/stacks/_generic.md +90 -0
  16. package/adapters/claude/references/stacks/go.md +138 -0
  17. package/adapters/claude/references/stacks/python.md +163 -0
  18. package/adapters/claude/references/stacks/rust.md +151 -0
  19. package/adapters/claude/references/stacks/typescript.md +111 -0
  20. package/adapters/claude/references/vendor-construct-inventory.md +49 -0
  21. package/adapters/claude/scripts/forge-root.sh +50 -0
  22. package/adapters/claude/skills/forge/SKILL.md +165 -0
  23. package/adapters/claude/skills/forge-0-epic/SKILL.md +303 -0
  24. package/adapters/claude/skills/forge-0-epic/references/edit-mode.md +222 -0
  25. package/adapters/claude/skills/forge-0-epic/references/epic-manifest-subcommands.md +64 -0
  26. package/adapters/claude/skills/forge-1-prd/SKILL.md +121 -0
  27. package/adapters/claude/skills/forge-1-prd/references/prd-template.md +106 -0
  28. package/adapters/claude/skills/forge-2-tech/SKILL.md +198 -0
  29. package/adapters/claude/skills/forge-2-tech/references/stack-discovery-checklist.md +95 -0
  30. package/adapters/claude/skills/forge-3-specs/SKILL.md +154 -0
  31. package/adapters/claude/skills/forge-3-specs/references/spec-archetypes.md +106 -0
  32. package/adapters/claude/skills/forge-3-specs/references/spec-examples.md +71 -0
  33. package/adapters/claude/skills/forge-4-backlog/SKILL.md +146 -0
  34. package/adapters/claude/skills/forge-5-loop/SKILL.md +303 -0
  35. package/adapters/claude/skills/forge-5-loop/references/result-reporting.md +63 -0
  36. package/adapters/claude/skills/forge-5-loop/references/runner-contract.md +214 -0
  37. package/adapters/claude/skills/forge-6-docs/SKILL.md +179 -0
  38. package/adapters/claude/skills/forge-6-docs/references/doc-conventions.md +126 -0
  39. package/adapters/claude/skills/forge-fix/SKILL.md +65 -0
  40. package/adapters/claude/skills/forge-init/SKILL.md +29 -0
  41. package/adapters/claude/skills/forge-verify/SKILL.md +219 -0
  42. package/adapters/claude/skills/forge-verify/references/verification-checklists.md +379 -0
  43. package/adapters/codex/agents/forge-researcher.md +133 -0
  44. package/adapters/codex/agents/forge-spec-writer.md +112 -0
  45. package/adapters/codex/agents/forge-verifier.md +115 -0
  46. package/adapters/codex/agents/openai.yaml +10 -0
  47. package/adapters/codex/references/epic-manifest-schema.json +120 -0
  48. package/adapters/codex/references/forge-config-schema.json +166 -0
  49. package/adapters/codex/references/pipeline-state-schema.json +110 -0
  50. package/adapters/codex/references/portable-root.md +56 -0
  51. package/adapters/codex/references/process-overview.md +123 -0
  52. package/adapters/codex/references/ralph-loop-contract.md +221 -0
  53. package/adapters/codex/references/shared-conventions.md +144 -0
  54. package/adapters/codex/references/skill-frontmatter.schema.json +17 -0
  55. package/adapters/codex/references/stack-resolution.md +51 -0
  56. package/adapters/codex/references/stacks/_generic.md +90 -0
  57. package/adapters/codex/references/stacks/go.md +138 -0
  58. package/adapters/codex/references/stacks/python.md +163 -0
  59. package/adapters/codex/references/stacks/rust.md +151 -0
  60. package/adapters/codex/references/stacks/typescript.md +111 -0
  61. package/adapters/codex/references/vendor-construct-inventory.md +49 -0
  62. package/adapters/codex/scripts/forge-root.sh +50 -0
  63. package/adapters/codex/skills/forge/forge.md +164 -0
  64. package/adapters/codex/skills/forge-0-epic/forge-0-epic.md +302 -0
  65. package/adapters/codex/skills/forge-0-epic/references/edit-mode.md +222 -0
  66. package/adapters/codex/skills/forge-0-epic/references/epic-manifest-subcommands.md +64 -0
  67. package/adapters/codex/skills/forge-1-prd/forge-1-prd.md +120 -0
  68. package/adapters/codex/skills/forge-1-prd/references/prd-template.md +106 -0
  69. package/adapters/codex/skills/forge-2-tech/forge-2-tech.md +197 -0
  70. package/adapters/codex/skills/forge-2-tech/references/stack-discovery-checklist.md +95 -0
  71. package/adapters/codex/skills/forge-3-specs/forge-3-specs.md +153 -0
  72. package/adapters/codex/skills/forge-3-specs/references/spec-archetypes.md +106 -0
  73. package/adapters/codex/skills/forge-3-specs/references/spec-examples.md +71 -0
  74. package/adapters/codex/skills/forge-4-backlog/forge-4-backlog.md +145 -0
  75. package/adapters/codex/skills/forge-5-loop/forge-5-loop.md +302 -0
  76. package/adapters/codex/skills/forge-5-loop/references/result-reporting.md +63 -0
  77. package/adapters/codex/skills/forge-5-loop/references/runner-contract.md +214 -0
  78. package/adapters/codex/skills/forge-6-docs/forge-6-docs.md +178 -0
  79. package/adapters/codex/skills/forge-6-docs/references/doc-conventions.md +126 -0
  80. package/adapters/codex/skills/forge-fix/forge-fix.md +64 -0
  81. package/adapters/codex/skills/forge-init/forge-init.md +29 -0
  82. package/adapters/codex/skills/forge-verify/forge-verify.md +218 -0
  83. package/adapters/codex/skills/forge-verify/references/verification-checklists.md +379 -0
  84. package/adapters/copilot/agents/forge-researcher.md +133 -0
  85. package/adapters/copilot/agents/forge-spec-writer.md +112 -0
  86. package/adapters/copilot/agents/forge-verifier.md +115 -0
  87. package/adapters/copilot/references/epic-manifest-schema.json +120 -0
  88. package/adapters/copilot/references/forge-config-schema.json +166 -0
  89. package/adapters/copilot/references/pipeline-state-schema.json +110 -0
  90. package/adapters/copilot/references/portable-root.md +56 -0
  91. package/adapters/copilot/references/process-overview.md +123 -0
  92. package/adapters/copilot/references/ralph-loop-contract.md +221 -0
  93. package/adapters/copilot/references/shared-conventions.md +144 -0
  94. package/adapters/copilot/references/skill-frontmatter.schema.json +17 -0
  95. package/adapters/copilot/references/stack-resolution.md +51 -0
  96. package/adapters/copilot/references/stacks/_generic.md +90 -0
  97. package/adapters/copilot/references/stacks/go.md +138 -0
  98. package/adapters/copilot/references/stacks/python.md +163 -0
  99. package/adapters/copilot/references/stacks/rust.md +151 -0
  100. package/adapters/copilot/references/stacks/typescript.md +111 -0
  101. package/adapters/copilot/references/vendor-construct-inventory.md +49 -0
  102. package/adapters/copilot/scripts/forge-root.sh +50 -0
  103. package/adapters/copilot/skills/forge/forge.md +164 -0
  104. package/adapters/copilot/skills/forge-0-epic/forge-0-epic.md +302 -0
  105. package/adapters/copilot/skills/forge-0-epic/references/edit-mode.md +222 -0
  106. package/adapters/copilot/skills/forge-0-epic/references/epic-manifest-subcommands.md +64 -0
  107. package/adapters/copilot/skills/forge-1-prd/forge-1-prd.md +120 -0
  108. package/adapters/copilot/skills/forge-1-prd/references/prd-template.md +106 -0
  109. package/adapters/copilot/skills/forge-2-tech/forge-2-tech.md +197 -0
  110. package/adapters/copilot/skills/forge-2-tech/references/stack-discovery-checklist.md +95 -0
  111. package/adapters/copilot/skills/forge-3-specs/forge-3-specs.md +153 -0
  112. package/adapters/copilot/skills/forge-3-specs/references/spec-archetypes.md +106 -0
  113. package/adapters/copilot/skills/forge-3-specs/references/spec-examples.md +71 -0
  114. package/adapters/copilot/skills/forge-4-backlog/forge-4-backlog.md +145 -0
  115. package/adapters/copilot/skills/forge-5-loop/forge-5-loop.md +302 -0
  116. package/adapters/copilot/skills/forge-5-loop/references/result-reporting.md +63 -0
  117. package/adapters/copilot/skills/forge-5-loop/references/runner-contract.md +214 -0
  118. package/adapters/copilot/skills/forge-6-docs/forge-6-docs.md +178 -0
  119. package/adapters/copilot/skills/forge-6-docs/references/doc-conventions.md +126 -0
  120. package/adapters/copilot/skills/forge-fix/forge-fix.md +64 -0
  121. package/adapters/copilot/skills/forge-init/forge-init.md +29 -0
  122. package/adapters/copilot/skills/forge-verify/forge-verify.md +218 -0
  123. package/adapters/copilot/skills/forge-verify/references/verification-checklists.md +379 -0
  124. package/adapters/cursor/agents/forge-researcher.mdc +134 -0
  125. package/adapters/cursor/agents/forge-spec-writer.mdc +113 -0
  126. package/adapters/cursor/agents/forge-verifier.mdc +116 -0
  127. package/adapters/cursor/references/epic-manifest-schema.json +120 -0
  128. package/adapters/cursor/references/forge-config-schema.json +166 -0
  129. package/adapters/cursor/references/pipeline-state-schema.json +110 -0
  130. package/adapters/cursor/references/portable-root.md +56 -0
  131. package/adapters/cursor/references/process-overview.md +123 -0
  132. package/adapters/cursor/references/ralph-loop-contract.md +221 -0
  133. package/adapters/cursor/references/shared-conventions.md +144 -0
  134. package/adapters/cursor/references/skill-frontmatter.schema.json +17 -0
  135. package/adapters/cursor/references/stack-resolution.md +51 -0
  136. package/adapters/cursor/references/stacks/_generic.md +90 -0
  137. package/adapters/cursor/references/stacks/go.md +138 -0
  138. package/adapters/cursor/references/stacks/python.md +163 -0
  139. package/adapters/cursor/references/stacks/rust.md +151 -0
  140. package/adapters/cursor/references/stacks/typescript.md +111 -0
  141. package/adapters/cursor/references/vendor-construct-inventory.md +49 -0
  142. package/adapters/cursor/scripts/forge-root.sh +50 -0
  143. package/adapters/cursor/skills/forge/forge.mdc +165 -0
  144. package/adapters/cursor/skills/forge-0-epic/forge-0-epic.mdc +303 -0
  145. package/adapters/cursor/skills/forge-0-epic/references/edit-mode.md +222 -0
  146. package/adapters/cursor/skills/forge-0-epic/references/epic-manifest-subcommands.md +64 -0
  147. package/adapters/cursor/skills/forge-1-prd/forge-1-prd.mdc +121 -0
  148. package/adapters/cursor/skills/forge-1-prd/references/prd-template.md +106 -0
  149. package/adapters/cursor/skills/forge-2-tech/forge-2-tech.mdc +198 -0
  150. package/adapters/cursor/skills/forge-2-tech/references/stack-discovery-checklist.md +95 -0
  151. package/adapters/cursor/skills/forge-3-specs/forge-3-specs.mdc +154 -0
  152. package/adapters/cursor/skills/forge-3-specs/references/spec-archetypes.md +106 -0
  153. package/adapters/cursor/skills/forge-3-specs/references/spec-examples.md +71 -0
  154. package/adapters/cursor/skills/forge-4-backlog/forge-4-backlog.mdc +146 -0
  155. package/adapters/cursor/skills/forge-5-loop/forge-5-loop.mdc +303 -0
  156. package/adapters/cursor/skills/forge-5-loop/references/result-reporting.md +63 -0
  157. package/adapters/cursor/skills/forge-5-loop/references/runner-contract.md +214 -0
  158. package/adapters/cursor/skills/forge-6-docs/forge-6-docs.mdc +179 -0
  159. package/adapters/cursor/skills/forge-6-docs/references/doc-conventions.md +126 -0
  160. package/adapters/cursor/skills/forge-fix/forge-fix.mdc +65 -0
  161. package/adapters/cursor/skills/forge-init/forge-init.mdc +30 -0
  162. package/adapters/cursor/skills/forge-verify/forge-verify.mdc +219 -0
  163. package/adapters/cursor/skills/forge-verify/references/verification-checklists.md +379 -0
  164. package/adapters/gemini/agents/forge-researcher.md +133 -0
  165. package/adapters/gemini/agents/forge-spec-writer.md +112 -0
  166. package/adapters/gemini/agents/forge-verifier.md +115 -0
  167. package/adapters/gemini/gemini-extension.json +54 -0
  168. package/adapters/gemini/references/epic-manifest-schema.json +120 -0
  169. package/adapters/gemini/references/forge-config-schema.json +166 -0
  170. package/adapters/gemini/references/pipeline-state-schema.json +110 -0
  171. package/adapters/gemini/references/portable-root.md +56 -0
  172. package/adapters/gemini/references/process-overview.md +123 -0
  173. package/adapters/gemini/references/ralph-loop-contract.md +221 -0
  174. package/adapters/gemini/references/shared-conventions.md +144 -0
  175. package/adapters/gemini/references/skill-frontmatter.schema.json +17 -0
  176. package/adapters/gemini/references/stack-resolution.md +51 -0
  177. package/adapters/gemini/references/stacks/_generic.md +90 -0
  178. package/adapters/gemini/references/stacks/go.md +138 -0
  179. package/adapters/gemini/references/stacks/python.md +163 -0
  180. package/adapters/gemini/references/stacks/rust.md +151 -0
  181. package/adapters/gemini/references/stacks/typescript.md +111 -0
  182. package/adapters/gemini/references/vendor-construct-inventory.md +49 -0
  183. package/adapters/gemini/scripts/forge-root.sh +50 -0
  184. package/adapters/gemini/skills/forge/forge.md +164 -0
  185. package/adapters/gemini/skills/forge-0-epic/forge-0-epic.md +302 -0
  186. package/adapters/gemini/skills/forge-0-epic/references/edit-mode.md +222 -0
  187. package/adapters/gemini/skills/forge-0-epic/references/epic-manifest-subcommands.md +64 -0
  188. package/adapters/gemini/skills/forge-1-prd/forge-1-prd.md +120 -0
  189. package/adapters/gemini/skills/forge-1-prd/references/prd-template.md +106 -0
  190. package/adapters/gemini/skills/forge-2-tech/forge-2-tech.md +197 -0
  191. package/adapters/gemini/skills/forge-2-tech/references/stack-discovery-checklist.md +95 -0
  192. package/adapters/gemini/skills/forge-3-specs/forge-3-specs.md +153 -0
  193. package/adapters/gemini/skills/forge-3-specs/references/spec-archetypes.md +106 -0
  194. package/adapters/gemini/skills/forge-3-specs/references/spec-examples.md +71 -0
  195. package/adapters/gemini/skills/forge-4-backlog/forge-4-backlog.md +145 -0
  196. package/adapters/gemini/skills/forge-5-loop/forge-5-loop.md +302 -0
  197. package/adapters/gemini/skills/forge-5-loop/references/result-reporting.md +63 -0
  198. package/adapters/gemini/skills/forge-5-loop/references/runner-contract.md +214 -0
  199. package/adapters/gemini/skills/forge-6-docs/forge-6-docs.md +178 -0
  200. package/adapters/gemini/skills/forge-6-docs/references/doc-conventions.md +126 -0
  201. package/adapters/gemini/skills/forge-fix/forge-fix.md +64 -0
  202. package/adapters/gemini/skills/forge-init/forge-init.md +29 -0
  203. package/adapters/gemini/skills/forge-verify/forge-verify.md +218 -0
  204. package/adapters/gemini/skills/forge-verify/references/verification-checklists.md +379 -0
  205. package/dist/agent-targets.d.ts +70 -0
  206. package/dist/agent-targets.js +111 -0
  207. package/dist/apply.d.ts +49 -0
  208. package/dist/apply.js +246 -0
  209. package/dist/cli.d.ts +94 -0
  210. package/dist/cli.js +508 -0
  211. package/dist/detect.d.ts +45 -0
  212. package/dist/detect.js +72 -0
  213. package/dist/fsutil.d.ts +56 -0
  214. package/dist/fsutil.js +175 -0
  215. package/dist/hash.d.ts +50 -0
  216. package/dist/hash.js +107 -0
  217. package/dist/index.d.ts +8 -0
  218. package/dist/index.js +9 -0
  219. package/dist/manifest.d.ts +72 -0
  220. package/dist/manifest.js +222 -0
  221. package/dist/plan.d.ts +66 -0
  222. package/dist/plan.js +166 -0
  223. package/dist/rauf.d.ts +83 -0
  224. package/dist/rauf.js +118 -0
  225. package/dist/report.d.ts +35 -0
  226. package/dist/report.js +110 -0
  227. package/dist/source.d.ts +69 -0
  228. package/dist/source.js +164 -0
  229. package/dist/types.d.ts +264 -0
  230. package/dist/types.js +57 -0
  231. package/package.json +42 -0
@@ -0,0 +1,197 @@
1
+ ---
2
+ # GENERATED — DO NOT EDIT. Source: skills/forge-2-tech/SKILL.md. Regenerate: python3 scripts/build-adapters.py
3
+ name: forge-2-tech
4
+ description: Create a technical specification from an existing PRD in the forge pipeline. Use when user runs /feature-forge:forge-2-tech or asks to create a tech spec for a forge feature after PRD completion. Do NOT trigger for general technical design discussions, architecture reviews, or tech specs outside the forge pipeline.
5
+ ---
6
+
7
+ # forge-2-tech — Technical Specification Driver
8
+
9
+ Create a thorough technical specification by interviewing the user about technology decisions, grounded in PRD requirements.
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
+ ## Step 1: Validate Prerequisites
16
+
17
+ **Resolve the feature directory first** via the **Feature Directory Resolution** block in `references/shared-conventions.md`, setting `{resolvedFeatureDir}`.
18
+
19
+ **Prerequisite check:** Read `{resolvedFeatureDir}/.pipeline-state.json`. If not in force mode and `forge-1-prd` is not `complete`, STOP and tell the user: "The PRD for '{feature}' isn't complete yet. Run `/feature-forge:forge-1-prd {feature}` first."
20
+
21
+ Read `{resolvedFeatureDir}/PRD.md` into context. This is your foundation — every technology decision must trace back to a PRD requirement.
22
+
23
+ After reading the PRD, 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 research and interview.
24
+
25
+ ## Step 2: Examine Existing Context
26
+
27
+ Before interviewing, you need to understand the existing codebase. This involves reading many files across the project, which consumes context.
28
+
29
+ ### Recommended: Delegate to forge-researcher Subagent
30
+
31
+ Spawn the `forge-researcher` subagent via the Agent tool to scan the codebase. Pass a prompt like: "Research the codebase for planning the {feature} feature. Focus on integration points, established patterns, and relevant packages."
32
+
33
+ If this feature belongs to an epic, also add to the dispatch prompt: "If this feature belongs to an epic, also account for these epic contracts: {paste this feature's `consumes` and the `exposes` of its direct deps}, and the completed dependency tech-specs at {paths}. Do not re-research transitive deps." This threads epic context into the researcher without changing the agent's behavior.
34
+
35
+ The researcher runs in its own context window, reads the project structure, and returns a concise integration report. This keeps your main conversation context clean for the interactive interview.
36
+
37
+ **Single vs. parallel research.** For a small or well-understood codebase, **one**
38
+ researcher is the right default. For a **large codebase or uncertain scope** (many
39
+ packages, several integration surfaces, monorepo), dispatch **multiple `forge-researcher`
40
+ subagents in parallel — a single message with multiple Agent calls** (the
41
+ `superpowers:dispatching-parallel-agents` pattern), each scoped to a **disjoint focus**
42
+ so they don't re-read the same ground:
43
+ - one on **project structure & conventions** (layout, build, naming, error/test patterns),
44
+ - one per **major integration area / subsystem** the feature touches (its exports, types,
45
+ public API),
46
+ - optionally one on **existing feature specs & in-progress conflicts**.
47
+
48
+ Each returns its own report; **you merge them** into a single integration picture for the
49
+ interview. This cuts latency and deepens coverage versus one researcher sweeping
50
+ everything serially. No agent change is needed — `forge-researcher` already returns a
51
+ self-contained report; just give each instance a narrower focus.
52
+
53
+ If the `forge-researcher` subagent is not available, perform the research inline (steps below).
54
+
55
+ ### Manual Research (fallback)
56
+
57
+ 1. **Read the PRD thoroughly**: Understand all requirements and constraints
58
+ 2. **Check for project-level stack decisions**: Look for `.claude/references/stack-decisions.md` in the project root. If present, read it — these are established technology choices that should be respected unless there's a strong reason to deviate.
59
+ 3. **Read the plugin's default stack reference**: Read `references/stack-discovery-checklist.md` for general stack context (only if no project-level override exists)
60
+ 4. **Examine the existing codebase**: Look at `package.json` files, existing packages, directory structure, and established patterns. Understand what conventions are already in place.
61
+ 5. **Review other features' tech specs**: Check `{specsDir}/*/tech-spec.md` and `{specsDir}/*/*/tech-spec.md` (depth-2, to find nested epic members) for consistency in approach and to identify shared infrastructure. Apply the **feature-shaped-dir bound**: only treat a directory as a feature if it directly contains a `.pipeline-state.json` (filter matches whose parent directory holds one, or enumerate members via the helper). A flat-only tree has no depth-2 feature dirs, so this gains no new matches there (REQ-COMPAT-01).
62
+ 6. **Identify integration points**: For each existing package that this feature touches, read its exports, types, and public API. Document these as constraints.
63
+
64
+ ### Stack Detection and Persistence
65
+
66
+ After researching the codebase, identify the primary stack (language, build tool, package manager, framework). Read `references/stack-resolution.md` for the full resolution protocol.
67
+
68
+ 1. Check if `forge.config.json` already has a `stack` field — if so, use it
69
+ 2. Otherwise, detect from project files and use `AskUserQuestion` to confirm: "I detected this as a {stack} project. Correct?"
70
+ 3. Update `forge.config.json` with `stack`, `typeCheckCommand`, and `testCommand`
71
+ 4. Verify that a matching stack profile exists at `references/stacks/{stack}.md`. If it does, load it for stack-specific guidance during this and all subsequent stages. If no profile exists, inform the user: "No dedicated profile for {stack}. Using generic fallback — spec conventions, verification checks, and examples will be language-neutral. Consider creating a project-level override at `.claude/references/stack-decisions.md`." Then load `references/stacks/_generic.md`.
72
+
73
+ ## Step 3: Conduct the Interview
74
+
75
+ Interview the user about technology decisions. Unlike the PRD interview, here you SHOULD discuss specific technologies, libraries, patterns, and architecture.
76
+
77
+ ### Interview Approach
78
+
79
+ **Turn structure:** Output your research findings, analysis, or technical proposals as regular text. Then use `AskUserQuestion` for the actual questions. NEVER put questions in your text output — they MUST go through `AskUserQuestion`.
80
+
81
+ **Pacing:** Present 1-2 decision areas per `AskUserQuestion` call and STOP to wait for the user's response before continuing. After receiving answers, probe deeper on anything incomplete before moving to the next topic. Signal progress in your text before the next question batch. Do NOT dump all decision areas in a single message — the interview is a conversation, not a document.
82
+
83
+ **First message pattern:** Output the research summary as text, then use `AskUserQuestion` to confirm the stack and ask about the first decision area (typically package/module structure). Wait for the user to respond before proceeding to subsequent areas.
84
+
85
+ **Question strategies** (use these as content for `AskUserQuestion`, not as inline prose):
86
+ - For each PRD requirement, propose a technical approach and ask for confirmation or alternatives
87
+ - Proactively suggest approaches consistent with the established stack
88
+ - Challenge over-engineering: does the feature need this, or is a simpler approach sufficient?
89
+ - Ask about every integration point and how the feature interacts with existing modules
90
+
91
+ **Parking lot:** If the user raises a concern that belongs to a different pipeline stage (e.g., backlog granularity, documentation format), acknowledge it and note it in the pipeline state's `notes` field: "Good point — I've noted that for the [specs/backlog/docs stage]. Let's continue with the tech spec."
92
+
93
+ ### Key Decision Areas to Cover
94
+
95
+ Work through these areas across multiple turns, grouping related areas (1-2 per message):
96
+
97
+ - **Package/module structure**: Where does this live in the project? What are its exports? (For non-monorepo projects, this becomes module organization — where the code lives, how it's organized, and what its exports are.)
98
+ - **Data model**: What are the key entities, their schemas, and storage approach?
99
+ - **API design**: What endpoints or interfaces does this expose?
100
+ - **Dependencies**: What external and internal packages are needed?
101
+ - **Patterns**: Which established patterns from the codebase apply here?
102
+ - **Error handling**: How are errors surfaced, propagated, and recovered from?
103
+ - **Testing strategy**: Unit, integration, e2e — what approach for this feature?
104
+ - **Configuration**: What's configurable? How is it configured?
105
+ - **Migration/deployment**: Any special rollout considerations?
106
+
107
+ ### Requirement Traceability
108
+
109
+ Every technical decision MUST reference the PRD requirement(s) it addresses. Use the format:
110
+
111
+ ```
112
+ ### JWT-based Session Tokens (REQ-AUTH-01, REQ-SEC-02)
113
+ Sessions will use signed JWT tokens with...
114
+ ```
115
+
116
+ If you find yourself writing a technical section that doesn't trace to any PRD requirement, STOP and ask: "I'm about to specify X, but I can't find a PRD requirement for it. Should we add one, or is this unnecessary?"
117
+
118
+ ## Step 4: Integration Analysis (Required)
119
+
120
+ Before finalizing the tech spec, this section is MANDATORY:
121
+
122
+ 1. List every existing package this feature depends on
123
+ 2. List every existing package that will need to import from this feature
124
+ 3. For each integration point, document:
125
+ - Which types or contracts are shared
126
+ - How data flows between packages
127
+ - Any patterns established by existing code that must be followed
128
+ - The EXACT function signatures and import paths verified from source code. If you cannot locate an expected export, note explicitly: "WARNING: Could not locate X export in {module} — verify this exists before implementing."
129
+ 4. Check for potential conflicts with in-progress features (other spec directories)
130
+
131
+ ## Step 5: Write the Tech Spec
132
+
133
+ Write `{resolvedFeatureDir}/tech-spec.md` with this structure:
134
+
135
+ ```markdown
136
+ # {Feature Name} — Technical Specification
137
+
138
+ ## 1. Overview
139
+ Brief technical summary and key architectural decisions.
140
+
141
+ ## 2. Module Structure
142
+ Project location, directory layout, public API surface.
143
+
144
+ ## 3. Technical Decisions
145
+ ### 3.1 {Decision Area} (REQ-XXX-NN)
146
+ Decision, rationale, alternatives considered.
147
+
148
+ ## 4. Data Model
149
+ Schemas, types, storage approach.
150
+
151
+ ## 5. API Design
152
+ Endpoints, interfaces, contracts.
153
+
154
+ ## 6. Integration Points
155
+ How this feature connects to existing packages.
156
+
157
+ ## 7. Error Handling
158
+ Error types, propagation, recovery.
159
+
160
+ ## 8. Testing Approach
161
+ Strategy, tooling, coverage targets.
162
+
163
+ ## 9. Dependencies
164
+ External packages, internal packages, version constraints.
165
+
166
+ ## 10. Open Technical Questions
167
+ Unresolved technical decisions.
168
+ ```
169
+
170
+ ## Step 6: Review with User
171
+
172
+ Present the complete tech spec. Ask:
173
+ - "Does this capture all the technical decisions correctly?"
174
+ - "Any patterns from the existing codebase I missed?"
175
+ - "Are the integration points complete?"
176
+
177
+ Use `AskUserQuestion` to collect this feedback.
178
+
179
+ ## Step 7: Update Pipeline State and Commit
180
+
181
+ Write pipeline state conforming to `references/pipeline-state-schema.json`.
182
+
183
+ 1. Update `{resolvedFeatureDir}/.pipeline-state.json`:
184
+ - Set `currentStage` to `forge-3-specs`
185
+ - Record `artifacts`, `completedAt`, `version`
186
+ - Set `stages.forge-2-tech.basedOnVersions` to `{"forge-1-prd": <current forge-1-prd version>}`
187
+ - Check downstream stages (forge-3-specs, forge-4-backlog, forge-5-loop, forge-6-docs). If any have `basedOnVersions` referencing an older version of forge-2-tech, set their status to `stale`
188
+ 2. Use `AskUserQuestion` to ask about notes to persist
189
+ 3. If `gitCommitAfterStage` is true, follow the Git Commit Protocol in `references/shared-conventions.md`: stage files, attempt commit with message `"{commitPrefix}({feature}): complete tech-spec v{n}"`, then set `stages.forge-2-tech.status` to `complete` with commit hash only on success. If commit fails, leave status as `in-progress`.
190
+ 5. Tell the user: "Tech spec complete. Next steps:\n - `/feature-forge:forge-verify {feature}` to verify the tech spec\n - `/feature-forge:forge-3-specs {feature}` to create implementation specs\n - `/feature-forge:forge {feature}` to see full pipeline status"
191
+
192
+ ## Gotchas
193
+
194
+ - Don't duplicate the PRD. The tech spec answers HOW, not WHAT. If you find yourself restating requirements, reference them by ID instead.
195
+ - When the user's stack decisions differ from what you'd recommend, document their choice AND note your concern as an "Alternatives Considered" item — don't silently override their preference.
196
+ - Integration points are the #1 source of implementation surprises. Spend extra time here. Read the actual code of packages this feature touches, don't just guess at their APIs.
197
+ - If the existing codebase has inconsistent patterns (it happens), call it out and ask which pattern should be followed for this feature.
@@ -0,0 +1,95 @@
1
+ # Stack Discovery Checklist (Plugin Default)
2
+
3
+ This file contains a default stack discovery protocol for the feature-forge plugin. Projects can override this by placing a `stack-decisions.md` in `.claude/references/` at the project root.
4
+
5
+ ## Note to Agent
6
+
7
+ This is a DISCOVERY PROTOCOL — it helps you identify what stack the project uses. It is NOT a set of decisions. Always check `.claude/references/stack-decisions.md` first — if present, it takes precedence.
8
+
9
+ After discovering the stack, check if `references/stacks/{stack}.md` exists in the plugin for stack-specific guidance. See `references/stack-resolution.md` for the full resolution protocol.
10
+
11
+ ## Purpose
12
+
13
+ This is a default discovery guide for understanding a project's technology stack. Projects should create `.claude/references/stack-decisions.md` with their actual stack decisions, which takes precedence over this checklist.
14
+
15
+ ## Stack Discovery Protocol
16
+
17
+ ### 1. Identify the Primary Language and Runtime
18
+
19
+ Check for project manifests:
20
+ - `package.json` → Node.js / Bun (JavaScript/TypeScript)
21
+ - `pyproject.toml`, `setup.py`, `setup.cfg` → Python
22
+ - `go.mod` → Go
23
+ - `Cargo.toml` → Rust
24
+ - `pom.xml`, `build.gradle`, `build.gradle.kts` → Java / Kotlin
25
+ - `*.csproj`, `*.sln` → .NET (C#/F#)
26
+ - `mix.exs` → Elixir
27
+ - `Gemfile` → Ruby
28
+ - `Package.swift` → Swift
29
+
30
+ ### 2. Identify the Package Manager
31
+
32
+ Check for lock files:
33
+ - `bun.lockb` → Bun
34
+ - `pnpm-lock.yaml` → pnpm
35
+ - `package-lock.json` → npm
36
+ - `yarn.lock` → Yarn
37
+ - `uv.lock` → uv
38
+ - `poetry.lock` → Poetry
39
+ - `go.sum` → Go modules
40
+ - `Cargo.lock` → Cargo
41
+
42
+ ### 3. Identify Project Structure
43
+
44
+ Check for monorepo/workspace configurations:
45
+ - `turbo.json` → Turborepo
46
+ - `nx.json` → Nx
47
+ - `lerna.json` → Lerna
48
+ - `pnpm-workspace.yaml` → pnpm workspaces
49
+ - `pants.toml` → Pants (Python/Go/Java)
50
+ - `go.work` → Go workspaces
51
+ - `Cargo.toml` with `[workspace]` → Cargo workspaces
52
+
53
+ If none found, this is likely a single-project repository.
54
+
55
+ ### 4. Identify Frameworks and Libraries
56
+
57
+ Examine the dependency manifest for:
58
+ - **Web frameworks**: Hono, Express, Fastify, FastAPI, Django, Flask, Gin, Actix, Spring Boot, etc.
59
+ - **Frontend**: React, Vue, Svelte, Solid, etc.
60
+ - **Database/ORM**: Drizzle, Prisma, SQLAlchemy, GORM, Diesel, etc.
61
+ - **Validation**: Zod, Pydantic, etc.
62
+ - **Testing**: Vitest, pytest, go test, etc.
63
+
64
+ ### 5. Identify Build and Type Checking
65
+
66
+ - Check for CI config (`.github/workflows/`, `Makefile`, `justfile`) to find build, test, and type check commands
67
+ - Check `package.json` scripts, `pyproject.toml` `[tool.*]` sections, or `Makefile` targets
68
+
69
+ ## How to Create a Project-Level Override
70
+
71
+ Create `.claude/references/stack-decisions.md` in your project root with your specific stack decisions. See `references/stacks/typescript.md` or `references/stacks/python.md` for stack-specific examples of what to include.
72
+
73
+ ```markdown
74
+ # Stack Decisions
75
+
76
+ ## Runtime & Build
77
+ - [Language and version]
78
+ - [Package manager]
79
+ - [Build tool / monorepo orchestration if applicable]
80
+
81
+ ## Backend
82
+ - [Web framework]
83
+ - [Database / ORM]
84
+ - [Validation library]
85
+
86
+ ## Frontend (if applicable)
87
+ - [UI framework]
88
+ - [Component library]
89
+ - [Styling approach]
90
+
91
+ ## Conventions
92
+ - [Testing framework and approach]
93
+ - [Type checking / linting command]
94
+ - [Module organization patterns]
95
+ ```
@@ -0,0 +1,153 @@
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 /feature-forge: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
+ Read both `{resolvedFeatureDir}/PRD.md` and `{resolvedFeatureDir}/tech-spec.md` into context.
24
+
25
+ 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.
26
+
27
+ ## Step 2: Examine Existing Context
28
+
29
+ 1. **Read the PRD and tech spec thoroughly**: These are your source of truth
30
+ 2. **Examine the existing codebase**: Look at how other packages are structured, what patterns they follow, what types they export
31
+ 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).
32
+ 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.'
33
+ 5. **Read spec examples**: Read `references/spec-examples.md` for the expected depth and quality of spec sections. These examples are your quality bar.
34
+
35
+ ## Step 3: Plan the Document Suite
36
+
37
+ Read `references/spec-archetypes.md` for the menu of document types.
38
+
39
+ 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.
40
+
41
+ **Example text output (no question here):**
42
+ ```
43
+ I'll create the following spec documents for {feature}:
44
+
45
+ Required:
46
+ 00-core-definitions.md — Type definitions, error hierarchy, shared contracts
47
+ 01-architecture-layout.md — Directory structure, exports map, dependency graph
48
+ NN-testing-strategy.md — Test approach, coverage targets, fixture patterns
49
+
50
+ Feature-specific:
51
+ 02-{subsystem-a}.md — {Brief description}
52
+ 03-{subsystem-b}.md — {Brief description}
53
+ 04-integration-points.md — Integration with existing project modules
54
+ ```
55
+
56
+ **Then call `AskUserQuestion`** with: "Does this look right? Should I add or remove any documents?"
57
+
58
+ **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 "Crash Recovery").
59
+
60
+ ## Step 4: Write the Spec Suite
61
+
62
+ The suite has a hard internal dependency: every domain/integration doc references the
63
+ shared types and layout from `00-core-definitions.md` and `01-architecture-layout.md`.
64
+ So author in two phases — a sequential foundation, then a parallel fan-out.
65
+
66
+ ### 4a. Foundation pass (sequential, you author)
67
+
68
+ Write `00-core-definitions.md` and `01-architecture-layout.md` yourself, in the main
69
+ session, **before** anything else. Every later document depends on these shared types
70
+ and the directory/exports map, so they must exist and be stable first.
71
+
72
+ ### 4b. Domain fan-out (parallel `forge-spec-writer` subagents)
73
+
74
+ Once the foundation is written, dispatch the remaining numbered docs in parallel — **one
75
+ `forge-spec-writer` subagent per document, in a single message with multiple Agent
76
+ calls** (the `superpowers:dispatching-parallel-agents` pattern). Each writer is given:
77
+ - the PRD and tech-spec,
78
+ - the just-written `00-core-definitions.md` and `01-architecture-layout.md` (so it builds
79
+ on the shared types, not its own),
80
+ - the stack profile path `references/stacks/{stack}.md` (if `stack` is set in config),
81
+ - the quality bar in `references/spec-examples.md`,
82
+ - the **exact single filename it must write** and the archetype slice (from
83
+ `references/spec-archetypes.md`) it covers.
84
+ - **(epic members only — additive context):** the relevant `EPIC.md` Contracts section(s)
85
+ for this feature, and the `tech-spec.md` of each completed direct dependency at {paths} — so
86
+ the doc is written against real upstream contracts, not guesses.
87
+
88
+ Each writer authors **only its one assigned file** and returns a short **manifest** of
89
+ the `REQ-XXX-NN` IDs it covered (feeds Step 5 traceability). Author `NN-testing-strategy.md`
90
+ last (it can be its own writer, or you author it once the others' shapes are known).
91
+
92
+ **Fallback (no subagents available):** author the documents yourself in batches of 3–5,
93
+ foundation first; after each batch, optionally commit
94
+ (`git add {specsDir}/{feature}/ && git commit -m "{commitPrefix}({feature}): specs batch {n}"`)
95
+ and re-read only `00-core-definitions.md` plus the upstream docs the next batch needs —
96
+ do not reload everything. This keeps quality up under context pressure.
97
+
98
+ ### Quality requirements (every document, whoever writes it)
99
+
100
+ 1. Number sequentially: `00-`, `01-`, `02-`, etc.
101
+ 2. Every implementation detail MUST trace to either a PRD requirement (REQ-XXX-NN) or a tech-spec decision
102
+ 3. Before the body, include a `## Requirement Coverage` table mapping every REQ-XXX-NN this document covers to the section that implements it
103
+ 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.
104
+ 5. Include error handling for every operation
105
+ 6. Include example usage where it aids clarity
106
+ 7. Cross-reference other spec documents by filename when one document depends on definitions from another
107
+
108
+ ### Document Conventions
109
+
110
+ - Filename format: `{specsDir}/{feature}/##-<descriptive-name>.md`
111
+ - Each document should be self-contained enough that an engineer could implement it without reading other spec docs (though cross-references help for context)
112
+ - Include a "Dependencies" section listing which other spec docs must be implemented first
113
+ - Include a "Verification" section describing how to confirm the implementation matches the spec
114
+
115
+ ## Step 5: Cross-Reference Validation
116
+
117
+ After writing all documents, verify:
118
+
119
+ 1. Every PRD requirement has coverage in at least one spec document
120
+ 2. Every tech-spec decision is reflected in the implementation specs
121
+ 3. Cross-references between spec documents are consistent (no broken references)
122
+ 4. Type definitions used across documents are consistent
123
+ 5. No orphaned implementation details that don't trace to requirements
124
+ 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`
125
+
126
+ List any gaps or inconsistencies found and resolve them.
127
+
128
+ ## Step 6: Review with User
129
+
130
+ 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:
131
+
132
+ "1. Does the level of detail match what you need? 2. Any areas that need more depth? 3. Any missing subsystems or concerns?"
133
+
134
+ ## Step 7: Update Pipeline State and Commit
135
+
136
+ Write pipeline state conforming to `references/pipeline-state-schema.json`.
137
+
138
+ 1. Update `{resolvedFeatureDir}/.pipeline-state.json`:
139
+ - Set `currentStage` to `forge-4-backlog` (or verification if they want to verify first)
140
+ - Record all created files in `artifacts`, including `TRACEABILITY.md`
141
+ - Set `stages.forge-3-specs.basedOnVersions` to `{"forge-1-prd": <current version>, "forge-2-tech": <current version>}`
142
+ - Check downstream stages (forge-4-backlog, forge-5-loop, forge-6-docs). If any have `basedOnVersions` referencing older versions, set their status to `stale`
143
+ 2. Use `AskUserQuestion` to ask about notes to persist
144
+ 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}"`, then set `stages.forge-3-specs.status` to `complete` with commit hash only on success. If commit fails, leave status as `in-progress`.
145
+ 5. Tell the user: "Implementation specs complete. Next steps:\n - `/feature-forge:forge-verify {feature}` to verify the specs (strongly recommended)\n - `/feature-forge:forge-4-backlog {feature}` to generate the backlog\n - `/feature-forge:forge {feature}` to see full pipeline status"
146
+
147
+ ## Gotchas
148
+
149
+ - 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.
150
+ - 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.
151
+ - 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.
152
+ - 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.
153
+ - 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.
@@ -0,0 +1,106 @@
1
+ # Implementation Spec Archetypes
2
+
3
+ This reference defines the types of implementation spec documents and their internal structure. Use this to plan which documents a feature needs.
4
+
5
+ ## Always Required
6
+
7
+ ### 00-core-definitions.md
8
+ The shared type system and data contracts for the feature. Every other spec document references definitions here.
9
+
10
+ **Sections:**
11
+ - Type aliases, union types, enums, or language-equivalent constructs
12
+ - Core types/interfaces/structs with documentation comments on every field
13
+ - Error/exception hierarchy (base error, domain-specific errors, each with typed properties)
14
+ - Constants and enumerations
15
+ - Utility types (if any)
16
+
17
+ **Rules:**
18
+ - Every type must have documentation comments explaining its purpose (JSDoc, docstrings, godoc, etc.)
19
+ - Error types must include `code`, `message`, and domain-specific context fields
20
+ - Export everything through the module's entry point following project conventions
21
+
22
+ ### 01-architecture-layout.md
23
+ How the feature is structured in the project.
24
+
25
+ **Sections:**
26
+ - Directory tree (full, not abbreviated)
27
+ - Project manifest: name, exports/entry points, dependencies, build scripts
28
+ - Build/compiler configuration: key options
29
+ - Module export structure: what each entry point exposes
30
+ - Build and deployment considerations
31
+
32
+ **Rules:**
33
+ - Exports/entry points must be explicit — list every public module or subpath
34
+ - Dependencies should distinguish runtime vs dev dependencies
35
+ - Internal project dependencies must reference exact module/package names
36
+
37
+ ### NN-testing-strategy.md (always last numbered document)
38
+ How to test this feature.
39
+
40
+ **Sections:**
41
+ - Testing framework and tooling (match project conventions — e.g., vitest, pytest, go test)
42
+ - Unit test approach: what to test, what to mock
43
+ - Integration test approach: how to test cross-package interactions
44
+ - Test fixtures and factories
45
+ - Coverage targets
46
+ - Test file location conventions
47
+
48
+ ## Conditionally Required
49
+
50
+ ### ##-{domain-concern}.md (one per major subsystem)
51
+ Use when the feature has distinct subsystems that warrant separate specification.
52
+
53
+ **Examples:** `02-provider-registry.md`, `03-streaming-engine.md`, `04-prompt-templates.md`
54
+
55
+ **Sections:**
56
+ - Purpose and scope (which PRD requirements this covers)
57
+ - Public API: exported functions, classes, or components with full signatures
58
+ - Internal implementation: key algorithms, data flows, state management
59
+ - Configuration: what's configurable, defaults, validation
60
+ - Error handling: what can fail, how errors are typed and surfaced
61
+ - Dependencies: on types from 00, on other subsystems, on external packages
62
+
63
+ ### ##-integration-points.md
64
+ Use when the feature interacts with existing modules or packages.
65
+
66
+ **Sections:**
67
+ - Integration map: which packages, which direction (depends-on vs depended-upon-by)
68
+ - For each integration point:
69
+ - Which types/interfaces are shared
70
+ - Data flow description
71
+ - Import paths and barrel exports
72
+ - Any adapter or bridge code needed
73
+ - Migration considerations: does integration require changes to existing packages?
74
+
75
+ ### ##-ui-components.md
76
+ Use when the feature has a frontend surface.
77
+
78
+ **Sections:**
79
+ - Component tree / hierarchy
80
+ - Props interfaces for each component
81
+ - State management approach
82
+ - Styling approach (consistent with project conventions)
83
+ - Responsive behavior
84
+ - Accessibility requirements (ARIA, keyboard navigation)
85
+
86
+ ### ##-data-migration.md
87
+ Use when the feature involves schema changes or data migration.
88
+
89
+ **Sections:**
90
+ - Schema definition (using project's ORM/migration tool, or raw SQL — match project conventions)
91
+ - Migration steps
92
+ - Rollback strategy
93
+ - Data seeding / fixtures
94
+ - Zero-downtime migration considerations (if applicable)
95
+
96
+ ## Document Quality Checklist
97
+
98
+ Before finalizing any spec document, verify:
99
+
100
+ - [ ] Every section references PRD requirement IDs
101
+ - [ ] All code is valid syntax in the project's language (not pseudocode)
102
+ - [ ] All type references resolve to definitions in 00-core-definitions.md or clearly stated external packages
103
+ - [ ] Error scenarios are covered, not just happy paths
104
+ - [ ] Cross-references to other spec docs use exact filenames
105
+ - [ ] A "Dependencies" section states which other spec docs must be implemented first
106
+ - [ ] A "Verification" section describes how to confirm correct implementation
@@ -0,0 +1,71 @@
1
+ # Spec Examples — Quality Bar
2
+
3
+ These examples demonstrate the expected depth and quality for implementation spec sections. Match this level of detail.
4
+
5
+ > **Note:** The following examples use TypeScript. Adapt the language, idioms, and documentation style to match your project's stack. The STRUCTURE and DEPTH shown here is the quality bar regardless of language. See `references/stacks/{stack}.md` for language-specific conventions.
6
+
7
+ ## Example: Function Specification (from a session management spec)
8
+
9
+ ### 3.2 Token Refresh (REQ-AUTH-05, REQ-SEC-03)
10
+
11
+ Refresh an expiring session token without requiring re-authentication.
12
+
13
+ ```typescript
14
+ /**
15
+ * Refresh a session token if it's within the refresh threshold.
16
+ * Returns a new token with an extended expiry, or null if the session
17
+ * is not eligible for refresh (expired, revoked, or outside threshold).
18
+ *
19
+ * @param currentToken - The JWT string from the session cookie
20
+ * @param options - Refresh configuration
21
+ * @returns New session token string, or null if refresh is not possible
22
+ * @throws {SessionExpiredError} If the token has already expired
23
+ * @throws {TokenValidationError} If the token signature is invalid
24
+ */
25
+ export async function refreshSessionToken(
26
+ currentToken: string,
27
+ options: RefreshOptions
28
+ ): Promise<string | null>;
29
+
30
+ interface RefreshOptions {
31
+ /** Maximum age of a token eligible for refresh. Default: SESSION_DURATION_MS */
32
+ maxAge?: number;
33
+ /** How close to expiry before refresh is allowed. Default: REFRESH_THRESHOLD_MS */
34
+ refreshThreshold?: number;
35
+ /** Secret key for signing the new token */
36
+ signingKey: CryptoKey;
37
+ }
38
+ ```
39
+
40
+ **Error Handling:**
41
+ - `SessionExpiredError` (code: `SESSION_EXPIRED`): Token's `exp` claim is in the past. Client must re-authenticate.
42
+ - `TokenValidationError` (code: `TOKEN_INVALID`): Signature verification failed. Token may have been tampered with. Log a security warning.
43
+ - Returns `null` (no error): Token is valid but not yet within the refresh threshold. No action needed.
44
+
45
+ **Dependencies:**
46
+ - Types from `00-core-definitions.md`: `SessionToken`, `SessionExpiredError`, `TokenValidationError`, `RefreshOptions`
47
+ - Constants from `00-core-definitions.md`: `SESSION_DURATION_MS`, `REFRESH_THRESHOLD_MS`
48
+ - `jose` library for JWT verification and signing
49
+
50
+ **Verification:**
51
+ - [ ] `refreshSessionToken` returns a new token when called with a token within the refresh threshold
52
+ - [ ] Returns `null` for a valid token outside the refresh threshold
53
+ - [ ] Throws `SessionExpiredError` for an expired token
54
+ - [ ] Throws `TokenValidationError` for a token with an invalid signature
55
+ - [ ] New token has an expiry of `SESSION_DURATION_MS` from the current time
56
+
57
+ ## Example: Requirement Coverage Header
58
+
59
+ Every spec document should begin with a requirement coverage section:
60
+
61
+ ```markdown
62
+ ## Requirement Coverage
63
+
64
+ | REQ ID | Requirement | Section |
65
+ |--------|-------------|---------|
66
+ | REQ-AUTH-05 | Token refresh without re-auth | 3.2 |
67
+ | REQ-SEC-03 | Session expiry management | 3.1, 3.2 |
68
+ | REQ-PERF-02 | Token validation under 10ms | 3.3 |
69
+ ```
70
+
71
+ This makes traceability explicit and auditable.