@curdx/flow 1.1.4 → 1.1.6

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 (89) hide show
  1. package/.claude-plugin/marketplace.json +25 -0
  2. package/.claude-plugin/plugin.json +43 -0
  3. package/CHANGELOG.md +279 -0
  4. package/agent-preamble/preamble.md +214 -0
  5. package/agents/flow-adversary.md +216 -0
  6. package/agents/flow-architect.md +190 -0
  7. package/agents/flow-debugger.md +325 -0
  8. package/agents/flow-edge-hunter.md +273 -0
  9. package/agents/flow-executor.md +246 -0
  10. package/agents/flow-planner.md +204 -0
  11. package/agents/flow-product-designer.md +146 -0
  12. package/agents/flow-qa-engineer.md +276 -0
  13. package/agents/flow-researcher.md +155 -0
  14. package/agents/flow-reviewer.md +280 -0
  15. package/agents/flow-security-auditor.md +398 -0
  16. package/agents/flow-triage-analyst.md +290 -0
  17. package/agents/flow-ui-researcher.md +227 -0
  18. package/agents/flow-ux-designer.md +247 -0
  19. package/agents/flow-verifier.md +283 -0
  20. package/agents/persona-amelia.md +128 -0
  21. package/agents/persona-david.md +141 -0
  22. package/agents/persona-emma.md +179 -0
  23. package/agents/persona-john.md +105 -0
  24. package/agents/persona-mary.md +95 -0
  25. package/agents/persona-oliver.md +136 -0
  26. package/agents/persona-rachel.md +126 -0
  27. package/agents/persona-serena.md +175 -0
  28. package/agents/persona-winston.md +117 -0
  29. package/bin/curdx-flow.js +5 -2
  30. package/cli/install.js +44 -5
  31. package/commands/audit.md +170 -0
  32. package/commands/autoplan.md +184 -0
  33. package/commands/debug.md +199 -0
  34. package/commands/design.md +155 -0
  35. package/commands/discuss.md +162 -0
  36. package/commands/doctor.md +124 -0
  37. package/commands/fast.md +128 -0
  38. package/commands/help.md +119 -0
  39. package/commands/implement.md +381 -0
  40. package/commands/index.md +261 -0
  41. package/commands/init.md +105 -0
  42. package/commands/install-deps.md +128 -0
  43. package/commands/party.md +241 -0
  44. package/commands/plan-ceo.md +117 -0
  45. package/commands/plan-design.md +107 -0
  46. package/commands/plan-dx.md +104 -0
  47. package/commands/plan-eng.md +108 -0
  48. package/commands/qa.md +118 -0
  49. package/commands/requirements.md +146 -0
  50. package/commands/research.md +141 -0
  51. package/commands/review.md +168 -0
  52. package/commands/security.md +109 -0
  53. package/commands/sketch.md +118 -0
  54. package/commands/spec.md +135 -0
  55. package/commands/spike.md +181 -0
  56. package/commands/start.md +189 -0
  57. package/commands/status.md +139 -0
  58. package/commands/switch.md +95 -0
  59. package/commands/tasks.md +189 -0
  60. package/commands/triage.md +160 -0
  61. package/commands/verify.md +124 -0
  62. package/gates/adversarial-review-gate.md +219 -0
  63. package/gates/coverage-audit-gate.md +184 -0
  64. package/gates/devex-gate.md +255 -0
  65. package/gates/edge-case-gate.md +194 -0
  66. package/gates/karpathy-gate.md +130 -0
  67. package/gates/security-gate.md +218 -0
  68. package/gates/tdd-gate.md +188 -0
  69. package/gates/verification-gate.md +183 -0
  70. package/hooks/hooks.json +56 -0
  71. package/hooks/scripts/fail-tracker.sh +31 -0
  72. package/hooks/scripts/inject-karpathy.sh +52 -0
  73. package/hooks/scripts/quick-mode-guard.sh +64 -0
  74. package/hooks/scripts/session-start.sh +76 -0
  75. package/hooks/scripts/stop-watcher.sh +166 -0
  76. package/knowledge/atomic-commits.md +262 -0
  77. package/knowledge/epic-decomposition.md +307 -0
  78. package/knowledge/execution-strategies.md +278 -0
  79. package/knowledge/karpathy-guidelines.md +219 -0
  80. package/knowledge/planning-reviews.md +211 -0
  81. package/knowledge/poc-first-workflow.md +227 -0
  82. package/knowledge/spec-driven-development.md +183 -0
  83. package/knowledge/systematic-debugging.md +384 -0
  84. package/knowledge/two-stage-review.md +233 -0
  85. package/knowledge/wave-execution.md +387 -0
  86. package/package.json +14 -3
  87. package/schemas/config.schema.json +100 -0
  88. package/schemas/spec-frontmatter.schema.json +42 -0
  89. package/schemas/spec-state.schema.json +117 -0
