@tuan_son.dinh/gsd 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +453 -0
  3. package/dist/app-paths.d.ts +4 -0
  4. package/dist/app-paths.js +6 -0
  5. package/dist/cli.d.ts +1 -0
  6. package/dist/cli.js +269 -0
  7. package/dist/loader.d.ts +2 -0
  8. package/dist/loader.js +70 -0
  9. package/dist/logo.d.ts +16 -0
  10. package/dist/logo.js +25 -0
  11. package/dist/onboarding.d.ts +43 -0
  12. package/dist/onboarding.js +418 -0
  13. package/dist/pi-migration.d.ts +14 -0
  14. package/dist/pi-migration.js +57 -0
  15. package/dist/resource-loader.d.ts +22 -0
  16. package/dist/resource-loader.js +60 -0
  17. package/dist/tool-bootstrap.d.ts +4 -0
  18. package/dist/tool-bootstrap.js +74 -0
  19. package/dist/wizard.d.ts +7 -0
  20. package/dist/wizard.js +25 -0
  21. package/package.json +60 -0
  22. package/patches/@mariozechner+pi-coding-agent+0.57.1.patch +108 -0
  23. package/patches/@mariozechner+pi-tui+0.57.1.patch +47 -0
  24. package/pkg/dist/modes/interactive/theme/dark.json +85 -0
  25. package/pkg/dist/modes/interactive/theme/light.json +84 -0
  26. package/pkg/dist/modes/interactive/theme/theme-schema.json +335 -0
  27. package/pkg/dist/modes/interactive/theme/theme.d.ts +78 -0
  28. package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  29. package/pkg/dist/modes/interactive/theme/theme.js +949 -0
  30. package/pkg/dist/modes/interactive/theme/theme.js.map +1 -0
  31. package/pkg/package.json +8 -0
  32. package/scripts/postinstall.js +127 -0
  33. package/src/resources/GSD-WORKFLOW.md +661 -0
  34. package/src/resources/agents/researcher.md +29 -0
  35. package/src/resources/agents/scout.md +56 -0
  36. package/src/resources/agents/worker.md +31 -0
  37. package/src/resources/extensions/ask-user-questions.ts +249 -0
  38. package/src/resources/extensions/bg-shell/index.ts +2808 -0
  39. package/src/resources/extensions/browser-tools/BROWSER-TOOLS-V2-PROPOSAL.md +1277 -0
  40. package/src/resources/extensions/browser-tools/core.js +1057 -0
  41. package/src/resources/extensions/browser-tools/index.ts +4989 -0
  42. package/src/resources/extensions/browser-tools/package.json +20 -0
  43. package/src/resources/extensions/context7/index.ts +428 -0
  44. package/src/resources/extensions/context7/package.json +11 -0
  45. package/src/resources/extensions/get-secrets-from-user.ts +352 -0
  46. package/src/resources/extensions/google-search/index.ts +323 -0
  47. package/src/resources/extensions/google-search/package.json +9 -0
  48. package/src/resources/extensions/gsd/activity-log.ts +69 -0
  49. package/src/resources/extensions/gsd/auto.ts +2744 -0
  50. package/src/resources/extensions/gsd/commands.ts +313 -0
  51. package/src/resources/extensions/gsd/crash-recovery.ts +85 -0
  52. package/src/resources/extensions/gsd/dashboard-overlay.ts +521 -0
  53. package/src/resources/extensions/gsd/docs/preferences-reference.md +176 -0
  54. package/src/resources/extensions/gsd/doctor.ts +690 -0
  55. package/src/resources/extensions/gsd/files.ts +732 -0
  56. package/src/resources/extensions/gsd/git-service.ts +597 -0
  57. package/src/resources/extensions/gsd/gitignore.ts +168 -0
  58. package/src/resources/extensions/gsd/guided-flow.ts +817 -0
  59. package/src/resources/extensions/gsd/index.ts +558 -0
  60. package/src/resources/extensions/gsd/metrics.ts +374 -0
  61. package/src/resources/extensions/gsd/migrate/command.ts +218 -0
  62. package/src/resources/extensions/gsd/migrate/index.ts +42 -0
  63. package/src/resources/extensions/gsd/migrate/parser.ts +323 -0
  64. package/src/resources/extensions/gsd/migrate/parsers.ts +624 -0
  65. package/src/resources/extensions/gsd/migrate/preview.ts +48 -0
  66. package/src/resources/extensions/gsd/migrate/transformer.ts +346 -0
  67. package/src/resources/extensions/gsd/migrate/types.ts +370 -0
  68. package/src/resources/extensions/gsd/migrate/validator.ts +55 -0
  69. package/src/resources/extensions/gsd/migrate/writer.ts +539 -0
  70. package/src/resources/extensions/gsd/observability-validator.ts +408 -0
  71. package/src/resources/extensions/gsd/package.json +11 -0
  72. package/src/resources/extensions/gsd/paths.ts +308 -0
  73. package/src/resources/extensions/gsd/preferences.ts +757 -0
  74. package/src/resources/extensions/gsd/prompt-loader.ts +50 -0
  75. package/src/resources/extensions/gsd/prompts/complete-milestone.md +25 -0
  76. package/src/resources/extensions/gsd/prompts/complete-slice.md +29 -0
  77. package/src/resources/extensions/gsd/prompts/discuss.md +189 -0
  78. package/src/resources/extensions/gsd/prompts/doctor-heal.md +29 -0
  79. package/src/resources/extensions/gsd/prompts/execute-task.md +61 -0
  80. package/src/resources/extensions/gsd/prompts/guided-complete-slice.md +1 -0
  81. package/src/resources/extensions/gsd/prompts/guided-discuss-milestone.md +3 -0
  82. package/src/resources/extensions/gsd/prompts/guided-discuss-slice.md +59 -0
  83. package/src/resources/extensions/gsd/prompts/guided-execute-task.md +1 -0
  84. package/src/resources/extensions/gsd/prompts/guided-plan-milestone.md +23 -0
  85. package/src/resources/extensions/gsd/prompts/guided-plan-slice.md +1 -0
  86. package/src/resources/extensions/gsd/prompts/guided-research-slice.md +11 -0
  87. package/src/resources/extensions/gsd/prompts/guided-resume-task.md +1 -0
  88. package/src/resources/extensions/gsd/prompts/plan-milestone.md +65 -0
  89. package/src/resources/extensions/gsd/prompts/plan-slice.md +51 -0
  90. package/src/resources/extensions/gsd/prompts/queue.md +85 -0
  91. package/src/resources/extensions/gsd/prompts/reassess-roadmap.md +48 -0
  92. package/src/resources/extensions/gsd/prompts/replan-slice.md +39 -0
  93. package/src/resources/extensions/gsd/prompts/research-milestone.md +37 -0
  94. package/src/resources/extensions/gsd/prompts/research-slice.md +28 -0
  95. package/src/resources/extensions/gsd/prompts/review-migration.md +66 -0
  96. package/src/resources/extensions/gsd/prompts/run-uat.md +109 -0
  97. package/src/resources/extensions/gsd/prompts/system.md +187 -0
  98. package/src/resources/extensions/gsd/prompts/worktree-merge.md +123 -0
  99. package/src/resources/extensions/gsd/session-forensics.ts +487 -0
  100. package/src/resources/extensions/gsd/skill-discovery.ts +137 -0
  101. package/src/resources/extensions/gsd/state.ts +460 -0
  102. package/src/resources/extensions/gsd/templates/context.md +76 -0
  103. package/src/resources/extensions/gsd/templates/decisions.md +8 -0
  104. package/src/resources/extensions/gsd/templates/milestone-summary.md +73 -0
  105. package/src/resources/extensions/gsd/templates/plan.md +131 -0
  106. package/src/resources/extensions/gsd/templates/preferences.md +24 -0
  107. package/src/resources/extensions/gsd/templates/project.md +31 -0
  108. package/src/resources/extensions/gsd/templates/reassessment.md +28 -0
  109. package/src/resources/extensions/gsd/templates/requirements.md +81 -0
  110. package/src/resources/extensions/gsd/templates/research.md +46 -0
  111. package/src/resources/extensions/gsd/templates/roadmap.md +118 -0
  112. package/src/resources/extensions/gsd/templates/slice-context.md +58 -0
  113. package/src/resources/extensions/gsd/templates/slice-summary.md +99 -0
  114. package/src/resources/extensions/gsd/templates/state.md +19 -0
  115. package/src/resources/extensions/gsd/templates/task-plan.md +52 -0
  116. package/src/resources/extensions/gsd/templates/task-summary.md +57 -0
  117. package/src/resources/extensions/gsd/templates/uat.md +54 -0
  118. package/src/resources/extensions/gsd/tests/activity-log-prune.test.ts +327 -0
  119. package/src/resources/extensions/gsd/tests/auto-preflight.test.ts +56 -0
  120. package/src/resources/extensions/gsd/tests/auto-supervisor.test.mjs +53 -0
  121. package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +225 -0
  122. package/src/resources/extensions/gsd/tests/cost-projection.test.ts +160 -0
  123. package/src/resources/extensions/gsd/tests/derive-state-deps.test.ts +341 -0
  124. package/src/resources/extensions/gsd/tests/derive-state.test.ts +689 -0
  125. package/src/resources/extensions/gsd/tests/discuss-prompt.test.ts +38 -0
  126. package/src/resources/extensions/gsd/tests/doctor.test.ts +505 -0
  127. package/src/resources/extensions/gsd/tests/git-service.test.ts +1313 -0
  128. package/src/resources/extensions/gsd/tests/idle-recovery.test.ts +308 -0
  129. package/src/resources/extensions/gsd/tests/metrics-io.test.ts +201 -0
  130. package/src/resources/extensions/gsd/tests/metrics.test.ts +217 -0
  131. package/src/resources/extensions/gsd/tests/migrate-command.test.ts +390 -0
  132. package/src/resources/extensions/gsd/tests/migrate-parser.test.ts +786 -0
  133. package/src/resources/extensions/gsd/tests/migrate-transformer.test.ts +657 -0
  134. package/src/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +443 -0
  135. package/src/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +318 -0
  136. package/src/resources/extensions/gsd/tests/migrate-writer.test.ts +420 -0
  137. package/src/resources/extensions/gsd/tests/must-have-parser.test.ts +309 -0
  138. package/src/resources/extensions/gsd/tests/parsers.test.ts +1351 -0
  139. package/src/resources/extensions/gsd/tests/plan-milestone.test.ts +163 -0
  140. package/src/resources/extensions/gsd/tests/plan-quality-validator.test.ts +386 -0
  141. package/src/resources/extensions/gsd/tests/reassess-prompt.test.ts +171 -0
  142. package/src/resources/extensions/gsd/tests/remote-questions.test.ts +155 -0
  143. package/src/resources/extensions/gsd/tests/remote-status.test.ts +99 -0
  144. package/src/resources/extensions/gsd/tests/replan-slice.test.ts +521 -0
  145. package/src/resources/extensions/gsd/tests/requirements.test.ts +125 -0
  146. package/src/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +34 -0
  147. package/src/resources/extensions/gsd/tests/resolve-ts.mjs +11 -0
  148. package/src/resources/extensions/gsd/tests/run-uat.test.ts +348 -0
  149. package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +247 -0
  150. package/src/resources/extensions/gsd/tests/workflow-config.test.mjs +53 -0
  151. package/src/resources/extensions/gsd/tests/workspace-index.test.ts +94 -0
  152. package/src/resources/extensions/gsd/tests/worktree-integration.test.ts +253 -0
  153. package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +160 -0
  154. package/src/resources/extensions/gsd/tests/worktree.test.ts +264 -0
  155. package/src/resources/extensions/gsd/types.ts +159 -0
  156. package/src/resources/extensions/gsd/unit-runtime.ts +184 -0
  157. package/src/resources/extensions/gsd/workspace-index.ts +203 -0
  158. package/src/resources/extensions/gsd/worktree-command.ts +845 -0
  159. package/src/resources/extensions/gsd/worktree-manager.ts +392 -0
  160. package/src/resources/extensions/gsd/worktree.ts +183 -0
  161. package/src/resources/extensions/mac-tools/index.ts +852 -0
  162. package/src/resources/extensions/mac-tools/swift-cli/Package.swift +22 -0
  163. package/src/resources/extensions/mac-tools/swift-cli/Sources/main.swift +1318 -0
  164. package/src/resources/extensions/mcporter/index.ts +429 -0
  165. package/src/resources/extensions/remote-questions/config.ts +81 -0
  166. package/src/resources/extensions/remote-questions/discord-adapter.ts +128 -0
  167. package/src/resources/extensions/remote-questions/format.ts +163 -0
  168. package/src/resources/extensions/remote-questions/manager.ts +192 -0
  169. package/src/resources/extensions/remote-questions/remote-command.ts +307 -0
  170. package/src/resources/extensions/remote-questions/slack-adapter.ts +92 -0
  171. package/src/resources/extensions/remote-questions/status.ts +31 -0
  172. package/src/resources/extensions/remote-questions/store.ts +77 -0
  173. package/src/resources/extensions/remote-questions/types.ts +75 -0
  174. package/src/resources/extensions/search-the-web/cache.ts +78 -0
  175. package/src/resources/extensions/search-the-web/command-search-provider.ts +95 -0
  176. package/src/resources/extensions/search-the-web/format.ts +258 -0
  177. package/src/resources/extensions/search-the-web/http.ts +238 -0
  178. package/src/resources/extensions/search-the-web/index.ts +65 -0
  179. package/src/resources/extensions/search-the-web/native-search.ts +157 -0
  180. package/src/resources/extensions/search-the-web/provider.ts +118 -0
  181. package/src/resources/extensions/search-the-web/tavily.ts +116 -0
  182. package/src/resources/extensions/search-the-web/tool-fetch-page.ts +519 -0
  183. package/src/resources/extensions/search-the-web/tool-llm-context.ts +561 -0
  184. package/src/resources/extensions/search-the-web/tool-search.ts +576 -0
  185. package/src/resources/extensions/search-the-web/url-utils.ts +91 -0
  186. package/src/resources/extensions/shared/confirm-ui.ts +126 -0
  187. package/src/resources/extensions/shared/interview-ui.ts +613 -0
  188. package/src/resources/extensions/shared/next-action-ui.ts +197 -0
  189. package/src/resources/extensions/shared/progress-widget.ts +282 -0
  190. package/src/resources/extensions/shared/terminal.ts +23 -0
  191. package/src/resources/extensions/shared/thinking-widget.ts +107 -0
  192. package/src/resources/extensions/shared/ui.ts +400 -0
  193. package/src/resources/extensions/shared/wizard-ui.ts +551 -0
  194. package/src/resources/extensions/slash-commands/audit.ts +88 -0
  195. package/src/resources/extensions/slash-commands/clear.ts +10 -0
  196. package/src/resources/extensions/slash-commands/create-extension.ts +297 -0
  197. package/src/resources/extensions/slash-commands/create-slash-command.ts +234 -0
  198. package/src/resources/extensions/slash-commands/index.ts +12 -0
  199. package/src/resources/extensions/subagent/agents.ts +126 -0
  200. package/src/resources/extensions/subagent/index.ts +1020 -0
  201. package/src/resources/extensions/voice/index.ts +195 -0
  202. package/src/resources/extensions/voice/speech-recognizer.swift +154 -0
  203. package/src/resources/skills/debug-like-expert/SKILL.md +231 -0
  204. package/src/resources/skills/debug-like-expert/references/debugging-mindset.md +253 -0
  205. package/src/resources/skills/debug-like-expert/references/hypothesis-testing.md +373 -0
  206. package/src/resources/skills/debug-like-expert/references/investigation-techniques.md +337 -0
  207. package/src/resources/skills/debug-like-expert/references/verification-patterns.md +425 -0
  208. package/src/resources/skills/debug-like-expert/references/when-to-research.md +361 -0
  209. package/src/resources/skills/frontend-design/SKILL.md +45 -0
  210. package/src/resources/skills/swiftui/SKILL.md +208 -0
  211. package/src/resources/skills/swiftui/references/animations.md +921 -0
  212. package/src/resources/skills/swiftui/references/architecture.md +1561 -0
  213. package/src/resources/skills/swiftui/references/layout-system.md +1186 -0
  214. package/src/resources/skills/swiftui/references/navigation.md +1492 -0
  215. package/src/resources/skills/swiftui/references/networking-async.md +214 -0
  216. package/src/resources/skills/swiftui/references/performance.md +1706 -0
  217. package/src/resources/skills/swiftui/references/platform-integration.md +204 -0
  218. package/src/resources/skills/swiftui/references/state-management.md +1443 -0
  219. package/src/resources/skills/swiftui/references/swiftdata.md +297 -0
  220. package/src/resources/skills/swiftui/references/testing-debugging.md +247 -0
  221. package/src/resources/skills/swiftui/references/uikit-appkit-interop.md +218 -0
  222. package/src/resources/skills/swiftui/workflows/add-feature.md +191 -0
  223. package/src/resources/skills/swiftui/workflows/build-new-app.md +311 -0
  224. package/src/resources/skills/swiftui/workflows/debug-swiftui.md +192 -0
  225. package/src/resources/skills/swiftui/workflows/optimize-performance.md +197 -0
  226. package/src/resources/skills/swiftui/workflows/ship-app.md +203 -0
  227. package/src/resources/skills/swiftui/workflows/write-tests.md +235 -0
