liteagents 2.4.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 (215) hide show
  1. package/CHANGELOG.md +441 -0
  2. package/LICENSE +21 -0
  3. package/README.md +179 -0
  4. package/cli.js +230 -0
  5. package/docs/.gitkeep +1 -0
  6. package/docs/CONTRIBUTING.md +739 -0
  7. package/docs/DUAL_PUBLISH_SUMMARY.md +177 -0
  8. package/docs/ERROR_HANDLING_IMPLEMENTATION.md +327 -0
  9. package/docs/GITHUB_PACKAGES.md +181 -0
  10. package/docs/GITHUB_SETUP.md +158 -0
  11. package/docs/INSTALLATION_DEMO.md +691 -0
  12. package/docs/INSTALLATION_LOCATIONS.md +299 -0
  13. package/docs/INSTALLER_GUIDE.md +1586 -0
  14. package/docs/INTEGRATION_ISSUES_9.1.md +341 -0
  15. package/docs/KNOWLEDGE_BASE.md +727 -0
  16. package/docs/MIGRATION.md +384 -0
  17. package/docs/PACKAGE_BASELINE.md +557 -0
  18. package/docs/PACKAGE_VALIDATION_REPORT.md +427 -0
  19. package/docs/PASS_INTEGRATION.md +307 -0
  20. package/docs/PASS_QUICK_START.md +150 -0
  21. package/docs/PRIVACY.md +203 -0
  22. package/docs/PUBLISHING.md +494 -0
  23. package/docs/QUICK-START.md +318 -0
  24. package/docs/RELEASE_NOTES_1.2.0.md +323 -0
  25. package/docs/SECURITY.md +317 -0
  26. package/docs/SILENT_MODE_GUIDE.md +526 -0
  27. package/docs/SKILLS_CONVERSION.md +154 -0
  28. package/docs/TESTING.md +582 -0
  29. package/docs/TEST_COVERAGE.md +347 -0
  30. package/docs/TROUBLESHOOTING.md +788 -0
  31. package/docs/UPDATED_VARIANT_CONFIGURATION.md +274 -0
  32. package/docs/VARIANT_CONFIGURATION.md +440 -0
  33. package/installer/cli.js +761 -0
  34. package/installer/installation-engine.js +1536 -0
  35. package/installer/package-manager.js +640 -0
  36. package/installer/path-manager.js +427 -0
  37. package/installer/report-template.js +298 -0
  38. package/installer/verification-system.js +274 -0
  39. package/package.json +83 -0
  40. package/packages/ampcode/AGENT.md +58 -0
  41. package/packages/ampcode/README.md +17 -0
  42. package/packages/ampcode/agents/1-create-prd.md +175 -0
  43. package/packages/ampcode/agents/2-generate-tasks.md +190 -0
  44. package/packages/ampcode/agents/3-process-task-list.md +225 -0
  45. package/packages/ampcode/agents/code-developer.md +198 -0
  46. package/packages/ampcode/agents/context-builder.md +142 -0
  47. package/packages/ampcode/agents/feature-planner.md +199 -0
  48. package/packages/ampcode/agents/market-researcher.md +89 -0
  49. package/packages/ampcode/agents/orchestrator.md +116 -0
  50. package/packages/ampcode/agents/quality-assurance.md +115 -0
  51. package/packages/ampcode/agents/system-architect.md +135 -0
  52. package/packages/ampcode/agents/ui-designer.md +184 -0
  53. package/packages/ampcode/commands/brainstorming.md +56 -0
  54. package/packages/ampcode/commands/code-review.md +107 -0
  55. package/packages/ampcode/commands/condition-based-waiting/example.ts +158 -0
  56. package/packages/ampcode/commands/condition-based-waiting.md +122 -0
  57. package/packages/ampcode/commands/debug.md +20 -0
  58. package/packages/ampcode/commands/docs-builder/templates.md +572 -0
  59. package/packages/ampcode/commands/docs-builder.md +106 -0
  60. package/packages/ampcode/commands/explain.md +18 -0
  61. package/packages/ampcode/commands/git-commit.md +14 -0
  62. package/packages/ampcode/commands/optimize.md +20 -0
  63. package/packages/ampcode/commands/refactor.md +21 -0
  64. package/packages/ampcode/commands/review.md +18 -0
  65. package/packages/ampcode/commands/root-cause-tracing/find-polluter.sh +63 -0
  66. package/packages/ampcode/commands/root-cause-tracing.md +176 -0
  67. package/packages/ampcode/commands/security.md +21 -0
  68. package/packages/ampcode/commands/ship.md +18 -0
  69. package/packages/ampcode/commands/skill-creator/scripts/init_skill.py +303 -0
  70. package/packages/ampcode/commands/skill-creator/scripts/package_skill.py +110 -0
  71. package/packages/ampcode/commands/skill-creator/scripts/quick_validate.py +65 -0
  72. package/packages/ampcode/commands/skill-creator.md +211 -0
  73. package/packages/ampcode/commands/stash.md +45 -0
  74. package/packages/ampcode/commands/systematic-debugging.md +297 -0
  75. package/packages/ampcode/commands/test-driven-development.md +390 -0
  76. package/packages/ampcode/commands/test-generate.md +18 -0
  77. package/packages/ampcode/commands/testing-anti-patterns.md +304 -0
  78. package/packages/ampcode/commands/verification-before-completion.md +152 -0
  79. package/packages/ampcode/settings.json +13 -0
  80. package/packages/ampcode/variants.json +8 -0
  81. package/packages/claude/CLAUDE.md +58 -0
  82. package/packages/claude/README.md +23 -0
  83. package/packages/claude/agents/1-create-prd.md +175 -0
  84. package/packages/claude/agents/2-generate-tasks.md +190 -0
  85. package/packages/claude/agents/3-process-task-list.md +225 -0
  86. package/packages/claude/agents/code-developer.md +198 -0
  87. package/packages/claude/agents/context-builder.md +142 -0
  88. package/packages/claude/agents/feature-planner.md +199 -0
  89. package/packages/claude/agents/market-researcher.md +89 -0
  90. package/packages/claude/agents/orchestrator.md +117 -0
  91. package/packages/claude/agents/quality-assurance.md +115 -0
  92. package/packages/claude/agents/system-architect.md +135 -0
  93. package/packages/claude/agents/ui-designer.md +184 -0
  94. package/packages/claude/commands/debug.md +20 -0
  95. package/packages/claude/commands/explain.md +18 -0
  96. package/packages/claude/commands/git-commit.md +14 -0
  97. package/packages/claude/commands/optimize.md +20 -0
  98. package/packages/claude/commands/refactor.md +21 -0
  99. package/packages/claude/commands/review.md +18 -0
  100. package/packages/claude/commands/security.md +21 -0
  101. package/packages/claude/commands/ship.md +18 -0
  102. package/packages/claude/commands/stash.md +45 -0
  103. package/packages/claude/commands/test-generate.md +18 -0
  104. package/packages/claude/skills/brainstorming/SKILL.md +56 -0
  105. package/packages/claude/skills/code-review/SKILL.md +107 -0
  106. package/packages/claude/skills/code-review/code-reviewer.md +146 -0
  107. package/packages/claude/skills/condition-based-waiting/SKILL.md +122 -0
  108. package/packages/claude/skills/condition-based-waiting/example.ts +158 -0
  109. package/packages/claude/skills/docs-builder/SKILL.md +106 -0
  110. package/packages/claude/skills/docs-builder/references/templates.md +572 -0
  111. package/packages/claude/skills/root-cause-tracing/SKILL.md +176 -0
  112. package/packages/claude/skills/root-cause-tracing/find-polluter.sh +63 -0
  113. package/packages/claude/skills/skill-creator/LICENSE.txt +202 -0
  114. package/packages/claude/skills/skill-creator/SKILL.md +211 -0
  115. package/packages/claude/skills/skill-creator/scripts/init_skill.py +303 -0
  116. package/packages/claude/skills/skill-creator/scripts/package_skill.py +110 -0
  117. package/packages/claude/skills/skill-creator/scripts/quick_validate.py +65 -0
  118. package/packages/claude/skills/systematic-debugging/CREATION-LOG.md +119 -0
  119. package/packages/claude/skills/systematic-debugging/SKILL.md +296 -0
  120. package/packages/claude/skills/systematic-debugging/test-academic.md +14 -0
  121. package/packages/claude/skills/systematic-debugging/test-pressure-1.md +58 -0
  122. package/packages/claude/skills/systematic-debugging/test-pressure-2.md +68 -0
  123. package/packages/claude/skills/systematic-debugging/test-pressure-3.md +69 -0
  124. package/packages/claude/skills/test-driven-development/SKILL.md +392 -0
  125. package/packages/claude/skills/testing-anti-patterns/SKILL.md +304 -0
  126. package/packages/claude/skills/verification-before-completion/SKILL.md +152 -0
  127. package/packages/claude/variants.json +9 -0
  128. package/packages/droid/AGENTS.md +52 -0
  129. package/packages/droid/README.md +17 -0
  130. package/packages/droid/change_settings.json +61 -0
  131. package/packages/droid/commands/brainstorming.md +56 -0
  132. package/packages/droid/commands/code-review.md +107 -0
  133. package/packages/droid/commands/condition-based-waiting/example.ts +158 -0
  134. package/packages/droid/commands/condition-based-waiting.md +122 -0
  135. package/packages/droid/commands/debug.md +20 -0
  136. package/packages/droid/commands/docs-builder/templates.md +572 -0
  137. package/packages/droid/commands/docs-builder.md +106 -0
  138. package/packages/droid/commands/explain.md +18 -0
  139. package/packages/droid/commands/git-commit.md +14 -0
  140. package/packages/droid/commands/optimize.md +20 -0
  141. package/packages/droid/commands/refactor.md +21 -0
  142. package/packages/droid/commands/review.md +18 -0
  143. package/packages/droid/commands/root-cause-tracing/find-polluter.sh +63 -0
  144. package/packages/droid/commands/root-cause-tracing.md +176 -0
  145. package/packages/droid/commands/security.md +21 -0
  146. package/packages/droid/commands/ship.md +18 -0
  147. package/packages/droid/commands/skill-creator/scripts/init_skill.py +303 -0
  148. package/packages/droid/commands/skill-creator/scripts/package_skill.py +110 -0
  149. package/packages/droid/commands/skill-creator/scripts/quick_validate.py +65 -0
  150. package/packages/droid/commands/skill-creator.md +211 -0
  151. package/packages/droid/commands/stash.md +45 -0
  152. package/packages/droid/commands/systematic-debugging.md +297 -0
  153. package/packages/droid/commands/test-driven-development.md +390 -0
  154. package/packages/droid/commands/test-generate.md +18 -0
  155. package/packages/droid/commands/testing-anti-patterns.md +304 -0
  156. package/packages/droid/commands/verification-before-completion.md +152 -0
  157. package/packages/droid/droids/1-create-prd.md +170 -0
  158. package/packages/droid/droids/2-generate-tasks.md +190 -0
  159. package/packages/droid/droids/3-process-task-list.md +225 -0
  160. package/packages/droid/droids/code-developer.md +198 -0
  161. package/packages/droid/droids/context-builder.md +142 -0
  162. package/packages/droid/droids/feature-planner.md +199 -0
  163. package/packages/droid/droids/market-researcher.md +89 -0
  164. package/packages/droid/droids/orchestrator.md +116 -0
  165. package/packages/droid/droids/quality-assurance.md +115 -0
  166. package/packages/droid/droids/system-architect.md +135 -0
  167. package/packages/droid/droids/ui-designer.md +184 -0
  168. package/packages/droid/variants.json +8 -0
  169. package/packages/opencode/AGENTS.md +52 -0
  170. package/packages/opencode/README.md +17 -0
  171. package/packages/opencode/agent/1-create-prd.md +179 -0
  172. package/packages/opencode/agent/2-generate-tasks.md +194 -0
  173. package/packages/opencode/agent/3-process-task-list.md +229 -0
  174. package/packages/opencode/agent/code-developer.md +202 -0
  175. package/packages/opencode/agent/context-builder.md +146 -0
  176. package/packages/opencode/agent/feature-planner.md +203 -0
  177. package/packages/opencode/agent/market-researcher.md +93 -0
  178. package/packages/opencode/agent/orchestrator.md +120 -0
  179. package/packages/opencode/agent/quality-assurance.md +119 -0
  180. package/packages/opencode/agent/system-architect.md +139 -0
  181. package/packages/opencode/agent/ui-designer.md +188 -0
  182. package/packages/opencode/command/brainstorming.md +56 -0
  183. package/packages/opencode/command/code-review.md +107 -0
  184. package/packages/opencode/command/condition-based-waiting/example.ts +158 -0
  185. package/packages/opencode/command/condition-based-waiting.md +122 -0
  186. package/packages/opencode/command/debug.md +20 -0
  187. package/packages/opencode/command/docs-builder/templates.md +572 -0
  188. package/packages/opencode/command/docs-builder.md +106 -0
  189. package/packages/opencode/command/explain.md +18 -0
  190. package/packages/opencode/command/git-commit.md +14 -0
  191. package/packages/opencode/command/optimize.md +20 -0
  192. package/packages/opencode/command/refactor.md +21 -0
  193. package/packages/opencode/command/review.md +18 -0
  194. package/packages/opencode/command/root-cause-tracing/find-polluter.sh +63 -0
  195. package/packages/opencode/command/root-cause-tracing.md +176 -0
  196. package/packages/opencode/command/security.md +21 -0
  197. package/packages/opencode/command/ship.md +18 -0
  198. package/packages/opencode/command/skill-creator/scripts/init_skill.py +303 -0
  199. package/packages/opencode/command/skill-creator/scripts/package_skill.py +110 -0
  200. package/packages/opencode/command/skill-creator/scripts/quick_validate.py +65 -0
  201. package/packages/opencode/command/skill-creator.md +211 -0
  202. package/packages/opencode/command/stash.md +45 -0
  203. package/packages/opencode/command/systematic-debugging.md +297 -0
  204. package/packages/opencode/command/test-driven-development.md +390 -0
  205. package/packages/opencode/command/test-generate.md +18 -0
  206. package/packages/opencode/command/testing-anti-patterns.md +304 -0
  207. package/packages/opencode/command/verification-before-completion.md +152 -0
  208. package/packages/opencode/opencode.jsonc +201 -0
  209. package/packages/opencode/variants.json +8 -0
  210. package/packages/subagentic-manual.md +349 -0
  211. package/postinstall.js +21 -0
  212. package/tools/ampcode/manifest-template.json +14 -0
  213. package/tools/claude/manifest-template.json +14 -0
  214. package/tools/droid/manifest-template.json +14 -0
  215. package/tools/opencode/manifest-template.json +14 -0
