@gordon.gan/specflow 1.0.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 (178) hide show
  1. package/LICENSE +31 -0
  2. package/README.md +442 -0
  3. package/bin/specflow.js +2 -0
  4. package/dist/cli/commands/change-archive.d.ts +26 -0
  5. package/dist/cli/commands/change-archive.js +50 -0
  6. package/dist/cli/commands/change-new.d.ts +18 -0
  7. package/dist/cli/commands/change-new.js +53 -0
  8. package/dist/cli/commands/change-phase.d.ts +33 -0
  9. package/dist/cli/commands/change-phase.js +66 -0
  10. package/dist/cli/commands/change-status.d.ts +35 -0
  11. package/dist/cli/commands/change-status.js +95 -0
  12. package/dist/cli/commands/doctor.d.ts +9 -0
  13. package/dist/cli/commands/doctor.js +48 -0
  14. package/dist/cli/commands/init.d.ts +16 -0
  15. package/dist/cli/commands/init.js +122 -0
  16. package/dist/cli/commands/instructions.d.ts +21 -0
  17. package/dist/cli/commands/instructions.js +75 -0
  18. package/dist/cli/commands/parity-report.d.ts +10 -0
  19. package/dist/cli/commands/parity-report.js +67 -0
  20. package/dist/cli/commands/sync.d.ts +4 -0
  21. package/dist/cli/commands/sync.js +40 -0
  22. package/dist/cli/commands/validate.d.ts +21 -0
  23. package/dist/cli/commands/validate.js +46 -0
  24. package/dist/cli/index.d.ts +1 -0
  25. package/dist/cli/index.js +52 -0
  26. package/dist/core/archive.d.ts +39 -0
  27. package/dist/core/archive.js +154 -0
  28. package/dist/core/artifact-graph/graph.d.ts +60 -0
  29. package/dist/core/artifact-graph/graph.js +141 -0
  30. package/dist/core/artifact-graph/index.d.ts +10 -0
  31. package/dist/core/artifact-graph/index.js +7 -0
  32. package/dist/core/artifact-graph/instruction-loader.d.ts +45 -0
  33. package/dist/core/artifact-graph/instruction-loader.js +37 -0
  34. package/dist/core/artifact-graph/outputs.d.ts +35 -0
  35. package/dist/core/artifact-graph/outputs.js +48 -0
  36. package/dist/core/artifact-graph/resolver.d.ts +54 -0
  37. package/dist/core/artifact-graph/resolver.js +139 -0
  38. package/dist/core/artifact-graph/schema.d.ts +23 -0
  39. package/dist/core/artifact-graph/schema.js +115 -0
  40. package/dist/core/artifact-graph/state.d.ts +9 -0
  41. package/dist/core/artifact-graph/state.js +93 -0
  42. package/dist/core/artifact-graph/types.d.ts +123 -0
  43. package/dist/core/artifact-graph/types.js +29 -0
  44. package/dist/core/parsers/change-parser.d.ts +20 -0
  45. package/dist/core/parsers/change-parser.js +22 -0
  46. package/dist/core/parsers/index.d.ts +7 -0
  47. package/dist/core/parsers/index.js +4 -0
  48. package/dist/core/parsers/markdown-parser.d.ts +35 -0
  49. package/dist/core/parsers/markdown-parser.js +193 -0
  50. package/dist/core/parsers/requirement-blocks.d.ts +21 -0
  51. package/dist/core/parsers/requirement-blocks.js +57 -0
  52. package/dist/core/parsers/spec-structure.d.ts +22 -0
  53. package/dist/core/parsers/spec-structure.js +105 -0
  54. package/dist/core/specs-apply.d.ts +22 -0
  55. package/dist/core/specs-apply.js +165 -0
  56. package/dist/core/templates/index.d.ts +31 -0
  57. package/dist/core/templates/index.js +80 -0
  58. package/dist/core/templates/types.d.ts +4 -0
  59. package/dist/core/templates/types.js +1 -0
  60. package/dist/core/validation/constants.d.ts +14 -0
  61. package/dist/core/validation/constants.js +14 -0
  62. package/dist/core/validation/types.d.ts +13 -0
  63. package/dist/core/validation/types.js +6 -0
  64. package/dist/core/validation/validator.d.ts +24 -0
  65. package/dist/core/validation/validator.js +250 -0
  66. package/dist/integrations/claude/adapter.d.ts +2 -0
  67. package/dist/integrations/claude/adapter.js +106 -0
  68. package/dist/integrations/codex/adapter.d.ts +2 -0
  69. package/dist/integrations/codex/adapter.js +141 -0
  70. package/dist/integrations/cursor/adapter.d.ts +2 -0
  71. package/dist/integrations/cursor/adapter.js +126 -0
  72. package/dist/integrations/shared/adapter-registry.d.ts +4 -0
  73. package/dist/integrations/shared/adapter-registry.js +27 -0
  74. package/dist/integrations/shared/asset-copy.d.ts +2 -0
  75. package/dist/integrations/shared/asset-copy.js +44 -0
  76. package/dist/integrations/shared/asset-hash.d.ts +4 -0
  77. package/dist/integrations/shared/asset-hash.js +54 -0
  78. package/dist/integrations/shared/capability-evidence.d.ts +1 -0
  79. package/dist/integrations/shared/capability-evidence.js +42 -0
  80. package/dist/integrations/shared/command-catalog.d.ts +6 -0
  81. package/dist/integrations/shared/command-catalog.js +13 -0
  82. package/dist/integrations/shared/managed-assets.d.ts +2 -0
  83. package/dist/integrations/shared/managed-assets.js +21 -0
  84. package/dist/integrations/shared/marker-write.d.ts +3 -0
  85. package/dist/integrations/shared/marker-write.js +48 -0
  86. package/dist/integrations/shared/migration-state.d.ts +2 -0
  87. package/dist/integrations/shared/migration-state.js +67 -0
  88. package/dist/integrations/shared/parity-comparator.d.ts +6 -0
  89. package/dist/integrations/shared/parity-comparator.js +97 -0
  90. package/dist/integrations/shared/parity-manifest.d.ts +13 -0
  91. package/dist/integrations/shared/parity-manifest.js +58 -0
  92. package/dist/integrations/shared/runtime-assets.d.ts +2 -0
  93. package/dist/integrations/shared/runtime-assets.js +21 -0
  94. package/dist/integrations/shared/skill-renderer.d.ts +5 -0
  95. package/dist/integrations/shared/skill-renderer.js +77 -0
  96. package/dist/integrations/shared/types.d.ts +35 -0
  97. package/dist/integrations/shared/types.js +1 -0
  98. package/dist/utils/change-metadata.d.ts +38 -0
  99. package/dist/utils/change-metadata.js +82 -0
  100. package/dist/utils/change-utils.d.ts +53 -0
  101. package/dist/utils/change-utils.js +97 -0
  102. package/dist/utils/file-system.d.ts +35 -0
  103. package/dist/utils/file-system.js +67 -0
  104. package/dist/utils/index.d.ts +7 -0
  105. package/dist/utils/index.js +5 -0
  106. package/dist/utils/project-root.d.ts +22 -0
  107. package/dist/utils/project-root.js +44 -0
  108. package/dist/utils/task-progress.d.ts +39 -0
  109. package/dist/utils/task-progress.js +62 -0
  110. package/package.json +72 -0
  111. package/prompts/build/ecc-go-reviewer.md +80 -0
  112. package/prompts/build/ecc-java-reviewer.md +185 -0
  113. package/prompts/build/ecc-kotlin-reviewer.md +163 -0
  114. package/prompts/build/ecc-python-reviewer.md +102 -0
  115. package/prompts/build/ecc-rust-reviewer.md +98 -0
  116. package/prompts/build/ecc-typescript-reviewer.md +116 -0
  117. package/prompts/build/language-router.md +22 -0
  118. package/prompts/build/phase-a-plan.md +288 -0
  119. package/prompts/build/phase-b-execute.md +276 -0
  120. package/prompts/build/phase-b-review.md +119 -0
  121. package/prompts/build/phase-b-worktree.md +215 -0
  122. package/prompts/build/plan-document-reviewer.md +51 -0
  123. package/prompts/build/tdd.md +184 -0
  124. package/prompts/done/branch-finish.md +204 -0
  125. package/prompts/fix/debug.md +249 -0
  126. package/prompts/plan/design-draft.md +123 -0
  127. package/prompts/plan/proposal.md +85 -0
  128. package/prompts/plan/specs.md +114 -0
  129. package/prompts/plan/tasks-draft.md +123 -0
  130. package/prompts/reference/openspec/apply-instruction.md +2 -0
  131. package/prompts/reference/openspec/design-instruction.md +20 -0
  132. package/prompts/reference/openspec/proposal-instruction.md +18 -0
  133. package/prompts/reference/openspec/specs-instruction.md +47 -0
  134. package/prompts/reference/openspec/tasks-instruction.md +26 -0
  135. package/prompts/reference/specflow/example-design.md +284 -0
  136. package/prompts/reference/superpowers/anthropic-best-practices.md +1150 -0
  137. package/prompts/reference/superpowers/codex-tools.md +29 -0
  138. package/prompts/reference/superpowers/condition-based-waiting-example.ts +158 -0
  139. package/prompts/reference/superpowers/condition-based-waiting.md +115 -0
  140. package/prompts/reference/superpowers/defense-in-depth.md +122 -0
  141. package/prompts/reference/superpowers/find-polluter.sh +63 -0
  142. package/prompts/reference/superpowers/graphviz-conventions.dot +172 -0
  143. package/prompts/reference/superpowers/persuasion-principles.md +187 -0
  144. package/prompts/reference/superpowers/root-cause-tracing.md +169 -0
  145. package/prompts/reference/superpowers/testing-anti-patterns.md +299 -0
  146. package/prompts/reference/superpowers/testing-skills-with-subagents.md +384 -0
  147. package/prompts/reference/superpowers/using-superpowers.md +117 -0
  148. package/prompts/reference/superpowers/writing-skills.md +655 -0
  149. package/prompts/refine/brainstorm.md +241 -0
  150. package/prompts/refine/design-output.md +126 -0
  151. package/prompts/refine/spec-document-reviewer.md +51 -0
  152. package/prompts/refine/update-artifacts.md +185 -0
  153. package/prompts/review/code-review.md +223 -0
  154. package/prompts/shared/code-reviewer-prompt.md +98 -0
  155. package/prompts/shared/dispatching-parallel-agents.md +143 -0
  156. package/prompts/shared/executing-plans.md +67 -0
  157. package/prompts/shared/implementer-prompt.md +115 -0
  158. package/prompts/shared/receiving-code-review.md +174 -0
  159. package/prompts/shared/spec-reviewer-prompt.md +63 -0
  160. package/prompts/test/tdd.md +236 -0
  161. package/prompts/test/verification.md +129 -0
  162. package/prompts/verify/ecc-security-reviewer.md +112 -0
  163. package/prompts/verify/verification.md +196 -0
  164. package/schemas/specflow/schema.yaml +48 -0
  165. package/skills/specflow-build/SKILL.md +129 -0
  166. package/skills/specflow-done/SKILL.md +68 -0
  167. package/skills/specflow-fix/SKILL.md +74 -0
  168. package/skills/specflow-plan/SKILL.md +82 -0
  169. package/skills/specflow-refine/SKILL.md +128 -0
  170. package/skills/specflow-review/SKILL.md +40 -0
  171. package/skills/specflow-scan/SKILL.md +48 -0
  172. package/skills/specflow-snap/SKILL.md +46 -0
  173. package/skills/specflow-test/SKILL.md +48 -0
  174. package/skills/specflow-verify/SKILL.md +77 -0
  175. package/templates/design.md +19 -0
  176. package/templates/proposal.md +23 -0
  177. package/templates/spec.md +42 -0
  178. package/templates/tasks.md +9 -0