@@ -0,0 +1,253 @@
1
+ <philosophy>
2
+ Debugging is applied epistemology. You're investigating a system to discover truth about its behavior. The difference between junior and senior debugging is not knowledge of frameworks - it's the discipline of systematic investigation.
3
+ </philosophy>
4
+
5
+ <meta_debugging>
6
+ **Special challenge**: When you're debugging code you wrote or modified, you're fighting your own mental model.
7
+
8
+ **Why this is harder**:
9
+ - You made the design decisions - they feel obviously correct
10
+ - You remember your intent, not what you actually implemented
11
+ - You see what you meant to write, not what's there
12
+ - Familiarity breeds blindness to bugs
13
+
14
+ **The trap**:
15
+ - "I know this works because I implemented it correctly"
16
+ - "The bug must be elsewhere - I designed this part"
17
+ - "I tested this approach"
18
+ - These thoughts are red flags. Code you wrote is guilty until proven innocent.
19
+
20
+ **The discipline**:
21
+
22
+ **1. Treat your own code as foreign**
23
+ - Read it as if someone else wrote it
24
+ - Don't assume it does what you intended
25
+ - Verify what it actually does, not what you think it does
26
+ - Fresh eyes see bugs; familiar eyes see intent
27
+
28
+ **2. Question your own design decisions**
29
+ - "I chose approach X because..." - Was that reasoning sound?
30
+ - "I assumed Y would..." - Have you verified Y actually does that?
31
+ - Your implementation decisions are hypotheses, not facts
32
+
33
+ **3. Admit your mental model might be wrong**
34
+ - You built a mental model of how this works
35
+ - That model might be incomplete or incorrect
36
+ - The code's behavior is truth; your model is just a guess
37
+ - Be willing to discover you misunderstood the problem
38
+
39
+ **4. Prioritize code you touched**
40
+ - If you modified 100 lines and something breaks
41
+ - Those 100 lines are the prime suspects
42
+ - Don't assume the bug is in the framework or existing code
43
+ - Start investigating where you made changes
44
+
45
+ <example>
46
+ ❌ "I implemented the auth flow correctly, the bug must be in the existing user service"
47
+
48
+ ✅ "I implemented the auth flow. Let me verify each part:
49
+ - Does login actually set the token? [test it]
50
+ - Does the middleware actually validate it? [test it]
51
+ - Does logout actually clear it? [test it]
52
+ - One of these is probably wrong"
53
+
54
+ The second approach found that logout wasn't clearing the token from localStorage, only from memory.
55
+ </example>
56
+
57
+ **The hardest admission**: "I implemented this wrong."
58
+
59
+ Not "the requirements were unclear" or "the library is confusing" - YOU made an error. Whether it was 5 minutes ago or 5 days ago doesn't matter. Your code, your responsibility, your bug to find.
60
+
61
+ This intellectual honesty is the difference between debugging for hours and finding bugs quickly.
62
+ </meta_debugging>
63
+
64
+ <foundation>
65
+ When debugging, return to foundational truths:
66
+
67
+ **What do you know for certain?**
68
+ - What have you directly observed (not assumed)?
69
+ - What can you prove with a test right now?
70
+ - What is speculation vs evidence?
71
+
72
+ **What are you assuming?**
73
+ - "This library should work this way" - Have you verified?
74
+ - "The docs say X" - Have you tested that X actually happens?
75
+ - "This worked before" - Can you prove when it worked and what changed?
76
+
77
+ Strip away everything you think you know. Build understanding from observable facts.
78
+ </foundation>
79
+
80
+ <example>
81
+ ❌ "React state updates should be synchronous here"
82
+ ✅ "Let me add a console.log to observe when state actually updates"
83
+
84
+ ❌ "The API must be returning bad data"
85
+ ✅ "Let me log the exact response payload to see what's actually being returned"
86
+
87
+ ❌ "This database query should be fast"
88
+ ✅ "Let me run EXPLAIN to see the actual execution plan"
89
+ </example>
90
+
91
+ <cognitive_biases>
92
+
93
+ <bias name="confirmation_bias">
94
+ **The problem**: You form a hypothesis and only look for evidence that confirms it.
95
+
96
+ **The trap**: "I think it's a race condition" → You only look for async code, missing the actual typo in a variable name.
97
+
98
+ **The antidote**: Actively seek evidence that disproves your hypothesis. Ask "What would prove me wrong?"
99
+ </bias>
100
+
101
+ <bias name="anchoring">
102
+ **The problem**: The first explanation you encounter becomes your anchor, and you adjust from there instead of considering alternatives.
103
+
104
+ **The trap**: Error message mentions "timeout" → You assume it's a network issue, when it's actually a deadlock.
105
+
106
+ **The antidote**: Generate multiple independent hypotheses before investigating any single one. Force yourself to list 3+ possible causes.
107
+ </bias>
108
+
109
+ <bias name="availability_heuristic">
110
+ **The problem**: You remember recent bugs and assume similar symptoms mean the same cause.
111
+
112
+ **The trap**: "We had a caching issue last week, this must be caching too."
113
+
114
+ **The antidote**: Treat each bug as novel until evidence suggests otherwise. Recent memory is not evidence.
115
+ </bias>
116
+
117
+ <bias name="sunk_cost_fallacy">
118
+ **The problem**: You've spent 2 hours debugging down one path, so you keep going even when evidence suggests it's wrong.
119
+
120
+ **The trap**: "I've almost figured out this state management issue" - when the actual bug is in the API layer.
121
+
122
+ **The antidote**: Set checkpoints. Every 30 minutes, ask: "If I started fresh right now, is this still the path I'd take?"
123
+ </bias>
124
+
125
+ </cognitive_biases>
126
+
127
+ <systematic_investigation>
128
+
129
+ <discipline name="change_one_variable">
130
+ **Why it matters**: If you change multiple things at once, you don't know which one fixed (or broke) it.
131
+
132
+ **In practice**:
133
+ 1. Make one change
134
+ 2. Test
135
+ 3. Observe result
136
+ 4. Document
137
+ 5. Repeat
138
+
139
+ **The temptation**: "Let me also update this dependency and refactor this function and change this config..."
140
+
141
+ **The reality**: Now you have no idea what actually mattered.
142
+ </discipline>
143
+
144
+ <discipline name="complete_reading">
145
+ **Why it matters**: Skimming code causes you to miss crucial details. You see what you expect to see, not what's there.
146
+
147
+ **In practice**:
148
+ - Read entire functions, not just the "relevant" lines
149
+ - Read imports and dependencies
150
+ - Read configuration files completely
151
+ - Read test files to understand intended behavior
152
+
153
+ **The shortcut**: "This function is long, I'll just read the part where the error happens"
154
+
155
+ **The miss**: The bug is actually in how the function is called 50 lines up.
156
+ </discipline>
157
+
158
+ <discipline name="embrace_not_knowing">
159
+ **Why it matters**: Premature certainty stops investigation. "I don't know" is a position of strength.
160
+
161
+ **In practice**:
162
+ - "I don't know why this fails" - Good. Now you can investigate.
163
+ - "It must be X" - Dangerous. You've stopped thinking.
164
+
165
+ **The pressure**: Users want answers. Managers want ETAs. Your ego wants to look smart.
166
+
167
+ **The truth**: "I need to investigate further" is more professional than a wrong fix.
168
+ </discipline>
169
+
170
+ </systematic_investigation>
171
+
172
+ <when_to_restart>
173
+
174
+ <restart_signals>
175
+ You should consider starting over when:
176
+
177
+ 1. **You've been investigating for 2+ hours with no progress**
178
+ - You're likely tunnel-visioned
179
+ - Take a break, then restart from evidence gathering
180
+
181
+ 2. **You've made 3+ "fixes" that didn't work**
182
+ - Your mental model is wrong
183
+ - Go back to first principles
184
+
185
+ 3. **You can't explain the current behavior**
186
+ - Don't add more changes on top of confusion
187
+ - First understand what's happening, then fix it
188
+
189
+ 4. **You're debugging the debugger**
190
+ - "Is my logging broken? Is the debugger lying?"
191
+ - Step back. Something fundamental is wrong.
192
+
193
+ 5. **The fix works but you don't know why**
194
+ - This isn't fixed. This is luck.
195
+ - Investigate until you understand, or revert the change
196
+ </restart_signals>
197
+
198
+ <restart_protocol>
199
+ When restarting:
200
+
201
+ 1. **Close all files and terminals**
202
+ 2. **Write down what you know for certain** (not what you think)
203
+ 3. **Write down what you've ruled out**
204
+ 4. **List new hypotheses** (different from before)
205
+ 5. **Begin again from Phase 1: Evidence Gathering**
206
+
207
+ This isn't failure. This is professionalism.
208
+ </restart_protocol>
209
+
210
+ </when_to_restart>
211
+
212
+ <humility>
213
+ The best debuggers have deep humility about their mental models:
214
+
215
+ **They know**:
216
+ - Their understanding of the system is incomplete
217
+ - Documentation can be wrong or outdated
218
+ - Their memory of "how this works" may be faulty
219
+ - The system's behavior is the only truth
220
+
221
+ **They don't**:
222
+ - Trust their first instinct
223
+ - Assume anything works as designed
224
+ - Skip verification steps
225
+ - Declare victory without proof
226
+
227
+ **They ask**:
228
+ - "What am I missing?"
229
+ - "What am I wrong about?"
230
+ - "What haven't I tested?"
231
+ - "What does the evidence actually say?"
232
+ </humility>
233
+
234
+ <craft>
235
+ Debugging is a craft that improves with practice:
236
+
237
+ **Novice debuggers**:
238
+ - Try random things hoping something works
239
+ - Skip reading code carefully
240
+ - Don't test their hypotheses
241
+ - Declare success too early
242
+
243
+ **Expert debuggers**:
244
+ - Form hypotheses explicitly
245
+ - Test hypotheses systematically
246
+ - Read code like literature
247
+ - Verify fixes rigorously
248
+ - Learn from each investigation
249
+
250
+ **The difference**: Not intelligence. Not knowledge. Discipline.
251
+
252
+ Practice the discipline of systematic investigation, and debugging becomes a strength.
253
+ </craft>
@@ -0,0 +1,373 @@
1
+
2
+ <overview>
3
+ Debugging is applied scientific method. You observe a phenomenon (the bug), form hypotheses about its cause, design experiments to test those hypotheses, and revise based on evidence. This isn't metaphorical - it's literal experimental science.
4
+ </overview>
5
+
6
+
7
+ <principle name="falsifiability">
8
+ A good hypothesis can be proven wrong. If you can't design an experiment that could disprove it, it's not a useful hypothesis.
9
+
10
+ **Bad hypotheses** (unfalsifiable):
11
+ - "Something is wrong with the state"
12
+ - "The timing is off"
13
+ - "There's a race condition somewhere"
14
+ - "The library is buggy"
15
+
16
+ **Good hypotheses** (falsifiable):
17
+ - "The user state is being reset because the component remounts when the route changes"
18
+ - "The API call completes after the component unmounts, causing the state update on unmounted component warning"
19
+ - "Two async operations are modifying the same array without locking, causing data loss"
20
+ - "The library's caching mechanism is returning stale data because our cache key doesn't include the timestamp"
21
+
22
+ **The difference**: Specificity. Good hypotheses make specific, testable claims.
23
+ </principle>
24
+
25
+ <how_to_form>
26
+ **Process for forming hypotheses**:
27
+
28
+ 1. **Observe the behavior precisely**
29
+ - Not "it's broken"
30
+ - But "the counter shows 3 when clicking once, should show 1"
31
+
32
+ 2. **Ask "What could cause this?"**
33
+ - List every possible cause you can think of
34
+ - Don't judge them yet, just brainstorm
35
+
36
+ 3. **Make each hypothesis specific**
37
+ - Not "state is wrong"
38
+ - But "state is being updated twice because handleClick is called twice"
39
+
40
+ 4. **Identify what evidence would support/refute each**
41
+ - If hypothesis X is true, I should see Y
42
+ - If hypothesis X is false, I should see Z
43
+
44
+ <example>
45
+ **Observation**: Button click sometimes saves data, sometimes doesn't.
46
+
47
+ **Vague hypothesis**: "The save isn't working reliably"
48
+ ❌ Unfalsifiable, not specific
49
+
50
+ **Specific hypotheses**:
51
+ 1. "The save API call is timing out when network is slow"
52
+ - Testable: Check network tab for timeout errors
53
+ - Falsifiable: If all requests complete successfully, this is wrong
54
+
55
+ 2. "The save button is being double-clicked, and the second request overwrites with stale data"
56
+ - Testable: Add logging to count clicks
57
+ - Falsifiable: If only one click is registered, this is wrong
58
+
59
+ 3. "The save is successful but the UI doesn't update because the response is being ignored"
60
+ - Testable: Check if API returns success
61
+ - Falsifiable: If UI updates on successful response, this is wrong
62
+ </example>
63
+ </how_to_form>
64
+
65
+
66
+ <experimental_design>
67
+ An experiment is a test that produces evidence supporting or refuting a hypothesis.
68
+
69
+ **Good experiments**:
70
+ - Test one hypothesis at a time
71
+ - Have clear success/failure criteria
72
+ - Produce unambiguous results
73
+ - Are repeatable
74
+
75
+ **Bad experiments**:
76
+ - Test multiple things at once
77
+ - Have unclear outcomes ("maybe it works better?")
78
+ - Rely on subjective judgment
79
+ - Can't be reproduced
80
+
81
+ <framework>
82
+ For each hypothesis, design an experiment:
83
+
84
+ **1. Prediction**: If hypothesis H is true, then I will observe X
85
+ **2. Test setup**: What do I need to do to test this?
86
+ **3. Measurement**: What exactly am I measuring?
87
+ **4. Success criteria**: What result confirms H? What result refutes H?
88
+ **5. Run the experiment**: Execute the test
89
+ **6. Observe the result**: Record what actually happened
90
+ **7. Conclude**: Does this support or refute H?
91
+
92
+ </framework>
93
+
94
+ <example>
95
+ **Hypothesis**: "The component is re-rendering excessively because the parent is passing a new object reference on every render"
96
+
97
+ **1. Prediction**: If true, the component will re-render even when the object's values haven't changed
98
+
99
+ **2. Test setup**:
100
+ - Add console.log in component body to count renders
101
+ - Add console.log in parent to track when object is created
102
+ - Add useEffect with the object as dependency to log when it changes
103
+
104
+ **3. Measurement**: Count of renders and object creations
105
+
106
+ **4. Success criteria**:
107
+ - Confirms H: Component re-renders match parent renders, object reference changes each time
108
+ - Refutes H: Component only re-renders when object values actually change
109
+
110
+ **5. Run**: Execute the code with logging
111
+
112
+ **6. Observe**:
113
+ ```
114
+ [Parent] Created user object
115
+ [Child] Rendering (1)
116
+ [Parent] Created user object
117
+ [Child] Rendering (2)
118
+ [Parent] Created user object
119
+ [Child] Rendering (3)
120
+ ```
121
+
122
+ **7. Conclude**: CONFIRMED. New object every parent render → child re-renders
123
+ </example>
124
+ </experimental_design>
125
+
126
+
127
+ <evidence_quality>
128
+ Not all evidence is equal. Learn to distinguish strong from weak evidence.
129
+
130
+ **Strong evidence**:
131
+ - Directly observable ("I can see in the logs that X happens")
132
+ - Repeatable ("This fails every time I do Y")
133
+ - Unambiguous ("The value is definitely null, not undefined")
134
+ - Independent ("This happens even in a fresh browser with no cache")
135
+
136
+ **Weak evidence**:
137
+ - Hearsay ("I think I saw this fail once")
138
+ - Non-repeatable ("It failed that one time but I can't reproduce it")
139
+ - Ambiguous ("Something seems off")
140
+ - Confounded ("It works after I restarted the server and cleared the cache and updated the package")
141
+
142
+ <examples>
143
+ **Strong**:
144
+ ```javascript
145
+ console.log('User ID:', userId); // Output: User ID: undefined
146
+ console.log('Type:', typeof userId); // Output: Type: undefined
147
+ ```
148
+ ✅ Direct observation, unambiguous
149
+
150
+ **Weak**:
151
+ "I think the user ID might not be set correctly sometimes"
152
+ ❌ Vague, not verified, uncertain
153
+
154
+ **Strong**:
155
+ ```javascript
156
+ for (let i = 0; i < 100; i++) {
157
+ const result = processData(testData);
158
+ if (result !== expected) {
159
+ console.log('Failed on iteration', i);
160
+ }
161
+ }
162
+ // Output: Failed on iterations: 3, 7, 12, 23, 31...
163
+ ```
164
+ ✅ Repeatable, shows pattern
165
+
166
+ **Weak**:
167
+ "It usually works, but sometimes fails"
168
+ ❌ Not quantified, no pattern identified
169
+ </examples>
170
+ </evidence_quality>
171
+
172
+
173
+ <decision_point>
174
+ Don't act too early (premature fix) or too late (analysis paralysis).
175
+
176
+ **Act when you can answer YES to all**:
177
+
178
+ 1. **Do you understand the mechanism?**
179
+ - Not just "what fails" but "why it fails"
180
+ - Can you explain the chain of events that produces the bug?
181
+
182
+ 2. **Can you reproduce it reliably?**
183
+ - Either always reproduces, or you understand the conditions that trigger it
184
+ - If you can't reproduce, you don't understand it yet
185
+
186
+ 3. **Do you have evidence, not just theory?**
187
+ - You've observed the behavior directly
188
+ - You've logged the values, traced the execution
189
+ - You're not guessing
190
+
191
+ 4. **Have you ruled out alternatives?**
192
+ - You've considered other hypotheses
193
+ - Evidence contradicts the alternatives
194
+ - This is the most likely cause, not just the first idea
195
+
196
+ **Don't act if**:
197
+ - "I think it might be X" - Too uncertain
198
+ - "This could be the issue" - Not confident enough
199
+ - "Let me try changing Y and see" - Random changes, not hypothesis-driven
200
+ - "I'll fix it and if it works, great" - Outcome-based, not understanding-based
201
+
202
+ <example>
203
+ **Too early** (don't act):
204
+ - Hypothesis: "Maybe the API is slow"
205
+ - Evidence: None, just a guess
206
+ - Action: Add caching
207
+ - Result: Bug persists, now you have caching to debug too
208
+
209
+ **Right time** (act):
210
+ - Hypothesis: "API response is missing the 'status' field when user is inactive, causing the app to crash"
211
+ - Evidence:
212
+ - Logged API response for active user: has 'status' field
213
+ - Logged API response for inactive user: missing 'status' field
214
+ - Logged app behavior: crashes on accessing undefined status
215
+ - Action: Add defensive check for missing status field
216
+ - Result: Bug fixed because you understood the cause
217
+ </example>
218
+ </decision_point>
219
+
220
+
221
+ <recovery>
222
+ You will be wrong sometimes. This is normal. The skill is recovering gracefully.
223
+
224
+ **When your hypothesis is disproven**:
225
+
226
+ 1. **Acknowledge it explicitly**
227
+ - "This hypothesis was wrong because [evidence]"
228
+ - Don't gloss over it or rationalize
229
+ - Intellectual honesty with yourself
230
+
231
+ 2. **Extract the learning**
232
+ - What did this experiment teach you?
233
+ - What did you rule out?
234
+ - What new information do you have?
235
+
236
+ 3. **Revise your understanding**
237
+ - Update your mental model
238
+ - What does the evidence actually suggest?
239
+
240
+ 4. **Form new hypotheses**
241
+ - Based on what you now know
242
+ - Avoid just moving to "second-guess" - use the evidence
243
+
244
+ 5. **Don't get attached to hypotheses**
245
+ - You're not your ideas
246
+ - Being wrong quickly is better than being wrong slowly
247
+
248
+ <example>
249
+ **Initial hypothesis**: "The memory leak is caused by event listeners not being cleaned up"
250
+
251
+ **Experiment**: Check Chrome DevTools for listener counts
252
+ **Result**: Listener count stays stable, doesn't grow over time
253
+
254
+ **Recovery**:
255
+ 1. ✅ "Event listeners are NOT the cause. The count doesn't increase."
256
+ 2. ✅ "I've ruled out event listeners as the culprit"
257
+ 3. ✅ "But the memory profile shows objects accumulating. What objects? Let me check the heap snapshot..."
258
+ 4. ✅ "New hypothesis: Large arrays are being cached and never released. Let me test by checking the heap for array sizes..."
259
+
260
+ This is good debugging. Wrong hypothesis, quick recovery, better understanding.
261
+ </example>
262
+ </recovery>
263
+
264
+
265
+ <multiple_hypotheses>
266
+ Don't fall in love with your first hypothesis. Generate multiple alternatives.
267
+
268
+ **Strategy**: "Strong inference" - Design experiments that differentiate between competing hypotheses.
269
+
270
+ <example>
271
+ **Problem**: Form submission fails intermittently
272
+
273
+ **Competing hypotheses**:
274
+ 1. Network timeout
275
+ 2. Validation failure
276
+ 3. Race condition with auto-save
277
+ 4. Server-side rate limiting
278
+
279
+ **Design experiment that differentiates**:
280
+
281
+ Add logging at each stage:
282
+ ```javascript
283
+ try {
284
+ console.log('[1] Starting validation');
285
+ const validation = await validate(formData);
286
+ console.log('[1] Validation passed:', validation);
287
+
288
+ console.log('[2] Starting submission');
289
+ const response = await api.submit(formData);
290
+ console.log('[2] Response received:', response.status);
291
+
292
+ console.log('[3] Updating UI');
293
+ updateUI(response);
294
+ console.log('[3] Complete');
295
+ } catch (error) {
296
+ console.log('[ERROR] Failed at stage:', error);
297
+ }
298
+ ```
299
+
300
+ **Observe results**:
301
+ - Fails at [2] with timeout error → Hypothesis 1
302
+ - Fails at [1] with validation error → Hypothesis 2
303
+ - Succeeds but [3] has wrong data → Hypothesis 3
304
+ - Fails at [2] with 429 status → Hypothesis 4
305
+
306
+ **One experiment, differentiates between four hypotheses.**
307
+ </example>
308
+ </multiple_hypotheses>
309
+
310
+
311
+ <workflow>
312
+ ```
313
+ 1. Observe unexpected behavior
314
+
315
+ 2. Form specific hypotheses (plural)
316
+
317
+ 3. For each hypothesis: What would prove/disprove?
318
+
319
+ 4. Design experiment to test
320
+
321
+ 5. Run experiment
322
+
323
+ 6. Observe results
324
+
325
+ 7. Evaluate: Confirmed, refuted, or inconclusive?
326
+
327
+ 8a. If CONFIRMED → Design fix based on understanding
328
+ 8b. If REFUTED → Return to step 2 with new hypotheses
329
+ 8c. If INCONCLUSIVE → Redesign experiment or gather more data
330
+ ```
331
+
332
+ **Key insight**: This is a loop, not a line. You'll cycle through multiple times. That's expected.
333
+ </workflow>
334
+
335
+
336
+ <pitfalls>
337
+
338
+ **Pitfall: Testing multiple hypotheses at once**
339
+ - You change three things and it works
340
+ - Which one fixed it? You don't know
341
+ - Solution: Test one hypothesis at a time
342
+
343
+ **Pitfall: Confirmation bias in experiments**
344
+ - You only look for evidence that confirms your hypothesis
345
+ - You ignore evidence that contradicts it
346
+ - Solution: Actively seek disconfirming evidence
347
+
348
+ **Pitfall: Acting on weak evidence**
349
+ - "It seems like maybe this could be..."
350
+ - Solution: Wait for strong, unambiguous evidence
351
+
352
+ **Pitfall: Not documenting results**
353
+ - You forget what you tested
354
+ - You repeat the same experiments
355
+ - Solution: Write down each hypothesis and its result
356
+
357
+ **Pitfall: Giving up on the scientific method**
358
+ - Under pressure, you start making random changes
359
+ - "Let me just try this..."
360
+ - Solution: Double down on rigor when pressure increases
361
+ </pitfalls>
362
+
363
+ <excellence>
364
+ **Great debuggers**:
365
+ - Form multiple competing hypotheses
366
+ - Design clever experiments that differentiate between them
367
+ - Follow the evidence wherever it leads
368
+ - Revise their beliefs when proven wrong
369
+ - Act only when they have strong evidence
370
+ - Understand the mechanism, not just the symptom
371
+
372
+ This is the difference between guessing and debugging.
373
+ </excellence>