@@ -0,0 +1,297 @@
1
+ ---
2
+ name: systematic-debugging
3
+ description: Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes - four-phase framework (root cause investigation, pattern analysis, hypothesis testing, implementation) that ensures understanding before attempting solutions
4
+ usage: /systematic-debugging <bug-or-error-description>
5
+ auto_trigger: false
6
+ ---
7
+
8
+ # Systematic Debugging
9
+
10
+ ## Overview
11
+
12
+ Random fixes waste time and create new bugs. Quick patches mask underlying issues.
13
+
14
+ **Core principle:** ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
15
+
16
+ **Violating the letter of this process is violating the spirit of debugging.**
17
+
18
+ ## The Iron Law
19
+
20
+ ```
21
+ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
22
+ ```
23
+
24
+ If you haven't completed Phase 1, you cannot propose fixes.
25
+
26
+ ## When to Use
27
+
28
+ Use for ANY technical issue:
29
+ - Test failures
30
+ - Bugs in production
31
+ - Unexpected behavior
32
+ - Performance problems
33
+ - Build failures
34
+ - Integration issues
35
+
36
+ **Use this ESPECIALLY when:**
37
+ - Under time pressure (emergencies make guessing tempting)
38
+ - "Just one quick fix" seems obvious
39
+ - You've already tried multiple fixes
40
+ - Previous fix didn't work
41
+ - You don't fully understand the issue
42
+
43
+ **Don't skip when:**
44
+ - Issue seems simple (simple bugs have root causes too)
45
+ - You're in a hurry (rushing guarantees rework)
46
+ - Manager wants it fixed NOW (systematic is faster than thrashing)
47
+
48
+ ## The Four Phases
49
+
50
+ You MUST complete each phase before proceeding to the next.
51
+
52
+ ### Phase 1: Root Cause Investigation
53
+
54
+ **BEFORE attempting ANY fix:**
55
+
56
+ 1. **Read Error Messages Carefully**
57
+ - Don't skip past errors or warnings
58
+ - They often contain the exact solution
59
+ - Read stack traces completely
60
+ - Note line numbers, file paths, error codes
61
+
62
+ 2. **Reproduce Consistently**
63
+ - Can you trigger it reliably?
64
+ - What are the exact steps?
65
+ - Does it happen every time?
66
+ - If not reproducible → gather more data, don't guess
67
+
68
+ 3. **Check Recent Changes**
69
+ - What changed that could cause this?
70
+ - Git diff, recent commits
71
+ - New dependencies, config changes
72
+ - Environmental differences
73
+
74
+ 4. **Gather Evidence in Multi-Component Systems**
75
+
76
+ **WHEN system has multiple components (CI → build → signing, API → service → database):**
77
+
78
+ **BEFORE proposing fixes, add diagnostic instrumentation:**
79
+ ```
80
+ For EACH component boundary:
81
+ - Log what data enters component
82
+ - Log what data exits component
83
+ - Verify environment/config propagation
84
+ - Check state at each layer
85
+
86
+ Run once to gather evidence showing WHERE it breaks
87
+ THEN analyze evidence to identify failing component
88
+ THEN investigate that specific component
89
+ ```
90
+
91
+ **Example (multi-layer system):**
92
+ ```bash
93
+ # Layer 1: Workflow
94
+ echo "=== Secrets available in workflow: ==="
95
+ echo "IDENTITY: ${IDENTITY:+SET}${IDENTITY:-UNSET}"
96
+
97
+ # Layer 2: Build script
98
+ echo "=== Env vars in build script: ==="
99
+ env | grep IDENTITY || echo "IDENTITY not in environment"
100
+
101
+ # Layer 3: Signing script
102
+ echo "=== Keychain state: ==="
103
+ security list-keychains
104
+ security find-identity -v
105
+
106
+ # Layer 4: Actual signing
107
+ codesign --sign "$IDENTITY" --verbose=4 "$APP"
108
+ ```
109
+
110
+ **This reveals:** Which layer fails (secrets → workflow ✓, workflow → build ✗)
111
+
112
+ 5. **Trace Data Flow**
113
+
114
+ **WHEN error is deep in call stack:**
115
+
116
+ **REQUIRED SUB-SKILL:** Use root-cause-tracing for backward tracing technique
117
+
118
+ **Quick version:**
119
+ - Where does bad value originate?
120
+ - What called this with bad value?
121
+ - Keep tracing up until you find the source
122
+ - Fix at source, not at symptom
123
+
124
+ ### Phase 2: Pattern Analysis
125
+
126
+ **Find the pattern before fixing:**
127
+
128
+ 1. **Find Working Examples**
129
+ - Locate similar working code in same codebase
130
+ - What works that's similar to what's broken?
131
+
132
+ 2. **Compare Against References**
133
+ - If implementing pattern, read reference implementation COMPLETELY
134
+ - Don't skim - read every line
135
+ - Understand the pattern fully before applying
136
+
137
+ 3. **Identify Differences**
138
+ - What's different between working and broken?
139
+ - List every difference, however small
140
+ - Don't assume "that can't matter"
141
+
142
+ 4. **Understand Dependencies**
143
+ - What other components does this need?
144
+ - What settings, config, environment?
145
+ - What assumptions does it make?
146
+
147
+ ### Phase 3: Hypothesis and Testing
148
+
149
+ **Scientific method:**
150
+
151
+ 1. **Form Single Hypothesis**
152
+ - State clearly: "I think X is the root cause because Y"
153
+ - Write it down
154
+ - Be specific, not vague
155
+
156
+ 2. **Test Minimally**
157
+ - Make the SMALLEST possible change to test hypothesis
158
+ - One variable at a time
159
+ - Don't fix multiple things at once
160
+
161
+ 3. **Verify Before Continuing**
162
+ - Did it work? Yes → Phase 4
163
+ - Didn't work? Form NEW hypothesis
164
+ - DON'T add more fixes on top
165
+
166
+ 4. **When You Don't Know**
167
+ - Say "I don't understand X"
168
+ - Don't pretend to know
169
+ - Ask for help
170
+ - Research more
171
+
172
+ ### Phase 4: Implementation
173
+
174
+ **Fix the root cause, not the symptom:**
175
+
176
+ 1. **Create Failing Test Case**
177
+ - Simplest possible reproduction
178
+ - Automated test if possible
179
+ - One-off test script if no framework
180
+ - MUST have before fixing
181
+ - **REQUIRED SUB-SKILL:** Use test-driven-development for writing proper failing tests
182
+
183
+ 2. **Implement Single Fix**
184
+ - Address the root cause identified
185
+ - ONE change at a time
186
+ - No "while I'm here" improvements
187
+ - No bundled refactoring
188
+
189
+ 3. **Verify Fix**
190
+ - Test passes now?
191
+ - No other tests broken?
192
+ - Issue actually resolved?
193
+
194
+ 4. **If Fix Doesn't Work**
195
+ - STOP
196
+ - Count: How many fixes have you tried?
197
+ - If < 3: Return to Phase 1, re-analyze with new information
198
+ - **If ≥ 3: STOP and question the architecture (step 5 below)**
199
+ - DON'T attempt Fix #4 without architectural discussion
200
+
201
+ 5. **If 3+ Fixes Failed: Question Architecture**
202
+
203
+ **Pattern indicating architectural problem:**
204
+ - Each fix reveals new shared state/coupling/problem in different place
205
+ - Fixes require "massive refactoring" to implement
206
+ - Each fix creates new symptoms elsewhere
207
+
208
+ **STOP and question fundamentals:**
209
+ - Is this pattern fundamentally sound?
210
+ - Are we "sticking with it through sheer inertia"?
211
+ - Should we refactor architecture vs. continue fixing symptoms?
212
+
213
+ **Discuss with your human partner before attempting more fixes**
214
+
215
+ This is NOT a failed hypothesis - this is a wrong architecture.
216
+
217
+ ## Red Flags - STOP and Follow Process
218
+
219
+ If you catch yourself thinking:
220
+ - "Quick fix for now, investigate later"
221
+ - "Just try changing X and see if it works"
222
+ - "Add multiple changes, run tests"
223
+ - "Skip the test, I'll manually verify"
224
+ - "It's probably X, let me fix that"
225
+ - "I don't fully understand but this might work"
226
+ - "Pattern says X but I'll adapt it differently"
227
+ - "Here are the main problems: [lists fixes without investigation]"
228
+ - Proposing solutions before tracing data flow
229
+ - **"One more fix attempt" (when already tried 2+)**
230
+ - **Each fix reveals new problem in different place**
231
+
232
+ **ALL of these mean: STOP. Return to Phase 1.**
233
+
234
+ **If 3+ fixes failed:** Question the architecture (see Phase 4.5)
235
+
236
+ ## your human partner's Signals You're Doing It Wrong
237
+
238
+ **Watch for these redirections:**
239
+ - "Is that not happening?" - You assumed without verifying
240
+ - "Will it show us...?" - You should have added evidence gathering
241
+ - "Stop guessing" - You're proposing fixes without understanding
242
+ - "Ultrathink this" - Question fundamentals, not just symptoms
243
+ - "We're stuck?" (frustrated) - Your approach isn't working
244
+
245
+ **When you see these:** STOP. Return to Phase 1.
246
+
247
+ ## Common Rationalizations
248
+
249
+ | Excuse | Reality |
250
+ |--------|---------|
251
+ | "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
252
+ | "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
253
+ | "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
254
+ | "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
255
+ | "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
256
+ | "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
257
+ | "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
258
+ | "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
259
+
260
+ ## Quick Reference
261
+
262
+ | Phase | Key Activities | Success Criteria |
263
+ |-------|---------------|------------------|
264
+ | **1. Root Cause** | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |
265
+ | **2. Pattern** | Find working examples, compare | Identify differences |
266
+ | **3. Hypothesis** | Form theory, test minimally | Confirmed or new hypothesis |
267
+ | **4. Implementation** | Create test, fix, verify | Bug resolved, tests pass |
268
+
269
+ ## When Process Reveals "No Root Cause"
270
+
271
+ If systematic investigation reveals issue is truly environmental, timing-dependent, or external:
272
+
273
+ 1. You've completed the process
274
+ 2. Document what you investigated
275
+ 3. Implement appropriate handling (retry, timeout, error message)
276
+ 4. Add monitoring/logging for future investigation
277
+
278
+ **But:** 95% of "no root cause" cases are incomplete investigation.
279
+
280
+ ## Integration with Other Skills
281
+
282
+ **This skill requires using:**
283
+ - **root-cause-tracing** - REQUIRED when error is deep in call stack (see Phase 1, Step 5)
284
+ - **test-driven-development** - REQUIRED for creating failing test case (see Phase 4, Step 1)
285
+
286
+ **Complementary skills:**
287
+ - **defense-in-depth** - Add validation at multiple layers after finding root cause
288
+ - **condition-based-waiting** - Replace arbitrary timeouts identified in Phase 2
289
+ - **verification-before-completion** - Verify fix worked before claiming success
290
+
291
+ ## Real-World Impact
292
+
293
+ From debugging sessions:
294
+ - Systematic approach: 15-30 minutes to fix
295
+ - Random fixes approach: 2-3 hours of thrashing
296
+ - First-time fix rate: 95% vs 40%
297
+ - New bugs introduced: Near zero vs common
@@ -0,0 +1,390 @@
1
+ ---
2
+ name: test-driven-development
3
+ description: Use when implementing any feature or bugfix, before writing implementation code - write the test first, watch it fail, write minimal code to pass; ensures tests actually verify behavior by requiring failure first
4
+ ---
5
+
6
+ # Test-Driven Development (TDD)
7
+
8
+ ## Auto-Trigger
9
+
10
+ **APPLIES WHEN:**
11
+ - About to write new production code (function, method, class)
12
+ - Implementing any feature or bug fix
13
+ - Modifying behavior of existing code
14
+ - Task metadata includes `tdd: yes`
15
+ - User requests feature implementation
16
+
17
+ **APPLIES TO:**
18
+ - All production code changes
19
+ - Feature implementations
20
+ - Bug fixes
21
+ - Refactoring that changes behavior
22
+ - API endpoint creation
23
+ - Model/class creation
24
+
25
+ **DOES NOT APPLY TO:**
26
+ - Documentation files
27
+ - Configuration files (unless logic-bearing)
28
+ - Throwaway prototypes (with explicit user permission)
29
+ - Generated code (with explicit user permission)
30
+
31
+ **ENFORCEMENT:**
32
+ If you find yourself writing implementation code before tests, STOP immediately. Delete the implementation and start over with TDD.
33
+
34
+ ## Overview
35
+
36
+ Write the test first. Watch it fail. Write minimal code to pass.
37
+
38
+ **Core principle:** If you didn't watch the test fail, you don't know if it tests the right thing.
39
+
40
+ **Violating the letter of the rules is violating the spirit of the rules.**
41
+
42
+ ## When to Use
43
+
44
+ **Always:**
45
+ - New features
46
+ - Bug fixes
47
+ - Refactoring
48
+ - Behavior changes
49
+
50
+ **Exceptions (ask your human partner):**
51
+ - Throwaway prototypes
52
+ - Generated code
53
+ - Configuration files
54
+
55
+ Thinking "skip TDD just this once"? Stop. That's rationalization.
56
+
57
+ ## The Iron Law
58
+
59
+ ```
60
+ NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
61
+ ```
62
+
63
+ Write code before the test? Delete it. Start over.
64
+
65
+ **No exceptions:**
66
+ - Don't keep it as "reference"
67
+ - Don't "adapt" it while writing tests
68
+ - Don't look at it
69
+ - Delete means delete
70
+
71
+ Implement fresh from tests. Period.
72
+
73
+ ## Red-Green-Refactor
74
+
75
+ ```dot
76
+ digraph tdd_cycle {
77
+ rankdir=LR;
78
+ red [label="RED\nWrite failing test", shape=box, style=filled, fillcolor="#ffcccc"];
79
+ verify_red [label="Verify fails\ncorrectly", shape=diamond];
80
+ green [label="GREEN\nMinimal code", shape=box, style=filled, fillcolor="#ccffcc"];
81
+ verify_green [label="Verify passes\nAll green", shape=diamond];
82
+ refactor [label="REFACTOR\nClean up", shape=box, style=filled, fillcolor="#ccccff"];
83
+ next [label="Next", shape=ellipse];
84
+
85
+ red -> verify_red;
86
+ verify_red -> green [label="yes"];
87
+ verify_red -> red [label="wrong\nfailure"];
88
+ green -> verify_green;
89
+ verify_green -> refactor [label="yes"];
90
+ verify_green -> green [label="no"];
91
+ refactor -> verify_green [label="stay\ngreen"];
92
+ verify_green -> next;
93
+ next -> red;
94
+ }
95
+ ```
96
+
97
+ ### RED - Write Failing Test
98
+
99
+ Write one minimal test showing what should happen.
100
+
101
+ <Good>
102
+ ```typescript
103
+ test('retries failed operations 3 times', async () => {
104
+ let attempts = 0;
105
+ const operation = () => {
106
+ attempts++;
107
+ if (attempts < 3) throw new Error('fail');
108
+ return 'success';
109
+ };
110
+
111
+ const result = await retryOperation(operation);
112
+
113
+ expect(result).toBe('success');
114
+ expect(attempts).toBe(3);
115
+ });
116
+ ```
117
+ Clear name, tests real behavior, one thing
118
+ </Good>
119
+
120
+ <Bad>
121
+ ```typescript
122
+ test('retry works', async () => {
123
+ const mock = jest.fn()
124
+ .mockRejectedValueOnce(new Error())
125
+ .mockRejectedValueOnce(new Error())
126
+ .mockResolvedValueOnce('success');
127
+ await retryOperation(mock);
128
+ expect(mock).toHaveBeenCalledTimes(3);
129
+ });
130
+ ```
131
+ Vague name, tests mock not code
132
+ </Bad>
133
+
134
+ **Requirements:**
135
+ - One behavior
136
+ - Clear name
137
+ - Real code (no mocks unless unavoidable)
138
+
139
+ ### Verify RED - Watch It Fail
140
+
141
+ **MANDATORY. Never skip.**
142
+
143
+ ```bash
144
+ npm test path/to/test.test.ts
145
+ ```
146
+
147
+ Confirm:
148
+ - Test fails (not errors)
149
+ - Failure message is expected
150
+ - Fails because feature missing (not typos)
151
+
152
+ **Test passes?** You're testing existing behavior. Fix test.
153
+
154
+ **Test errors?** Fix error, re-run until it fails correctly.
155
+
156
+ ### GREEN - Minimal Code
157
+
158
+ Write simplest code to pass the test.
159
+
160
+ <Good>
161
+ ```typescript
162
+ async function retryOperation<T>(fn: () => Promise<T>): Promise<T> {
163
+ for (let i = 0; i < 3; i++) {
164
+ try {
165
+ return await fn();
166
+ } catch (e) {
167
+ if (i === 2) throw e;
168
+ }
169
+ }
170
+ throw new Error('unreachable');
171
+ }
172
+ ```
173
+ Just enough to pass
174
+ </Good>
175
+
176
+ <Bad>
177
+ ```typescript
178
+ async function retryOperation<T>(
179
+ fn: () => Promise<T>,
180
+ options?: {
181
+ maxRetries?: number;
182
+ backoff?: 'linear' | 'exponential';
183
+ onRetry?: (attempt: number) => void;
184
+ }
185
+ ): Promise<T> {
186
+ // YAGNI
187
+ }
188
+ ```
189
+ Over-engineered
190
+ </Bad>
191
+
192
+ Don't add features, refactor other code, or "improve" beyond the test.
193
+
194
+ ### Verify GREEN - Watch It Pass
195
+
196
+ **MANDATORY.**
197
+
198
+ ```bash
199
+ npm test path/to/test.test.ts
200
+ ```
201
+
202
+ Confirm:
203
+ - Test passes
204
+ - Other tests still pass
205
+ - Output pristine (no errors, warnings)
206
+
207
+ **Test fails?** Fix code, not test.
208
+
209
+ **Other tests fail?** Fix now.
210
+
211
+ ### REFACTOR - Clean Up
212
+
213
+ After green only:
214
+ - Remove duplication
215
+ - Improve names
216
+ - Extract helpers
217
+
218
+ Keep tests green. Don't add behavior.
219
+
220
+ ### Repeat
221
+
222
+ Next failing test for next feature.
223
+
224
+ ## Good Tests
225
+
226
+ | Quality | Good | Bad |
227
+ |---------|------|-----|
228
+ | **Minimal** | One thing. "and" in name? Split it. | `test('validates email and domain and whitespace')` |
229
+ | **Clear** | Name describes behavior | `test('test1')` |
230
+ | **Shows intent** | Demonstrates desired API | Obscures what code should do |
231
+
232
+ ## Why Order Matters
233
+
234
+ **"I'll write tests after to verify it works"**
235
+
236
+ Tests written after code pass immediately. Passing immediately proves nothing:
237
+ - Might test wrong thing
238
+ - Might test implementation, not behavior
239
+ - Might miss edge cases you forgot
240
+ - You never saw it catch the bug
241
+
242
+ Test-first forces you to see the test fail, proving it actually tests something.
243
+
244
+ **"I already manually tested all the edge cases"**
245
+
246
+ Manual testing is ad-hoc. You think you tested everything but:
247
+ - No record of what you tested
248
+ - Can't re-run when code changes
249
+ - Easy to forget cases under pressure
250
+ - "It worked when I tried it" ≠ comprehensive
251
+
252
+ Automated tests are systematic. They run the same way every time.
253
+
254
+ **"Deleting X hours of work is wasteful"**
255
+
256
+ Sunk cost fallacy. The time is already gone. Your choice now:
257
+ - Delete and rewrite with TDD (X more hours, high confidence)
258
+ - Keep it and add tests after (30 min, low confidence, likely bugs)
259
+
260
+ The "waste" is keeping code you can't trust. Working code without real tests is technical debt.
261
+
262
+ **"TDD is dogmatic, being pragmatic means adapting"**
263
+
264
+ TDD IS pragmatic:
265
+ - Finds bugs before commit (faster than debugging after)
266
+ - Prevents regressions (tests catch breaks immediately)
267
+ - Documents behavior (tests show how to use code)
268
+ - Enables refactoring (change freely, tests catch breaks)
269
+
270
+ "Pragmatic" shortcuts = debugging in production = slower.
271
+
272
+ **"Tests after achieve the same goals - it's spirit not ritual"**
273
+
274
+ No. Tests-after answer "What does this do?" Tests-first answer "What should this do?"
275
+
276
+ Tests-after are biased by your implementation. You test what you built, not what's required. You verify remembered edge cases, not discovered ones.
277
+
278
+ Tests-first force edge case discovery before implementing. Tests-after verify you remembered everything (you didn't).
279
+
280
+ 30 minutes of tests after ≠ TDD. You get coverage, lose proof tests work.
281
+
282
+ ## Common Rationalizations
283
+
284
+ | Excuse | Reality |
285
+ |--------|---------|
286
+ | "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
287
+ | "I'll test after" | Tests passing immediately prove nothing. |
288
+ | "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
289
+ | "Already manually tested" | Ad-hoc ≠ systematic. No record, can't re-run. |
290
+ | "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is technical debt. |
291
+ | "Keep as reference, write tests first" | You'll adapt it. That's testing after. Delete means delete. |
292
+ | "Need to explore first" | Fine. Throw away exploration, start with TDD. |
293
+ | "Test hard = design unclear" | Listen to test. Hard to test = hard to use. |
294
+ | "TDD will slow me down" | TDD faster than debugging. Pragmatic = test-first. |
295
+ | "Manual test faster" | Manual doesn't prove edge cases. You'll re-test every change. |
296
+ | "Existing code has no tests" | You're improving it. Add tests for existing code. |
297
+
298
+ ## Red Flags - STOP and Start Over
299
+
300
+ - Code before test
301
+ - Test after implementation
302
+ - Test passes immediately
303
+ - Can't explain why test failed
304
+ - Tests added "later"
305
+ - Rationalizing "just this once"
306
+ - "I already manually tested it"
307
+ - "Tests after achieve the same purpose"
308
+ - "It's about spirit not ritual"
309
+ - "Keep as reference" or "adapt existing code"
310
+ - "Already spent X hours, deleting is wasteful"
311
+ - "TDD is dogmatic, I'm being pragmatic"
312
+ - "This is different because..."
313
+
314
+ **All of these mean: Delete code. Start over with TDD.**
315
+
316
+ ## Example: Bug Fix
317
+
318
+ **Bug:** Empty email accepted
319
+
320
+ **RED**
321
+ ```typescript
322
+ test('rejects empty email', async () => {
323
+ const result = await submitForm({ email: '' });
324
+ expect(result.error).toBe('Email required');
325
+ });
326
+ ```
327
+
328
+ **Verify RED**
329
+ ```bash
330
+ $ npm test
331
+ FAIL: expected 'Email required', got undefined
332
+ ```
333
+
334
+ **GREEN**
335
+ ```typescript
336
+ function submitForm(data: FormData) {
337
+ if (!data.email?.trim()) {
338
+ return { error: 'Email required' };
339
+ }
340
+ // ...
341
+ }
342
+ ```
343
+
344
+ **Verify GREEN**
345
+ ```bash
346
+ $ npm test
347
+ PASS
348
+ ```
349
+
350
+ **REFACTOR**
351
+ Extract validation for multiple fields if needed.
352
+
353
+ ## Verification Checklist
354
+
355
+ Before marking work complete:
356
+
357
+ - [ ] Every new function/method has a test
358
+ - [ ] Watched each test fail before implementing
359
+ - [ ] Each test failed for expected reason (feature missing, not typo)
360
+ - [ ] Wrote minimal code to pass each test
361
+ - [ ] All tests pass
362
+ - [ ] Output pristine (no errors, warnings)
363
+ - [ ] Tests use real code (mocks only if unavoidable)
364
+ - [ ] Edge cases and errors covered
365
+
366
+ Can't check all boxes? You skipped TDD. Start over.
367
+
368
+ ## When Stuck
369
+
370
+ | Problem | Solution |
371
+ |---------|----------|
372
+ | Don't know how to test | Write wished-for API. Write assertion first. Ask your human partner. |
373
+ | Test too complicated | Design too complicated. Simplify interface. |
374
+ | Must mock everything | Code too coupled. Use dependency injection. |
375
+ | Test setup huge | Extract helpers. Still complex? Simplify design. |
376
+
377
+ ## Debugging Integration
378
+
379
+ Bug found? Write failing test reproducing it. Follow TDD cycle. Test proves fix and prevents regression.
380
+
381
+ Never fix bugs without a test.
382
+
383
+ ## Final Rule
384
+
385
+ ```
386
+ Production code → test exists and failed first
387
+ Otherwise → not TDD
388
+ ```
389
+
390
+ No exceptions without your human partner's permission.
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: test-generate
3
+ description: Generate tests [file]
4
+ usage: /test-generate <code-section>
5
+ argument-hint: [file-to-test]
6
+ ---
7
+ Generate tests for $ARGUMENTS.
8
+
9
+ ## Include
10
+ - Happy path (expected usage)
11
+ - Edge cases (empty, null, boundaries)
12
+ - Error scenarios (invalid input, failures)
13
+ - Integration points (mocks for external deps)
14
+
15
+ ## Requirements
16
+ - Match existing test patterns in this project
17
+ - Use the testing framework already in use
18
+ - Clear test names: "should [expected] when [condition]"