@@ -0,0 +1,276 @@
1
+ > **HARD GATE**: Wait for user confirmation after each task's review. Do NOT proceed to the next task until both spec compliance and code quality reviews pass and the user confirms.
2
+
3
+ <!-- SOURCE: skills/subagent-driven-development/SKILL.md -->
4
+
5
+ # Subagent-Driven Development (Phase B)
6
+
7
+ Execute plan by dispatching fresh subagent per task, with two-stage review after each: spec compliance review first, then code quality review.
8
+
9
+ **Why subagents:** You delegate tasks to specialized agents with isolated context. By precisely crafting their instructions and context, you ensure they stay focused and succeed at their task. They should never inherit your session's context or history -- you construct exactly what they need. This also preserves your own context for coordination work.
10
+
11
+ **Core principle:** Fresh subagent per task + two-stage review (spec then quality) = high quality, fast iteration
12
+
13
+ ## When to Use
14
+
15
+ ```dot
16
+ digraph when_to_use {
17
+ "Have implementation plan?" [shape=diamond];
18
+ "Tasks mostly independent?" [shape=diamond];
19
+ "Stay in this session?" [shape=diamond];
20
+ "specflow:build Phase B" [shape=box];
21
+ "specflow:build Phase B (inline mode)" [shape=box];
22
+ "Manual execution or brainstorm first" [shape=box];
23
+
24
+ "Have implementation plan?" -> "Tasks mostly independent?" [label="yes"];
25
+ "Have implementation plan?" -> "Manual execution or brainstorm first" [label="no"];
26
+ "Tasks mostly independent?" -> "Stay in this session?" [label="yes"];
27
+ "Tasks mostly independent?" -> "Manual execution or brainstorm first" [label="no - tightly coupled"];
28
+ "Stay in this session?" -> "specflow:build Phase B" [label="yes"];
29
+ "Stay in this session?" -> "specflow:build Phase B (inline mode)" [label="no - parallel session"];
30
+ }
31
+ ```
32
+
33
+ **vs. Inline Mode (parallel session):**
34
+ - Same session (no context switch)
35
+ - Fresh subagent per task (no context pollution)
36
+ - Two-stage review after each task: spec compliance first, then code quality
37
+ - Faster iteration (no human-in-loop between tasks)
38
+
39
+ ## The Process
40
+
41
+ ```dot
42
+ digraph process {
43
+ rankdir=TB;
44
+
45
+ subgraph cluster_per_task {
46
+ label="Per Task";
47
+ "Dispatch implementer subagent\n(Read .claude/specflow/prompts/shared/implementer-prompt.md)" [shape=box];
48
+ "Implementer subagent asks questions?" [shape=diamond];
49
+ "Answer questions, provide context" [shape=box];
50
+ "Implementer subagent implements, tests, commits, self-reviews" [shape=box];
51
+ "Dispatch spec reviewer subagent\n(Read .claude/specflow/prompts/shared/spec-reviewer-prompt.md)" [shape=box];
52
+ "Spec reviewer subagent confirms code matches spec?" [shape=diamond];
53
+ "Implementer subagent fixes spec gaps" [shape=box];
54
+ "Dispatch code quality reviewer subagent\n(Read .claude/specflow/prompts/shared/code-reviewer-prompt.md)" [shape=box];
55
+ "Code quality reviewer subagent approves?" [shape=diamond];
56
+ "Implementer subagent fixes quality issues" [shape=box];
57
+ "Mark task complete in TodoWrite" [shape=box];
58
+ }
59
+
60
+ "Read plan, extract all tasks with full text, note context, create TodoWrite" [shape=box];
61
+ "More tasks remain?" [shape=diamond];
62
+ "Dispatch final code reviewer subagent for entire implementation" [shape=box];
63
+ "Use specflow:done" [shape=box style=filled fillcolor=lightgreen];
64
+
65
+ "Read plan, extract all tasks with full text, note context, create TodoWrite" -> "Dispatch implementer subagent\n(Read .claude/specflow/prompts/shared/implementer-prompt.md)";
66
+ "Dispatch implementer subagent\n(Read .claude/specflow/prompts/shared/implementer-prompt.md)" -> "Implementer subagent asks questions?";
67
+ "Implementer subagent asks questions?" -> "Answer questions, provide context" [label="yes"];
68
+ "Answer questions, provide context" -> "Dispatch implementer subagent\n(Read .claude/specflow/prompts/shared/implementer-prompt.md)";
69
+ "Implementer subagent asks questions?" -> "Implementer subagent implements, tests, commits, self-reviews" [label="no"];
70
+ "Implementer subagent implements, tests, commits, self-reviews" -> "Dispatch spec reviewer subagent\n(Read .claude/specflow/prompts/shared/spec-reviewer-prompt.md)";
71
+ "Dispatch spec reviewer subagent\n(Read .claude/specflow/prompts/shared/spec-reviewer-prompt.md)" -> "Spec reviewer subagent confirms code matches spec?";
72
+ "Spec reviewer subagent confirms code matches spec?" -> "Implementer subagent fixes spec gaps" [label="no"];
73
+ "Implementer subagent fixes spec gaps" -> "Dispatch spec reviewer subagent\n(Read .claude/specflow/prompts/shared/spec-reviewer-prompt.md)" [label="re-review"];
74
+ "Spec reviewer subagent confirms code matches spec?" -> "Dispatch code quality reviewer subagent\n(Read .claude/specflow/prompts/shared/code-reviewer-prompt.md)" [label="yes"];
75
+ "Dispatch code quality reviewer subagent\n(Read .claude/specflow/prompts/shared/code-reviewer-prompt.md)" -> "Code quality reviewer subagent approves?";
76
+ "Code quality reviewer subagent approves?" -> "Implementer subagent fixes quality issues" [label="no"];
77
+ "Implementer subagent fixes quality issues" -> "Dispatch code quality reviewer subagent\n(Read .claude/specflow/prompts/shared/code-reviewer-prompt.md)" [label="re-review"];
78
+ "Code quality reviewer subagent approves?" -> "Mark task complete in TodoWrite" [label="yes"];
79
+ "Mark task complete in TodoWrite" -> "More tasks remain?";
80
+ "More tasks remain?" -> "Dispatch implementer subagent\n(Read .claude/specflow/prompts/shared/implementer-prompt.md)" [label="yes"];
81
+ "More tasks remain?" -> "Dispatch final code reviewer subagent for entire implementation" [label="no"];
82
+ "Dispatch final code reviewer subagent for entire implementation" -> "Use specflow:done";
83
+ }
84
+ ```
85
+
86
+ ## Model Selection
87
+
88
+ Use the least powerful model that can handle each role to conserve cost and increase speed.
89
+
90
+ **Mechanical implementation tasks** (isolated functions, clear specs, 1-2 files): use a fast, cheap model. Most implementation tasks are mechanical when the plan is well-specified.
91
+
92
+ **Integration and judgment tasks** (multi-file coordination, pattern matching, debugging): use a standard model.
93
+
94
+ **Architecture, design, and review tasks**: use the most capable available model.
95
+
96
+ **Task complexity signals:**
97
+ - Touches 1-2 files with a complete spec -> cheap model
98
+ - Touches multiple files with integration concerns -> standard model
99
+ - Requires design judgment or broad codebase understanding -> most capable model
100
+
101
+ ## Handling Implementer Status
102
+
103
+ Implementer subagents report one of four statuses. Handle each appropriately:
104
+
105
+ **DONE:** Proceed to spec compliance review.
106
+
107
+ **DONE_WITH_CONCERNS:** The implementer completed the work but flagged doubts. Read the concerns before proceeding. If the concerns are about correctness or scope, address them before review. If they're observations (e.g., "this file is getting large"), note them and proceed to review.
108
+
109
+ **NEEDS_CONTEXT:** The implementer needs information that wasn't provided. Provide the missing context and re-dispatch.
110
+
111
+ **BLOCKED:** The implementer cannot complete the task. Assess the blocker:
112
+ 1. If it's a context problem, provide more context and re-dispatch with the same model
113
+ 2. If the task requires more reasoning, re-dispatch with a more capable model
114
+ 3. If the task is too large, break it into smaller pieces
115
+ 4. If the plan itself is wrong, escalate to the human
116
+
117
+ **Never** ignore an escalation or force the same model to retry without changes. If the implementer said it's stuck, something needs to change.
118
+
119
+ ## Prompt Templates
120
+
121
+ - Read `.claude/specflow/prompts/shared/implementer-prompt.md` - Dispatch implementer subagent
122
+ - Read `.claude/specflow/prompts/shared/spec-reviewer-prompt.md` - Dispatch spec compliance reviewer subagent
123
+ - Read `.claude/specflow/prompts/shared/code-reviewer-prompt.md` - Dispatch code quality reviewer subagent
124
+
125
+ ## Example Workflow
126
+
127
+ ```
128
+ You: I'm using specflow:build Phase B to execute this plan.
129
+
130
+ [Read plan file once: specflow/changes/<change-name>/tasks.md]
131
+ [Extract all 5 tasks with full text and context]
132
+ [Create TodoWrite with all tasks]
133
+
134
+ Task 1: Hook installation script
135
+
136
+ [Get Task 1 text and context (already extracted)]
137
+ [Dispatch implementation subagent with full task text + context]
138
+
139
+ Implementer: "Before I begin - should the hook be installed at user or system level?"
140
+
141
+ You: "User level (~/.config/specflow/hooks/)"
142
+
143
+ Implementer: "Got it. Implementing now..."
144
+ [Later] Implementer:
145
+ - Implemented install-hook command
146
+ - Added tests, 5/5 passing
147
+ - Self-review: Found I missed --force flag, added it
148
+ - Committed
149
+
150
+ [Dispatch spec compliance reviewer]
151
+ Spec reviewer: Spec compliant - all requirements met, nothing extra
152
+
153
+ [Get git SHAs, dispatch code quality reviewer]
154
+ Code reviewer: Strengths: Good test coverage, clean. Issues: None. Approved.
155
+
156
+ [Mark Task 1 complete]
157
+
158
+ Task 2: Recovery modes
159
+
160
+ [Get Task 2 text and context (already extracted)]
161
+ [Dispatch implementation subagent with full task text + context]
162
+
163
+ Implementer: [No questions, proceeds]
164
+ Implementer:
165
+ - Added verify/repair modes
166
+ - 8/8 tests passing
167
+ - Self-review: All good
168
+ - Committed
169
+
170
+ [Dispatch spec compliance reviewer]
171
+ Spec reviewer: Issues:
172
+ - Missing: Progress reporting (spec says "report every 100 items")
173
+ - Extra: Added --json flag (not requested)
174
+
175
+ [Implementer fixes issues]
176
+ Implementer: Removed --json flag, added progress reporting
177
+
178
+ [Spec reviewer reviews again]
179
+ Spec reviewer: Spec compliant now
180
+
181
+ [Dispatch code quality reviewer]
182
+ Code reviewer: Strengths: Solid. Issues (Important): Magic number (100)
183
+
184
+ [Implementer fixes]
185
+ Implementer: Extracted PROGRESS_INTERVAL constant
186
+
187
+ [Code reviewer reviews again]
188
+ Code reviewer: Approved
189
+
190
+ [Mark Task 2 complete]
191
+
192
+ ...
193
+
194
+ [After all tasks]
195
+ [Dispatch final code-reviewer]
196
+ Final reviewer: All requirements met, ready to merge
197
+
198
+ Done!
199
+ ```
200
+
201
+ ## Advantages
202
+
203
+ **vs. Manual execution:**
204
+ - Subagents follow TDD naturally
205
+ - Fresh context per task (no confusion)
206
+ - Parallel-safe (subagents don't interfere)
207
+ - Subagent can ask questions (before AND during work)
208
+
209
+ **vs. Inline Mode:**
210
+ - Same session (no handoff)
211
+ - Continuous progress (no waiting)
212
+ - Review checkpoints automatic
213
+
214
+ **Efficiency gains:**
215
+ - No file reading overhead (controller provides full text)
216
+ - Controller curates exactly what context is needed
217
+ - Subagent gets complete information upfront
218
+ - Questions surfaced before work begins (not after)
219
+
220
+ **Quality gates:**
221
+ - Self-review catches issues before handoff
222
+ - Two-stage review: spec compliance, then code quality
223
+ - Review loops ensure fixes actually work
224
+ - Spec compliance prevents over/under-building
225
+ - Code quality ensures implementation is well-built
226
+
227
+ **Cost:**
228
+ - More subagent invocations (implementer + 2 reviewers per task)
229
+ - Controller does more prep work (extracting all tasks upfront)
230
+ - Review loops add iterations
231
+ - But catches issues early (cheaper than debugging later)
232
+
233
+ ## Red Flags
234
+
235
+ **Never:**
236
+ - Start implementation on main/master branch without explicit user consent
237
+ - Skip reviews (spec compliance OR code quality)
238
+ - Proceed with unfixed issues
239
+ - Dispatch multiple implementation subagents in parallel (conflicts)
240
+ - Make subagent read plan file (provide full text instead)
241
+ - Skip scene-setting context (subagent needs to understand where task fits)
242
+ - Ignore subagent questions (answer before letting them proceed)
243
+ - Accept "close enough" on spec compliance (spec reviewer found issues = not done)
244
+ - Skip review loops (reviewer found issues = implementer fixes = review again)
245
+ - Let implementer self-review replace actual review (both are needed)
246
+ - **Start code quality review before spec compliance passes** (wrong order)
247
+ - Move to next task while either review has open issues
248
+
249
+ **If subagent asks questions:**
250
+ - Answer clearly and completely
251
+ - Provide additional context if needed
252
+ - Don't rush them into implementation
253
+
254
+ **If reviewer finds issues:**
255
+ - Implementer (same subagent) fixes them
256
+ - Reviewer reviews again
257
+ - Repeat until approved
258
+ - Don't skip the re-review
259
+
260
+ **If subagent fails task:**
261
+ - Dispatch fix subagent with specific instructions
262
+ - Don't try to fix manually (context pollution)
263
+
264
+ ## Integration
265
+
266
+ **Required workflow skills:**
267
+ - **specflow:build Phase B (worktree)** - REQUIRED: Set up isolated workspace before starting
268
+ - **specflow:build Phase A** - Creates the plan this skill executes
269
+ - **specflow:review** - Code review template for reviewer subagents
270
+ - **specflow:done** - Complete development after all tasks
271
+
272
+ **Subagents should use:**
273
+ - **specflow:build TDD** - Subagents follow TDD for each task
274
+
275
+ **Alternative workflow:**
276
+ - **specflow:build Phase B (inline mode)** - Use for parallel session instead of same-session execution
@@ -0,0 +1,119 @@
1
+ > **HARD GATE**: Spec compliance must pass before code quality review. Do NOT start code quality review until the spec reviewer has approved. Running them in parallel or out of order is forbidden.
2
+
3
+ # Two-Phase Review Routing
4
+
5
+ Orchestration for the two-phase review process used during specflow:build Phase B. Each task's implementation goes through spec compliance first, then code quality.
6
+
7
+ ## Overview
8
+
9
+ Two sequential review phases ensure that code both matches the specification and meets quality standards. The order is non-negotiable: spec compliance first, code quality second.
10
+
11
+ **Why this order:** Code quality review on spec-noncompliant code is wasted effort. Fix what's wrong before polishing how it's built.
12
+
13
+ ## Phase 1: Spec Compliance Review
14
+
15
+ **Prompt source:** Read `.claude/specflow/prompts/shared/spec-reviewer-prompt.md`
16
+
17
+ **Purpose:** Verify the implementer built what was requested -- nothing more, nothing less.
18
+
19
+ **Dispatch:**
20
+ ```
21
+ Task tool (general-purpose):
22
+ description: "Review spec compliance for Task N"
23
+ prompt: [content from spec-reviewer-prompt.md with placeholders filled]
24
+ ```
25
+
26
+ **Inputs to provide:**
27
+ - Full text of the task requirements (from the plan)
28
+ - Implementer's report of what they claim they built
29
+ - File paths of changed files
30
+
31
+ **Expected output:**
32
+ - Spec compliant (all requirements met, nothing extra)
33
+ - OR: Issues found (list of missing/extra/misunderstood items with file:line references)
34
+
35
+ **If issues found:**
36
+ 1. Send issues back to the implementer subagent for fixes
37
+ 2. Re-dispatch spec reviewer after fixes
38
+ 3. Repeat until spec compliance passes
39
+ 4. Only THEN proceed to Phase 2
40
+
41
+ ## Phase 2: Code Quality Review
42
+
43
+ **Prompt source:** Read the `ReviewerFile` session context set after Stage B1b. Mapping details live in `.claude/specflow/prompts/build/language-router.md`. When `Language` is `unknown`, fall back to `.claude/specflow/prompts/shared/code-reviewer-prompt.md`.
44
+
45
+ **Purpose:** Verify the implementation is well-built -- clean, tested, maintainable, and language-appropriate when an ECC reviewer is selected.
46
+
47
+ **Dispatch:**
48
+ ```
49
+ Task tool (general-purpose):
50
+ description: "Review code quality for Task N"
51
+ prompt: [content from ReviewerFile with placeholders filled]
52
+ ```
53
+
54
+ **Inputs to provide:**
55
+ - What was implemented (from implementer's report)
56
+ - Plan or requirements reference
57
+ - Base SHA and Head SHA for the git range
58
+ - Brief description
59
+ - `Language` and `ReviewerFile` from Stage B1b
60
+
61
+ **Expected output when using an ECC reviewer:**
62
+ - Severity breakdown: `CRITICAL`, `HIGH`, `MEDIUM`
63
+ - Explicit verdict: `Approve`, `Warning`, or `Block`
64
+ - File-level findings with remediation guidance
65
+
66
+ **Verdict routing:**
67
+ - `Block`: return task to implementer with specific findings; do not advance to Gate B until a subsequent review produces `Approve` or `Warning`
68
+ - `Warning`: proceed to Gate B with MEDIUM findings visible in the task summary
69
+ - `Approve`: proceed directly to Gate B
70
+
71
+ **Diagnostic commands:**
72
+ Language-specific reviewers may run diagnostic commands listed in their prompt files (for example `tsc --noEmit`, `eslint`, `mypy`, `go vet`, `cargo clippy`). If a command is unavailable in the environment, record the skip and continue the review rather than failing the entire review pass.
73
+
74
+ **If issues found:**
75
+ 1. Send issues back to the implementer subagent for fixes
76
+ 2. Re-dispatch code quality reviewer after fixes
77
+ 3. Repeat until approved
78
+
79
+ ## Flow
80
+
81
+ ```dot
82
+ digraph review_routing {
83
+ rankdir=TB;
84
+
85
+ "Task implementation complete" [shape=box];
86
+ "Dispatch spec reviewer\n(Phase 1)" [shape=box];
87
+ "Spec compliant?" [shape=diamond];
88
+ "Implementer fixes spec issues" [shape=box];
89
+ "Dispatch code quality reviewer\n(Phase 2)" [shape=box];
90
+ "Quality approved?" [shape=diamond];
91
+ "Implementer fixes quality issues" [shape=box];
92
+ "Task review complete" [shape=doublecircle];
93
+
94
+ "Task implementation complete" -> "Dispatch spec reviewer\n(Phase 1)";
95
+ "Dispatch spec reviewer\n(Phase 1)" -> "Spec compliant?";
96
+ "Spec compliant?" -> "Implementer fixes spec issues" [label="no"];
97
+ "Implementer fixes spec issues" -> "Dispatch spec reviewer\n(Phase 1)" [label="re-review"];
98
+ "Spec compliant?" -> "Dispatch code quality reviewer\n(Phase 2)" [label="yes"];
99
+ "Dispatch code quality reviewer\n(Phase 2)" -> "Quality approved?";
100
+ "Quality approved?" -> "Implementer fixes quality issues" [label="no"];
101
+ "Implementer fixes quality issues" -> "Dispatch code quality reviewer\n(Phase 2)" [label="re-review"];
102
+ "Quality approved?" -> "Task review complete" [label="yes"];
103
+ }
104
+ ```
105
+
106
+ ## Red Flags
107
+
108
+ **Never:**
109
+ - Run code quality review before spec compliance passes
110
+ - Run both reviews in parallel
111
+ - Skip the re-review loop after fixes
112
+ - Accept "close enough" on spec compliance
113
+ - Let the implementer self-review replace either formal review
114
+
115
+ **Always:**
116
+ - Spec compliance first, code quality second
117
+ - Loop until each phase passes
118
+ - Provide full task context to each reviewer
119
+ - Wait for user confirmation after both phases pass
@@ -0,0 +1,215 @@
1
+ <!-- SOURCE: skills/using-git-worktrees/SKILL.md -->
2
+
3
+ # Using Git Worktrees
4
+
5
+ ## Overview
6
+
7
+ Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
8
+
9
+ **Core principle:** Systematic directory selection + safety verification = reliable isolation.
10
+
11
+ **Announce at start:** "I'm using the git-worktrees skill to set up an isolated workspace."
12
+
13
+ ## Directory Selection Process
14
+
15
+ Follow this priority order:
16
+
17
+ ### 1. Check Existing Directories
18
+
19
+ ```bash
20
+ # Check in priority order
21
+ ls -d .worktrees 2>/dev/null # Preferred (hidden)
22
+ ls -d worktrees 2>/dev/null # Alternative
23
+ ```
24
+
25
+ **If found:** Use that directory. If both exist, `.worktrees` wins.
26
+
27
+ ### 2. Check CLAUDE.md
28
+
29
+ ```bash
30
+ grep -i "worktree.*director" CLAUDE.md 2>/dev/null
31
+ ```
32
+
33
+ **If preference specified:** Use it without asking.
34
+
35
+ ### 3. Ask User
36
+
37
+ If no directory exists and no CLAUDE.md preference:
38
+
39
+ ```
40
+ No worktree directory found. Where should I create worktrees?
41
+
42
+ 1. .worktrees/ (project-local, hidden)
43
+ 2. ~/.config/specflow/worktrees/<project-name>/ (global location)
44
+
45
+ Which would you prefer?
46
+ ```
47
+
48
+ ## Safety Verification
49
+
50
+ ### For Project-Local Directories (.worktrees or worktrees)
51
+
52
+ **MUST verify directory is ignored before creating worktree:**
53
+
54
+ ```bash
55
+ # Check if directory is ignored (respects local, global, and system gitignore)
56
+ git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
57
+ ```
58
+
59
+ **If NOT ignored:**
60
+
61
+ Fix broken things immediately:
62
+ 1. Add appropriate line to .gitignore
63
+ 2. Commit the change
64
+ 3. Proceed with worktree creation
65
+
66
+ **Why critical:** Prevents accidentally committing worktree contents to repository.
67
+
68
+ ### For Global Directory (~/.config/specflow/worktrees)
69
+
70
+ No .gitignore verification needed - outside project entirely.
71
+
72
+ ## Creation Steps
73
+
74
+ ### 1. Detect Project Name
75
+
76
+ ```bash
77
+ project=$(basename "$(git rev-parse --show-toplevel)")
78
+ ```
79
+
80
+ ### 2. Create Worktree
81
+
82
+ ```bash
83
+ # Determine full path
84
+ case $LOCATION in
85
+ .worktrees|worktrees)
86
+ path="$LOCATION/$BRANCH_NAME"
87
+ ;;
88
+ ~/.config/specflow/worktrees/*)
89
+ path="~/.config/specflow/worktrees/$project/$BRANCH_NAME"
90
+ ;;
91
+ esac
92
+
93
+ # Create worktree with new branch
94
+ git worktree add "$path" -b "$BRANCH_NAME"
95
+ cd "$path"
96
+ ```
97
+
98
+ ### 3. Run Project Setup
99
+
100
+ Auto-detect and run appropriate setup:
101
+
102
+ ```bash
103
+ # Node.js
104
+ if [ -f package.json ]; then npm install; fi
105
+
106
+ # Rust
107
+ if [ -f Cargo.toml ]; then cargo build; fi
108
+
109
+ # Python
110
+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
111
+ if [ -f pyproject.toml ]; then poetry install; fi
112
+
113
+ # Go
114
+ if [ -f go.mod ]; then go mod download; fi
115
+ ```
116
+
117
+ ### 4. Verify Clean Baseline
118
+
119
+ Run tests to ensure worktree starts clean:
120
+
121
+ ```bash
122
+ # Examples - use project-appropriate command
123
+ npm test
124
+ cargo test
125
+ pytest
126
+ go test ./...
127
+ ```
128
+
129
+ **If tests fail:** Report failures, ask whether to proceed or investigate.
130
+
131
+ **If tests pass:** Report ready.
132
+
133
+ ### 5. Report Location
134
+
135
+ ```
136
+ Worktree ready at <full-path>
137
+ Tests passing (<N> tests, 0 failures)
138
+ Ready to implement <feature-name>
139
+ ```
140
+
141
+ ## Quick Reference
142
+
143
+ | Situation | Action |
144
+ |-----------|--------|
145
+ | `.worktrees/` exists | Use it (verify ignored) |
146
+ | `worktrees/` exists | Use it (verify ignored) |
147
+ | Both exist | Use `.worktrees/` |
148
+ | Neither exists | Check CLAUDE.md -> Ask user |
149
+ | Directory not ignored | Add to .gitignore + commit |
150
+ | Tests fail during baseline | Report failures + ask |
151
+ | No package.json/Cargo.toml | Skip dependency install |
152
+
153
+ ## Common Mistakes
154
+
155
+ ### Skipping ignore verification
156
+
157
+ - **Problem:** Worktree contents get tracked, pollute git status
158
+ - **Fix:** Always use `git check-ignore` before creating project-local worktree
159
+
160
+ ### Assuming directory location
161
+
162
+ - **Problem:** Creates inconsistency, violates project conventions
163
+ - **Fix:** Follow priority: existing > CLAUDE.md > ask
164
+
165
+ ### Proceeding with failing tests
166
+
167
+ - **Problem:** Can't distinguish new bugs from pre-existing issues
168
+ - **Fix:** Report failures, get explicit permission to proceed
169
+
170
+ ### Hardcoding setup commands
171
+
172
+ - **Problem:** Breaks on projects using different tools
173
+ - **Fix:** Auto-detect from project files (package.json, etc.)
174
+
175
+ ## Example Workflow
176
+
177
+ ```
178
+ You: I'm using the git-worktrees skill to set up an isolated workspace.
179
+
180
+ [Check .worktrees/ - exists]
181
+ [Verify ignored - git check-ignore confirms .worktrees/ is ignored]
182
+ [Create worktree: git worktree add .worktrees/auth -b feature/auth]
183
+ [Run npm install]
184
+ [Run npm test - 47 passing]
185
+
186
+ Worktree ready at /Users/dev/myproject/.worktrees/auth
187
+ Tests passing (47 tests, 0 failures)
188
+ Ready to implement auth feature
189
+ ```
190
+
191
+ ## Red Flags
192
+
193
+ **Never:**
194
+ - Create worktree without verifying it's ignored (project-local)
195
+ - Skip baseline test verification
196
+ - Proceed with failing tests without asking
197
+ - Assume directory location when ambiguous
198
+ - Skip CLAUDE.md check
199
+
200
+ **Always:**
201
+ - Follow directory priority: existing > CLAUDE.md > ask
202
+ - Verify directory is ignored for project-local
203
+ - Auto-detect and run project setup
204
+ - Verify clean test baseline
205
+
206
+ ## Integration
207
+
208
+ **Called by:**
209
+ - **specflow:refine** (Phase 4) - REQUIRED when design is approved and implementation follows
210
+ - **specflow:build Phase B** - REQUIRED before executing any tasks
211
+ - **specflow:build Phase B (inline mode)** - REQUIRED before executing any tasks
212
+ - Any skill needing isolated workspace
213
+
214
+ **Pairs with:**
215
+ - **specflow:done** - REQUIRED for cleanup after work complete
@@ -0,0 +1,51 @@
1
+ <!-- SOURCE: skills/writing-plans/plan-document-reviewer-prompt.md -->
2
+
3
+ # Plan Document Reviewer Prompt Template
4
+
5
+ Use this template when dispatching a plan document reviewer subagent.
6
+
7
+ **Purpose:** Verify the plan is complete, matches the spec, and has proper task decomposition.
8
+
9
+ **Dispatch after:** The complete plan is written.
10
+
11
+ ```
12
+ Task tool (general-purpose):
13
+ description: "Review plan document"
14
+ prompt: |
15
+ You are a plan document reviewer. Verify this plan is complete and ready for implementation.
16
+
17
+ **Plan to review:** [PLAN_FILE_PATH]
18
+ **Spec for reference:** [SPEC_FILE_PATH]
19
+
20
+ ## What to Check
21
+
22
+ | Category | What to Look For |
23
+ |----------|------------------|
24
+ | Completeness | TODOs, placeholders, incomplete tasks, missing steps |
25
+ | Spec Alignment | Plan covers spec requirements, no major scope creep |
26
+ | Task Decomposition | Tasks have clear boundaries, steps are actionable |
27
+ | Buildability | Could an engineer follow this plan without getting stuck? |
28
+
29
+ ## Calibration
30
+
31
+ **Only flag issues that would cause real problems during implementation.**
32
+ An implementer building the wrong thing or getting stuck is an issue.
33
+ Minor wording, stylistic preferences, and "nice to have" suggestions are not.
34
+
35
+ Approve unless there are serious gaps -- missing requirements from the spec,
36
+ contradictory steps, placeholder content, or tasks so vague they can't be acted on.
37
+
38
+ ## Output Format
39
+
40
+ ## Plan Review
41
+
42
+ **Status:** Approved | Issues Found
43
+
44
+ **Issues (if any):**
45
+ - [Task X, Step Y]: [specific issue] - [why it matters for implementation]
46
+
47
+ **Recommendations (advisory, do not block approval):**
48
+ - [suggestions for improvement]
49
+ ```
50
+
51
+ **Reviewer returns:** Status, Issues (if any), Recommendations