@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,184 @@
1
+ > **HARD GATE**: Test must FAIL before writing implementation. If you write production code before seeing a failing test, delete it and start over. No exceptions.
2
+
3
+ <!-- SOURCE: skills/test-driven-development/SKILL.md -->
4
+
5
+ # Test-Driven Development (Build Variant)
6
+
7
+ Per-task atomic TDD for the build phase. Each task in the plan follows Red-Green-Refactor strictly.
8
+
9
+ ## Overview
10
+
11
+ Write the test first. Watch it fail. Write minimal code to pass.
12
+
13
+ **Core principle:** If you didn't watch the test fail, you don't know if it tests the right thing.
14
+
15
+ **Violating the letter of the rules is violating the spirit of the rules.**
16
+
17
+ ## When to Use
18
+
19
+ **Always during build phase tasks:**
20
+ - Each task in the implementation plan
21
+ - Bug fixes discovered during implementation
22
+ - Behavior changes within a task
23
+
24
+ **Exceptions (ask your human partner):**
25
+ - Throwaway prototypes
26
+ - Generated code
27
+ - Configuration files
28
+
29
+ ## The Iron Law
30
+
31
+ ```
32
+ NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
33
+ ```
34
+
35
+ Write code before the test? Delete it. Start over.
36
+
37
+ **No exceptions:**
38
+ - Don't keep it as "reference"
39
+ - Don't "adapt" it while writing tests
40
+ - Don't look at it
41
+ - Delete means delete
42
+
43
+ Implement fresh from tests. Period.
44
+
45
+ ## Red-Green-Refactor
46
+
47
+ ```dot
48
+ digraph tdd_cycle {
49
+ rankdir=LR;
50
+ red [label="RED\nWrite failing test", shape=box, style=filled, fillcolor="#ffcccc"];
51
+ verify_red [label="Verify fails\ncorrectly", shape=diamond];
52
+ green [label="GREEN\nMinimal code", shape=box, style=filled, fillcolor="#ccffcc"];
53
+ verify_green [label="Verify passes\nAll green", shape=diamond];
54
+ refactor [label="REFACTOR\nClean up", shape=box, style=filled, fillcolor="#ccccff"];
55
+ next [label="Next", shape=ellipse];
56
+
57
+ red -> verify_red;
58
+ verify_red -> green [label="yes"];
59
+ verify_red -> red [label="wrong\nfailure"];
60
+ green -> verify_green;
61
+ verify_green -> refactor [label="yes"];
62
+ verify_green -> green [label="no"];
63
+ refactor -> verify_green [label="stay\ngreen"];
64
+ verify_green -> next;
65
+ next -> red;
66
+ }
67
+ ```
68
+
69
+ ### RED - Write Failing Test
70
+
71
+ Write one minimal test showing what should happen.
72
+
73
+ **Requirements:**
74
+ - One behavior per test
75
+ - Clear, descriptive name
76
+ - Real code (no mocks unless unavoidable)
77
+
78
+ ### Verify RED - Watch It Fail
79
+
80
+ **MANDATORY. Never skip.**
81
+
82
+ ```bash
83
+ <test-runner> path/to/test
84
+ ```
85
+
86
+ Confirm:
87
+ - Test fails (not errors)
88
+ - Failure message is expected
89
+ - Fails because feature missing (not typos)
90
+
91
+ **Test passes?** You're testing existing behavior. Fix test.
92
+
93
+ **Test errors?** Fix error, re-run until it fails correctly.
94
+
95
+ ### GREEN - Minimal Code
96
+
97
+ Write simplest code to pass the test. Don't add features, refactor other code, or "improve" beyond the test.
98
+
99
+ ### Verify GREEN - Watch It Pass
100
+
101
+ **MANDATORY.**
102
+
103
+ Confirm:
104
+ - Test passes
105
+ - Other tests still pass
106
+ - Output pristine (no errors, warnings)
107
+
108
+ **Test fails?** Fix code, not test.
109
+
110
+ **Other tests fail?** Fix now.
111
+
112
+ ### REFACTOR - Clean Up
113
+
114
+ After green only:
115
+ - Remove duplication
116
+ - Improve names
117
+ - Extract helpers
118
+
119
+ Keep tests green. Don't add behavior.
120
+
121
+ ### Repeat
122
+
123
+ Next failing test for next behavior in the task.
124
+
125
+ ## Per-Task Commit Pattern
126
+
127
+ Each task in the plan should follow this atomic cycle:
128
+
129
+ 1. Write failing test for first behavior -> verify RED
130
+ 2. Write minimal implementation -> verify GREEN
131
+ 3. Refactor if needed -> verify still GREEN
132
+ 4. Repeat for remaining behaviors in the task
133
+ 5. Commit all changes for the task
134
+
135
+ ## Red Flags - STOP and Start Over
136
+
137
+ - Code before test
138
+ - Test after implementation
139
+ - Test passes immediately
140
+ - Can't explain why test failed
141
+ - Tests added "later"
142
+ - Rationalizing "just this once"
143
+
144
+ **All of these mean: Delete code. Start over with TDD.**
145
+
146
+ ## Verification Checklist (Per Task)
147
+
148
+ Before marking a task complete:
149
+
150
+ - [ ] Every new function/method has a test
151
+ - [ ] Watched each test fail before implementing
152
+ - [ ] Each test failed for expected reason (feature missing, not typo)
153
+ - [ ] Wrote minimal code to pass each test
154
+ - [ ] All tests pass
155
+ - [ ] Output pristine (no errors, warnings)
156
+ - [ ] Tests use real code (mocks only if unavoidable)
157
+ - [ ] Edge cases and errors covered
158
+
159
+ ## Common Rationalizations
160
+
161
+ | Excuse | Reality |
162
+ |--------|---------|
163
+ | "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
164
+ | "I'll test after" | Tests passing immediately prove nothing. |
165
+ | "Need to explore first" | Fine. Throw away exploration, start with TDD. |
166
+ | "Test hard = design unclear" | Listen to test. Hard to test = hard to use. |
167
+
168
+ ## When Stuck
169
+
170
+ | Problem | Solution |
171
+ |---------|----------|
172
+ | Don't know how to test | Write wished-for API. Write assertion first. |
173
+ | Test too complicated | Design too complicated. Simplify interface. |
174
+ | Must mock everything | Code too coupled. Use dependency injection. |
175
+ | Test setup huge | Extract helpers. Still complex? Simplify design. |
176
+
177
+ ## Final Rule
178
+
179
+ ```
180
+ Production code -> test exists and failed first
181
+ Otherwise -> not TDD
182
+ ```
183
+
184
+ No exceptions without your human partner's permission.
@@ -0,0 +1,204 @@
1
+ <!-- SOURCE: skills/finishing-a-development-branch/SKILL.md -->
2
+
3
+ # Finishing a Development Branch
4
+
5
+ ## Overview
6
+
7
+ Guide completion of development work by presenting clear options and handling chosen workflow.
8
+
9
+ **Core principle:** Verify tests -> Present options -> Execute choice -> Clean up.
10
+
11
+ **Announce at start:** "I'm using specflow:done to complete this work."
12
+
13
+ ## The Process
14
+
15
+ ### Step 1: Verify Tests
16
+
17
+ **Before presenting options, verify tests pass:**
18
+
19
+ ```bash
20
+ # Run project's test suite
21
+ npm test / cargo test / pytest / go test ./...
22
+ ```
23
+
24
+ **If tests fail:**
25
+ ```
26
+ Tests failing (<N> failures). Must fix before completing:
27
+
28
+ [Show failures]
29
+
30
+ Cannot proceed with merge/PR until tests pass.
31
+ ```
32
+
33
+ Stop. Don't proceed to Step 2.
34
+
35
+ **If tests pass:** Continue to Step 2.
36
+
37
+ ### Step 2: Determine Base Branch
38
+
39
+ Detect the repository's default base branch — common names are `main`, `master`, or `trunk`:
40
+
41
+ ```bash
42
+ # Try to detect the default branch from the remote
43
+ git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'
44
+
45
+ # Fallback: check which common base branch exists
46
+ for b in main master trunk; do git rev-parse --verify "$b" >/dev/null 2>&1 && echo "$b" && break; done
47
+ ```
48
+
49
+ Use whichever base branch the detection returns in all subsequent steps and in the option labels. When presenting the options to the user, substitute the actual branch name (e.g., show "Merge back to `master` locally" if master is the base).
50
+
51
+ If detection fails or returns ambiguous results, ask the user: "What base branch should this merge target? (detected: none — typical choices are main, master, trunk)"
52
+
53
+ ### Step 3: Present Options
54
+
55
+ Present exactly these 4 options:
56
+
57
+ ```
58
+ Implementation complete. What would you like to do?
59
+
60
+ 1. Merge back to <base-branch> locally
61
+ 2. Push and create a Pull Request
62
+ 3. Keep the branch as-is (I'll handle it later)
63
+ 4. Discard this work
64
+
65
+ Which option?
66
+ ```
67
+
68
+ **Don't add explanation** - keep options concise.
69
+
70
+ ### Step 4: Execute Choice
71
+
72
+ #### Option 1: Merge Locally
73
+
74
+ ```bash
75
+ # Switch to base branch
76
+ git checkout <base-branch>
77
+
78
+ # Pull latest
79
+ git pull
80
+
81
+ # Merge feature branch
82
+ git merge <feature-branch>
83
+
84
+ # Verify tests on merged result
85
+ <test command>
86
+
87
+ # If tests pass
88
+ git branch -d <feature-branch>
89
+ ```
90
+
91
+ Then: Cleanup worktree (Step 5)
92
+
93
+ #### Option 2: Push and Create PR
94
+
95
+ ```bash
96
+ # Push branch
97
+ git push -u origin <feature-branch>
98
+
99
+ # Create PR
100
+ gh pr create --title "<title>" --body "$(cat <<'EOF'
101
+ ## Summary
102
+ <2-3 bullets of what changed>
103
+
104
+ ## Test Plan
105
+ - [ ] <verification steps>
106
+ EOF
107
+ )"
108
+ ```
109
+
110
+ Then: Cleanup worktree (Step 5)
111
+
112
+ #### Option 3: Keep As-Is
113
+
114
+ Report: "Keeping branch <name>. Worktree preserved at <path>."
115
+
116
+ **Don't cleanup worktree.**
117
+
118
+ #### Option 4: Discard
119
+
120
+ **Confirm first:**
121
+ ```
122
+ This will permanently delete:
123
+ - Branch <name>
124
+ - All commits: <commit-list>
125
+ - Worktree at <path>
126
+
127
+ Type 'discard' to confirm.
128
+ ```
129
+
130
+ Wait for exact confirmation.
131
+
132
+ If confirmed:
133
+ ```bash
134
+ git checkout <base-branch>
135
+ git branch -D <feature-branch>
136
+ ```
137
+
138
+ Then: Cleanup worktree (Step 5)
139
+
140
+ ### Step 5: Cleanup Worktree
141
+
142
+ **For Options 1, 2, 4:**
143
+
144
+ Check if in worktree:
145
+ ```bash
146
+ git worktree list | grep $(git branch --show-current)
147
+ ```
148
+
149
+ If yes:
150
+ ```bash
151
+ git worktree remove <worktree-path>
152
+ ```
153
+
154
+ **For Option 3:** Keep worktree.
155
+
156
+ ## Quick Reference
157
+
158
+ | Option | Merge | Push | Keep Worktree | Cleanup Branch |
159
+ |--------|-------|------|---------------|----------------|
160
+ | 1. Merge locally | Y | - | - | Y |
161
+ | 2. Create PR | - | Y | Y | - |
162
+ | 3. Keep as-is | - | - | Y | - |
163
+ | 4. Discard | - | - | - | Y (force) |
164
+
165
+ ## Common Mistakes
166
+
167
+ **Skipping test verification**
168
+ - **Problem:** Merge broken code, create failing PR
169
+ - **Fix:** Always verify tests before offering options
170
+
171
+ **Open-ended questions**
172
+ - **Problem:** "What should I do next?" leads to ambiguity
173
+ - **Fix:** Present exactly 4 structured options
174
+
175
+ **Automatic worktree cleanup**
176
+ - **Problem:** Remove worktree when might need it (Option 2, 3)
177
+ - **Fix:** Only cleanup for Options 1 and 4
178
+
179
+ **No confirmation for discard**
180
+ - **Problem:** Accidentally delete work
181
+ - **Fix:** Require typed "discard" confirmation
182
+
183
+ ## Red Flags
184
+
185
+ **Never:**
186
+ - Proceed with failing tests
187
+ - Merge without verifying tests on result
188
+ - Delete work without confirmation
189
+ - Force-push without explicit request
190
+
191
+ **Always:**
192
+ - Verify tests before offering options
193
+ - Present exactly 4 options
194
+ - Get typed confirmation for Option 4
195
+ - Clean up worktree for Options 1 and 4 only
196
+
197
+ ## Integration
198
+
199
+ **Called by:**
200
+ - **specflow:build Phase B** (final step) - After all tasks complete
201
+ - **specflow:build Phase B (inline mode)** (final step) - After all batches complete
202
+
203
+ **Pairs with:**
204
+ - **specflow:build Phase B (worktree)** - Cleans up worktree created by that skill
@@ -0,0 +1,249 @@
1
+ <!-- SOURCE: skills/systematic-debugging/SKILL.md -->
2
+
3
+ # Systematic Debugging
4
+
5
+ ## Overview
6
+
7
+ Random fixes waste time and create new bugs. Quick patches mask underlying issues.
8
+
9
+ **Core principle:** ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
10
+
11
+ **Violating the letter of this process is violating the spirit of debugging.**
12
+
13
+ ## Spec Awareness
14
+
15
+ **Before beginning investigation:** Read relevant specs from `specflow/specs/` to understand expected behavior. Knowing the declared behavior helps distinguish bugs from intended behavior and prevents "fixing" things that are working as designed.
16
+
17
+ If `specflow/specs/` exists:
18
+ 1. Identify which specs relate to the failing component
19
+ 2. Read the WHEN/THEN scenarios for expected behavior
20
+ 3. Compare observed behavior against spec expectations
21
+ 4. Use specs to inform your root cause hypothesis
22
+
23
+ ## The Iron Law
24
+
25
+ ```
26
+ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
27
+ ```
28
+
29
+ If you haven't completed Phase 1, you cannot propose fixes.
30
+
31
+ ## When to Use
32
+
33
+ Use for ANY technical issue:
34
+ - Test failures
35
+ - Bugs in production
36
+ - Unexpected behavior
37
+ - Performance problems
38
+ - Build failures
39
+ - Integration issues
40
+
41
+ **Use this ESPECIALLY when:**
42
+ - Under time pressure (emergencies make guessing tempting)
43
+ - "Just one quick fix" seems obvious
44
+ - You've already tried multiple fixes
45
+ - Previous fix didn't work
46
+ - You don't fully understand the issue
47
+
48
+ **Don't skip when:**
49
+ - Issue seems simple (simple bugs have root causes too)
50
+ - You're in a hurry (rushing guarantees rework)
51
+ - Manager wants it fixed NOW (systematic is faster than thrashing)
52
+
53
+ ## The Four Phases
54
+
55
+ You MUST complete each phase before proceeding to the next.
56
+
57
+ ### Phase 1: Root Cause Investigation
58
+
59
+ **BEFORE attempting ANY fix:**
60
+
61
+ 1. **Read Error Messages Carefully**
62
+ - Don't skip past errors or warnings
63
+ - They often contain the exact solution
64
+ - Read stack traces completely
65
+ - Note line numbers, file paths, error codes
66
+
67
+ 2. **Reproduce Consistently**
68
+ - Can you trigger it reliably?
69
+ - What are the exact steps?
70
+ - Does it happen every time?
71
+ - If not reproducible -> gather more data, don't guess
72
+
73
+ 3. **Check Recent Changes**
74
+ - What changed that could cause this?
75
+ - Git diff, recent commits
76
+ - New dependencies, config changes
77
+ - Environmental differences
78
+
79
+ 4. **Gather Evidence in Multi-Component Systems**
80
+
81
+ **WHEN system has multiple components (CI -> build -> signing, API -> service -> database):**
82
+
83
+ **BEFORE proposing fixes, add diagnostic instrumentation:**
84
+ ```
85
+ For EACH component boundary:
86
+ - Log what data enters component
87
+ - Log what data exits component
88
+ - Verify environment/config propagation
89
+ - Check state at each layer
90
+
91
+ Run once to gather evidence showing WHERE it breaks
92
+ THEN analyze evidence to identify failing component
93
+ THEN investigate that specific component
94
+ ```
95
+
96
+ 5. **Trace Data Flow**
97
+
98
+ **WHEN error is deep in call stack:**
99
+ - Where does bad value originate?
100
+ - What called this with bad value?
101
+ - Keep tracing up until you find the source
102
+ - Fix at source, not at symptom
103
+
104
+ ### Phase 2: Pattern Analysis
105
+
106
+ **Find the pattern before fixing:**
107
+
108
+ 1. **Find Working Examples**
109
+ - Locate similar working code in same codebase
110
+ - What works that's similar to what's broken?
111
+
112
+ 2. **Compare Against References**
113
+ - If implementing pattern, read reference implementation COMPLETELY
114
+ - Don't skim - read every line
115
+ - Understand the pattern fully before applying
116
+
117
+ 3. **Identify Differences**
118
+ - What's different between working and broken?
119
+ - List every difference, however small
120
+ - Don't assume "that can't matter"
121
+
122
+ 4. **Understand Dependencies**
123
+ - What other components does this need?
124
+ - What settings, config, environment?
125
+ - What assumptions does it make?
126
+
127
+ ### Phase 3: Hypothesis and Testing
128
+
129
+ **Scientific method:**
130
+
131
+ 1. **Form Single Hypothesis**
132
+ - State clearly: "I think X is the root cause because Y"
133
+ - Write it down
134
+ - Be specific, not vague
135
+
136
+ 2. **Test Minimally**
137
+ - Make the SMALLEST possible change to test hypothesis
138
+ - One variable at a time
139
+ - Don't fix multiple things at once
140
+
141
+ 3. **Verify Before Continuing**
142
+ - Did it work? Yes -> Phase 4
143
+ - Didn't work? Form NEW hypothesis
144
+ - DON'T add more fixes on top
145
+
146
+ 4. **When You Don't Know**
147
+ - Say "I don't understand X"
148
+ - Don't pretend to know
149
+ - Ask for help
150
+ - Research more
151
+
152
+ ### Phase 4: Implementation
153
+
154
+ **Fix the root cause, not the symptom:**
155
+
156
+ 1. **Create Failing Test Case**
157
+ - Simplest possible reproduction
158
+ - Automated test if possible
159
+ - One-off test script if no framework
160
+ - MUST have before fixing
161
+ - Use specflow:test or specflow:build TDD for writing proper failing tests
162
+
163
+ 2. **Implement Single Fix**
164
+ - Address the root cause identified
165
+ - ONE change at a time
166
+ - No "while I'm here" improvements
167
+ - No bundled refactoring
168
+
169
+ 3. **Verify Fix**
170
+ - Test passes now?
171
+ - No other tests broken?
172
+ - Issue actually resolved?
173
+
174
+ 4. **If Fix Doesn't Work**
175
+ - STOP
176
+ - Count: How many fixes have you tried?
177
+ - If < 3: Return to Phase 1, re-analyze with new information
178
+ - **If >= 3: STOP and question the architecture (step 5 below)**
179
+ - DON'T attempt Fix #4 without architectural discussion
180
+
181
+ 5. **If 3+ Fixes Failed: Question Architecture**
182
+
183
+ **Pattern indicating architectural problem:**
184
+ - Each fix reveals new shared state/coupling/problem in different place
185
+ - Fixes require "massive refactoring" to implement
186
+ - Each fix creates new symptoms elsewhere
187
+
188
+ **STOP and question fundamentals:**
189
+ - Is this pattern fundamentally sound?
190
+ - Are we "sticking with it through sheer inertia"?
191
+ - Should we refactor architecture vs. continue fixing symptoms?
192
+
193
+ **Discuss with your human partner before attempting more fixes**
194
+
195
+ This is NOT a failed hypothesis - this is a wrong architecture.
196
+
197
+ ## Red Flags - STOP and Follow Process
198
+
199
+ If you catch yourself thinking:
200
+ - "Quick fix for now, investigate later"
201
+ - "Just try changing X and see if it works"
202
+ - "Add multiple changes, run tests"
203
+ - "Skip the test, I'll manually verify"
204
+ - "It's probably X, let me fix that"
205
+ - "I don't fully understand but this might work"
206
+ - "Pattern says X but I'll adapt it differently"
207
+ - "Here are the main problems: [lists fixes without investigation]"
208
+ - Proposing solutions before tracing data flow
209
+ - **"One more fix attempt" (when already tried 2+)**
210
+ - **Each fix reveals new problem in different place**
211
+
212
+ **ALL of these mean: STOP. Return to Phase 1.**
213
+
214
+ **If 3+ fixes failed:** Question the architecture (see Phase 4.5)
215
+
216
+ ## Common Rationalizations
217
+
218
+ | Excuse | Reality |
219
+ |--------|---------|
220
+ | "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
221
+ | "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
222
+ | "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
223
+ | "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
224
+ | "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
225
+ | "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
226
+ | "I see the problem, let me fix it" | Seeing symptoms does not equal understanding root cause. |
227
+ | "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
228
+
229
+ ## Quick Reference
230
+
231
+ | Phase | Key Activities | Success Criteria |
232
+ |-------|---------------|------------------|
233
+ | **1. Root Cause** | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |
234
+ | **2. Pattern** | Find working examples, compare | Identify differences |
235
+ | **3. Hypothesis** | Form theory, test minimally | Confirmed or new hypothesis |
236
+ | **4. Implementation** | Create test, fix, verify | Bug resolved, tests pass |
237
+
238
+ ## Related Skills
239
+
240
+ - **specflow:test** or **specflow:build TDD** - For creating failing test case (Phase 4, Step 1)
241
+ - **specflow:verify** - Verify fix worked before claiming success
242
+
243
+ ## Real-World Impact
244
+
245
+ From debugging sessions:
246
+ - Systematic approach: 15-30 minutes to fix
247
+ - Random fixes approach: 2-3 hours of thrashing
248
+ - First-time fix rate: 95% vs 40%
249
+ - New bugs introduced: Near zero vs common