@@ -0,0 +1,183 @@
1
+ # Spec-Driven Development — CurDX-Flow Methodology
2
+
3
+ > Spec-driven development (SDD): decompose the path from "idea" to "code" into 4 verifiable phases, each with clear deliverables.
4
+ >
5
+ > Agents reference this file via `@${CLAUDE_PLUGIN_ROOT}/knowledge/spec-driven-development.md`.
6
+
7
+ ---
8
+
9
+ ## Core Idea
10
+
11
+ **Do not write code until research, requirements, and design are clear.**
12
+
13
+ ```
14
+ ┌─────────┐ ┌─────────────┐ ┌────────┐ ┌───────┐ ┌─────────┐
15
+ │ Research │ → │ Requirements │ → │ Design │ → │ Tasks │ → │ Execute │
16
+ └─────────┘ └─────────────┘ └────────┘ └───────┘ └─────────┘
17
+ "can it be done" "what to do" "how to do" "split how" "actually do"
18
+ ```
19
+
20
+ Each phase:
21
+ - Has an independent Markdown deliverable (research.md / requirements.md / design.md / tasks.md)
22
+ - Output is user-reviewed before progressing to the next
23
+ - Later phases strictly reference prior conclusions — no re-litigation
24
+
25
+ ---
26
+
27
+ ## Why This Way?
28
+
29
+ ### Problems from not doing this (writing code directly)
30
+
31
+ ```
32
+ User: "Add user authentication"
33
+ AI: writes 800 lines of JWT code
34
+ User: "Actually I wanted session cookies"
35
+ AI: rewrites 800 lines of session code
36
+ User: "I forgot to mention SSO is required"
37
+ AI: rewrites again…
38
+ ```
39
+
40
+ What's wasted isn't code — it's context tokens and decision fatigue from churn.
41
+
42
+ ### Benefits of doing it this way
43
+
44
+ - **Catch misunderstandings early** — ask during research, not at implementation time
45
+ - **Decisions are traceable** — every choice is written in design.md; later refer to `AD-01` rather than re-debating
46
+ - **Interruptible and resumable** — spec files persist; tomorrow's continuation requires only a read
47
+ - **Team collaboration** — others can pick up the work by reading the spec
48
+
49
+ ---
50
+
51
+ ## The 4 Phases Explained
52
+
53
+ ### Phase 1: Research
54
+
55
+ **Question**: Can this be done? What should it use?
56
+
57
+ **Key behaviors** (flow-researcher agent):
58
+ 1. Read `.flow/PROJECT.md` and `.flow/CONTEXT.md` to understand project background
59
+ 2. Call `mcp__claude_mem__search` to retrieve relevant historical experience
60
+ 3. Use sequential-thinking for 5-8 rounds of problem understanding
61
+ 4. Scan the codebase for reusable modules
62
+ 5. Use `mcp__context7__*` to look up latest docs for relevant libraries
63
+ 6. When necessary, WebSearch for the latest technical trends
64
+
65
+ **Deliverable**: `research.md` — includes:
66
+ - Problem understanding + explicit assumptions
67
+ - 2-3 candidate technical approaches
68
+ - Existing code analysis
69
+ - Feasibility judgment + recommended direction
70
+
71
+ **Next-step decision**: the recommended direction enters requirements; if entirely infeasible, stop here.
72
+
73
+ ---
74
+
75
+ ### Phase 2: Requirements
76
+
77
+ **Question**: What will the user see / experience?
78
+
79
+ **Key behaviors** (flow-product-designer agent):
80
+ 1. Read `research.md` to understand technical direction
81
+ 2. Translate technical capabilities into user stories (US-NN)
82
+ 3. Write 2-5 acceptance criteria per story (AC-X.Y)
83
+ 4. List FR (functional requirements) + NFR (non-functional requirements)
84
+ 5. Define an **explicit out-of-scope** list (prevents later scope creep)
85
+ 6. Raise open questions for the user to answer
86
+
87
+ **Deliverable**: `requirements.md`
88
+
89
+ **User review focus**:
90
+ - Are the user stories correct? (maybe research misunderstood)
91
+ - Are edge cases handled reasonably?
92
+ - Is the out-of-scope list accepted?
93
+
94
+ ---
95
+
96
+ ### Phase 3: Design
97
+
98
+ **Question**: How is the code organized? What decisions are made?
99
+
100
+ **Key behaviors** (flow-architect agent):
101
+ 1. Read `research.md` + `requirements.md`
102
+ 2. **Must use sequential-thinking for at least 8 rounds**:
103
+ - Rounds 1-2: constraints
104
+ - Rounds 3-5: comparison of options A/B
105
+ - Rounds 6-7: selection + trade-offs
106
+ - Round 8: rebut yourself
107
+ 3. Assign an `AD-NN` ID to each architectural decision
108
+ 4. Draw a data flow diagram (mermaid)
109
+ 5. Define component interfaces + error paths
110
+ 6. Make the test strategy explicit
111
+
112
+ **Deliverable**: `design.md`
113
+
114
+ **Freeze**: once tasks begin, the design is frozen. If changes are needed, return to the design phase to update (and bump AD numbers).
115
+
116
+ ---
117
+
118
+ ### Phase 4: Tasks (decomposition)
119
+
120
+ **Question**: How many steps to do it? How is each step verified?
121
+
122
+ **Key behaviors** (flow-planner agent):
123
+ 1. Read `requirements.md` + `design.md`
124
+ 2. Decompose by POC-First 5 Phases (see `poc-first-workflow.md`)
125
+ 3. Each task has 5 fields: `Do` / `Files` / `Done-when` / `Verify` / `Commit`
126
+ 4. **Multi-source coverage audit**: for each FR / AC / AD / decision, confirm there is a covering task (no omissions)
127
+ 5. Mark `[P]` (parallel-safe) and `[VERIFY]` (checkpoint)
128
+ 6. Simple decomposition doesn't need sequential-thinking, but reflect on coverage every 5 tasks
129
+
130
+ **Deliverable**: `tasks.md`
131
+
132
+ **Verification standard**: each `Verify` field must be an **automated command**, not "manual test".
133
+
134
+ ---
135
+
136
+ ## Spec-File Invariants
137
+
138
+ Regardless of the path taken, the 4 files must satisfy:
139
+
140
+ 1. **Clear dependency chain**: requirements reference research conclusions; design references requirements' FR; tasks reference design's AD.
141
+ 2. **IDs unique and stable**: US-01 refers to the same story across every file.
142
+ 3. **Auditable and traceable**: every implementation task can be traced to some FR or AC.
143
+ 4. **No backward edits**: once frozen, changes bump the version number (1.0 → 1.1), with prior versions kept.
144
+
145
+ ---
146
+
147
+ ## Spec vs Epic Difference
148
+
149
+ - **Spec**: a single independently-deliverable feature. Typically 1-2 weeks of effort.
150
+ - **Epic**: a collection of specs. `/curdx-flow:triage` breaks down a large goal into multiple specs.
151
+
152
+ `.flow/specs/<name>/` is a single-spec directory.
153
+ `.flow/_epics/<name>/` is an Epic directory (contains the dependency graph and sub-spec list).
154
+
155
+ ---
156
+
157
+ ## When Not to Use the Full Flow
158
+
159
+ SDD is not dogma. The following scenarios may skip phases:
160
+
161
+ - **One-off scripts** (`/curdx-flow:fast` mode) — skip all specs
162
+ - **UI prototype exploration** (`/curdx-flow:sketch` mode) — only research + design sketches
163
+ - **Emergency hotfix** (`/curdx-flow:spike` mode) — validating the assumption is enough
164
+
165
+ But **production code changes** should follow the full flow. Rationale:
166
+ - Code may be only 20 lines, but impact may reach all users
167
+ - The spec file itself is a record of "why" — valuable for future maintenance
168
+
169
+ ---
170
+
171
+ ## Division of Labor with claude-mem
172
+
173
+ - **claude-mem** automatically captures all tool calls and conversation → implicit memory
174
+ - **Spec files** are **explicit decision records** → consciously written
175
+
176
+ The two complement each other:
177
+ - Agents `mcp__claude_mem__search` the history before starting research
178
+ - What gets written into research.md is filtered, retention-worthy conclusions
179
+ - Subsequent sessions: claude-mem auto-injects recent context; spec files provide the structured overview
180
+
181
+ ---
182
+
183
+ _Adapted from smart-ralph's spec engine, extended with get-shit-done's multi-source audit._
@@ -0,0 +1,384 @@
1
+ # Systematic Debugging — 4-Stage Methodology
2
+
3
+ > Inherited from superpowers' systematic-debugging skill.
4
+ >
5
+ > Agents reference this via `@${CLAUDE_PLUGIN_ROOT}/knowledge/systematic-debugging.md`.
6
+
7
+ ---
8
+
9
+ ## Why Systematic
10
+
11
+ **Unsystematic debugging**:
12
+ - "Try this" → doesn't work
13
+ - "Try that" → doesn't work
14
+ - "Change this line" → looks good?
15
+ - (half an hour later) the bug is back
16
+
17
+ **Problems**:
18
+ - Without a root cause → fix isn't sturdy
19
+ - No failing test → no regression protection
20
+ - Consumes a lot of time
21
+ - Introduces new bugs while fixing bugs
22
+
23
+ **Systematic debugging**: explicit 4 stages, each with deliverables, preventing skipping.
24
+
25
+ ---
26
+
27
+ ## 4-Stage Overview
28
+
29
+ ```
30
+ Phase 1: Root Cause Investigation
31
+ ↓ a clear root cause statement
32
+ Phase 2: Pattern Analysis
33
+ ↓ compare working vs broken
34
+ Phase 3: Hypothesis & Test
35
+ ↓ single hypothesis, minimal test, verify
36
+ Phase 4: Implement Fix
37
+ ↓ failing test → fix root cause → verify
38
+ ```
39
+
40
+ Skipping any stage = incomplete.
41
+
42
+ ---
43
+
44
+ ## Phase 1: Root Cause Investigation
45
+
46
+ ### Step 1.1: Read the error carefully
47
+
48
+ Don't skim and start changing things. **Read every word**:
49
+
50
+ ```
51
+ TypeError: Cannot read property 'email' of undefined
52
+ at validateUser (src/auth/login.ts:42:18)
53
+ at processLogin (src/auth/login.ts:15:3)
54
+ at async Router.post (src/routes/auth.ts:22:5)
55
+ ```
56
+
57
+ What I can learn:
58
+ - **Type**: TypeError (not a logic error)
59
+ - **Cause**: reading .email on undefined
60
+ - **Location**: login.ts:42
61
+ - **Call chain**: processLogin → validateUser
62
+ - **Entry**: POST /auth/... route handler
63
+
64
+ Don't skip these.
65
+
66
+ ### Step 1.2: Reliable reproduction
67
+
68
+ Establish **minimal** reproduction steps:
69
+
70
+ ```
71
+ Preconditions:
72
+ 1. Run dev server
73
+ 2. Clear cookies
74
+ 3. Visit /login
75
+
76
+ Steps:
77
+ 1. Leave email empty
78
+ 2. Fill password with anything
79
+ 3. Click Submit
80
+
81
+ Expected: 400 + "email required"
82
+ Actual: 500 + stack trace with the TypeError above
83
+ ```
84
+
85
+ If **unstable** (sometimes happens, sometimes not):
86
+ - Record under what conditions it occurs
87
+ - Under what conditions it doesn't
88
+ - This hints at: race condition / initialization order / environment difference
89
+
90
+ ### Step 1.3: Check recent changes
91
+
92
+ ```bash
93
+ git log --oneline -20 src/auth/login.ts
94
+ git log --oneline --all --since="7 days ago"
95
+ git diff HEAD~5 src/auth/login.ts
96
+ ```
97
+
98
+ Most bugs are introduced by recent changes. Look at the suspicious recent commits first.
99
+
100
+ ### Step 1.4: Trace data flow
101
+
102
+ Backwards from the error point:
103
+
104
+ ```
105
+ error at login.ts:42: user.email is undefined
106
+ → where does user come from?
107
+ → validateUser(user) parameter
108
+ → req.body.user in processLogin
109
+ → route parameter req.body
110
+ → JSON.parse(request.body)
111
+ → payload from client
112
+
113
+ Reasoning:
114
+ If payload = `{email: ""}`,
115
+ req.body = {email: ""},
116
+ and code reads req.body.user.email → undefined.email → crash
117
+ ```
118
+
119
+ Root cause found: the code expected `req.body.user.email`, but the API contract sends `req.body.email`.
120
+
121
+ ### Step 1.5: Root cause statement
122
+
123
+ The completion sign for Phase 1: **being able to write the root cause in one sentence**.
124
+
125
+ Format:
126
+ > "Root cause: <specific cause>; trigger: <specific condition>; scope: <scope>"
127
+
128
+ Example:
129
+ > "Root cause: validateUser reads req.body.user.email, but the API sends req.body.email; trigger: all login requests; scope: the entire login flow fails 100%."
130
+
131
+ **Forbidden**:
132
+ - "Might be..." (hypothesis, not root cause)
133
+ - "Maybe..." (same)
134
+ - "I think..." (subjective)
135
+
136
+ If still at the "might be" level → continue investigating, don't enter Phase 2.
137
+
138
+ ---
139
+
140
+ ## Phase 2: Pattern Analysis
141
+
142
+ ### Step 2.1: Find working examples
143
+
144
+ 90% of the code in the system doesn't have this bug. What does that 90% look like?
145
+
146
+ ```bash
147
+ # Find similar scenarios
148
+ grep -rn "req.body" src/routes/
149
+ ```
150
+
151
+ Results:
152
+ ```
153
+ src/routes/auth.ts:15: const { email } = req.body ← works
154
+ src/routes/auth.ts:22: req.body.user.email ← broken
155
+ src/routes/user.ts:10: const { name } = req.body ← works
156
+ src/routes/order.ts:8: const { amount } = req.body ← works
157
+ ```
158
+
159
+ ### Step 2.2: Locate the difference
160
+
161
+ ```
162
+ Working pattern: const { email } = req.body (destructure top-level fields)
163
+ Broken pattern: req.body.user.email (access nested field)
164
+ ```
165
+
166
+ Difference is clear → confirms the root cause.
167
+
168
+ ### Step 2.3: Isolated case or systemic?
169
+
170
+ ```bash
171
+ grep -rn "req\.body\.user\." src/
172
+ ```
173
+
174
+ If the `req.body.user` pattern is used in multiple places:
175
+ - A wrong mental model exists in the system
176
+ - Fix all of them, not just one
177
+
178
+ If only this one:
179
+ - Isolated case, fix only here
180
+
181
+ ---
182
+
183
+ ## Phase 3: Hypothesis & Test
184
+
185
+ ### Step 3.1: Single hypothesis
186
+
187
+ **Do not** test multiple hypotheses simultaneously. If something works, you won't know which one did it.
188
+
189
+ **Single hypothesis**:
190
+ > "Hypothesis: changing login.ts:42 from req.body.user.email to req.body.email will fix this bug."
191
+
192
+ ### Step 3.2: Minimal test
193
+
194
+ ```bash
195
+ # Reproduce with current code first
196
+ curl -X POST localhost:3000/auth/login \
197
+ -d '{"email":"","password":""}'
198
+ # → 500 + TypeError ✓ (reproduces)
199
+
200
+ # Make the minimum change (in memory / editor, don't commit)
201
+ # Edit login.ts:42
202
+
203
+ # Test again
204
+ curl ... # expect 400 + "email required"
205
+
206
+ # If success → hypothesis confirmed
207
+ # If failure → hypothesis wrong; go back to Phase 1
208
+ ```
209
+
210
+ ### Step 3.3: Hypothesis confirmed → Phase 4
211
+
212
+ Once confirmed, proceed to the fix.
213
+
214
+ Hypothesis refuted → **do not** keep guessing; go back to Phase 1 and re-investigate the data flow.
215
+
216
+ ---
217
+
218
+ ## Phase 4: Implement Fix
219
+
220
+ ### Step 4.1: Write a failing test (**before code**)
221
+
222
+ ```typescript
223
+ // login.test.ts
224
+ test("rejects empty email with 400 (regression for #N)", async () => {
225
+ const res = await request(app)
226
+ .post("/auth/login")
227
+ .send({ email: "", password: "any" })
228
+
229
+ expect(res.status).toBe(400)
230
+ expect(res.body.error).toMatch(/email required/i)
231
+ })
232
+ ```
233
+
234
+ Run:
235
+ ```bash
236
+ npm test -- login.test.ts
237
+ # ✗ FAIL (expected, since it currently crashes with 500)
238
+ ```
239
+
240
+ Commit: `test(auth): red - reject empty email in login`
241
+
242
+ ### Step 4.2: Fix the root cause (not the symptom)
243
+
244
+ Phase 1 root cause: the code mis-reads `req.body.user.email`.
245
+
246
+ **Correct fix**: change to `req.body.email`
247
+ ```typescript
248
+ // login.ts
249
+ - const email = req.body.user.email // wrong
250
+ + const email = req.body.email // correct
251
+ ```
252
+
253
+ **Symptom fix** (wrong): add a null check
254
+ ```typescript
255
+ // ✗ symptom fix (doesn't answer "why is user.email undefined")
256
+ if (!req.body.user?.email) return res.status(400)
257
+ ```
258
+
259
+ ### Step 4.3: Verify
260
+
261
+ ```bash
262
+ npm test -- login.test.ts
263
+ # ✓ PASS
264
+
265
+ # Full test run to ensure no regressions
266
+ npm test
267
+ # ✓ all pass
268
+ ```
269
+
270
+ ### Step 4.4: Commit the fix
271
+
272
+ ```
273
+ fix(auth): green - read email from req.body directly
274
+
275
+ Root cause: validateUser expected req.body.user.email but API
276
+ contract sends req.body.email directly. This caused TypeError
277
+ on all login requests (100% failure).
278
+
279
+ Phase 1-4 analysis:
280
+ - Phase 1: traced data flow, found contract mismatch
281
+ - Phase 2: 3 other routes use correct `req.body.{field}` pattern
282
+ - Phase 3: hypothesis confirmed by minimal test
283
+ - Phase 4: test + fix + full regression passed
284
+
285
+ Fixes: #N
286
+ ```
287
+
288
+ ---
289
+
290
+ ## 3-Failure Protection (Anti-Loop)
291
+
292
+ ```python
293
+ failed_attempts = 0
294
+
295
+ while bug_not_fixed:
296
+ run_4_phases()
297
+ if failed:
298
+ failed_attempts += 1
299
+
300
+ if failed_attempts >= 3:
301
+ STOP_AND_REPORT:
302
+ """
303
+ I tried 3 different approaches, all failed:
304
+ 1. <method 1>: <why it failed>
305
+ 2. <method 2>: <why it failed>
306
+ 3. <method 3>: <why it failed>
307
+
308
+ This suggests the underlying problem may be:
309
+ - Wrong architecture (e.g., auth layer shouldn't own token mgmt)
310
+ - Dependency issue (e.g., bcrypt version incompatibility)
311
+ - Data issue (e.g., schema mismatches code)
312
+ - Tests don't reflect real scenarios
313
+
314
+ Recommendation: user intervention to decide direction.
315
+ """
316
+ ```
317
+
318
+ **Key**: do not blindly attempt a 4th time. 3 failures mean your hypothesis framework is wrong — step back and see the big picture.
319
+
320
+ ---
321
+
322
+ ## Forbidden Anti-Patterns
323
+
324
+ ### 1. Pray programming
325
+
326
+ ```python
327
+ for retry in range(10):
328
+ try:
329
+ do_thing()
330
+ break
331
+ except:
332
+ pass
333
+ ```
334
+ This is not fixing the bug, it's **masking** it.
335
+
336
+ ### 2. "Maybe it's..." attribution
337
+
338
+ ```
339
+ "Maybe it's a network issue" → didn't verify
340
+ "Maybe permissions" → didn't ls -la
341
+ "Maybe timezone" → didn't check timestamps
342
+ ```
343
+ **Verify** before attributing.
344
+
345
+ ### 3. Fix without a failing test
346
+
347
+ "I fixed it" → no test written → 6 months later a regression → debug again
348
+
349
+ Every fix comes with:
350
+ 1. A failing test that reproduces the bug
351
+ 2. The fix
352
+ 3. Test passes
353
+
354
+ ### 4. Bypassing the root cause
355
+
356
+ ```typescript
357
+ // Bug: user.email is null causing crash
358
+ // ✗ wrong fix: if (!user?.email) return defaultEmail
359
+ // ✓ correct fix: trace data flow, find where email becomes null
360
+ ```
361
+
362
+ ### 5. Half-fix
363
+
364
+ - ✗ Fixed one place, but similar code exists in 5 more
365
+ - ✓ Phase 2 analysis identifies all cases, fixes all at once
366
+
367
+ ---
368
+
369
+ ## Summary
370
+
371
+ ```
372
+ The value of systematic debugging:
373
+ Phase 1 ensures → don't fix on a hypothesis
374
+ Phase 2 ensures → recognize patterns, avoid isolated cases
375
+ Phase 3 ensures → know the fix works before applying
376
+ Phase 4 ensures → fix is durable + regression-proof
377
+
378
+ Unsystematic → fixes fast but fragile → bitten again by the same bug
379
+ Systematic → fixes slow but thorough → solved once, never looked back
380
+ ```
381
+
382
+ ---
383
+
384
+ _Source: superpowers' systematic-debugging skill._