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,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]"
@@ -0,0 +1,304 @@
1
+ ---
2
+ name: testing-anti-patterns
3
+ description: Use when writing or changing tests, adding mocks, or tempted to add test-only methods to production code - prevents testing mock behavior, production pollution with test-only methods, and mocking without understanding dependencies
4
+ usage: /testing-anti-patterns <testing-scenario>
5
+ auto_trigger: true
6
+ ---
7
+
8
+ # Testing Anti-Patterns
9
+
10
+ ## Overview
11
+
12
+ Tests must verify real behavior, not mock behavior. Mocks are a means to isolate, not the thing being tested.
13
+
14
+ **Core principle:** Test what the code does, not what the mocks do.
15
+
16
+ **Following strict TDD prevents these anti-patterns.**
17
+
18
+ ## The Iron Laws
19
+
20
+ ```
21
+ 1. NEVER test mock behavior
22
+ 2. NEVER add test-only methods to production classes
23
+ 3. NEVER mock without understanding dependencies
24
+ ```
25
+
26
+ ## Anti-Pattern 1: Testing Mock Behavior
27
+
28
+ **The violation:**
29
+ ```typescript
30
+ // ❌ BAD: Testing that the mock exists
31
+ test('renders sidebar', () => {
32
+ render(<Page />);
33
+ expect(screen.getByTestId('sidebar-mock')).toBeInTheDocument();
34
+ });
35
+ ```
36
+
37
+ **Why this is wrong:**
38
+ - You're verifying the mock works, not that the component works
39
+ - Test passes when mock is present, fails when it's not
40
+ - Tells you nothing about real behavior
41
+
42
+ **your human partner's correction:** "Are we testing the behavior of a mock?"
43
+
44
+ **The fix:**
45
+ ```typescript
46
+ // ✅ GOOD: Test real component or don't mock it
47
+ test('renders sidebar', () => {
48
+ render(<Page />); // Don't mock sidebar
49
+ expect(screen.getByRole('navigation')).toBeInTheDocument();
50
+ });
51
+
52
+ // OR if sidebar must be mocked for isolation:
53
+ // Don't assert on the mock - test Page's behavior with sidebar present
54
+ ```
55
+
56
+ ### Gate Function
57
+
58
+ ```
59
+ BEFORE asserting on any mock element:
60
+ Ask: "Am I testing real component behavior or just mock existence?"
61
+
62
+ IF testing mock existence:
63
+ STOP - Delete the assertion or unmock the component
64
+
65
+ Test real behavior instead
66
+ ```
67
+
68
+ ## Anti-Pattern 2: Test-Only Methods in Production
69
+
70
+ **The violation:**
71
+ ```typescript
72
+ // ❌ BAD: destroy() only used in tests
73
+ class Session {
74
+ async destroy() { // Looks like production API!
75
+ await this._workspaceManager?.destroyWorkspace(this.id);
76
+ // ... cleanup
77
+ }
78
+ }
79
+
80
+ // In tests
81
+ afterEach(() => session.destroy());
82
+ ```
83
+
84
+ **Why this is wrong:**
85
+ - Production class polluted with test-only code
86
+ - Dangerous if accidentally called in production
87
+ - Violates YAGNI and separation of concerns
88
+ - Confuses object lifecycle with entity lifecycle
89
+
90
+ **The fix:**
91
+ ```typescript
92
+ // ✅ GOOD: Test utilities handle test cleanup
93
+ // Session has no destroy() - it's stateless in production
94
+
95
+ // In test-utils/
96
+ export async function cleanupSession(session: Session) {
97
+ const workspace = session.getWorkspaceInfo();
98
+ if (workspace) {
99
+ await workspaceManager.destroyWorkspace(workspace.id);
100
+ }
101
+ }
102
+
103
+ // In tests
104
+ afterEach(() => cleanupSession(session));
105
+ ```
106
+
107
+ ### Gate Function
108
+
109
+ ```
110
+ BEFORE adding any method to production class:
111
+ Ask: "Is this only used by tests?"
112
+
113
+ IF yes:
114
+ STOP - Don't add it
115
+ Put it in test utilities instead
116
+
117
+ Ask: "Does this class own this resource's lifecycle?"
118
+
119
+ IF no:
120
+ STOP - Wrong class for this method
121
+ ```
122
+
123
+ ## Anti-Pattern 3: Mocking Without Understanding
124
+
125
+ **The violation:**
126
+ ```typescript
127
+ // ❌ BAD: Mock breaks test logic
128
+ test('detects duplicate server', () => {
129
+ // Mock prevents config write that test depends on!
130
+ vi.mock('ToolCatalog', () => ({
131
+ discoverAndCacheTools: vi.fn().mockResolvedValue(undefined)
132
+ }));
133
+
134
+ await addServer(config);
135
+ await addServer(config); // Should throw - but won't!
136
+ });
137
+ ```
138
+
139
+ **Why this is wrong:**
140
+ - Mocked method had side effect test depended on (writing config)
141
+ - Over-mocking to "be safe" breaks actual behavior
142
+ - Test passes for wrong reason or fails mysteriously
143
+
144
+ **The fix:**
145
+ ```typescript
146
+ // ✅ GOOD: Mock at correct level
147
+ test('detects duplicate server', () => {
148
+ // Mock the slow part, preserve behavior test needs
149
+ vi.mock('MCPServerManager'); // Just mock slow server startup
150
+
151
+ await addServer(config); // Config written
152
+ await addServer(config); // Duplicate detected ✓
153
+ });
154
+ ```
155
+
156
+ ### Gate Function
157
+
158
+ ```
159
+ BEFORE mocking any method:
160
+ STOP - Don't mock yet
161
+
162
+ 1. Ask: "What side effects does the real method have?"
163
+ 2. Ask: "Does this test depend on any of those side effects?"
164
+ 3. Ask: "Do I fully understand what this test needs?"
165
+
166
+ IF depends on side effects:
167
+ Mock at lower level (the actual slow/external operation)
168
+ OR use test doubles that preserve necessary behavior
169
+ NOT the high-level method the test depends on
170
+
171
+ IF unsure what test depends on:
172
+ Run test with real implementation FIRST
173
+ Observe what actually needs to happen
174
+ THEN add minimal mocking at the right level
175
+
176
+ Red flags:
177
+ - "I'll mock this to be safe"
178
+ - "This might be slow, better mock it"
179
+ - Mocking without understanding the dependency chain
180
+ ```
181
+
182
+ ## Anti-Pattern 4: Incomplete Mocks
183
+
184
+ **The violation:**
185
+ ```typescript
186
+ // ❌ BAD: Partial mock - only fields you think you need
187
+ const mockResponse = {
188
+ status: 'success',
189
+ data: { userId: '123', name: 'Alice' }
190
+ // Missing: metadata that downstream code uses
191
+ };
192
+
193
+ // Later: breaks when code accesses response.metadata.requestId
194
+ ```
195
+
196
+ **Why this is wrong:**
197
+ - **Partial mocks hide structural assumptions** - You only mocked fields you know about
198
+ - **Downstream code may depend on fields you didn't include** - Silent failures
199
+ - **Tests pass but integration fails** - Mock incomplete, real API complete
200
+ - **False confidence** - Test proves nothing about real behavior
201
+
202
+ **The Iron Rule:** Mock the COMPLETE data structure as it exists in reality, not just fields your immediate test uses.
203
+
204
+ **The fix:**
205
+ ```typescript
206
+ // ✅ GOOD: Mirror real API completeness
207
+ const mockResponse = {
208
+ status: 'success',
209
+ data: { userId: '123', name: 'Alice' },
210
+ metadata: { requestId: 'req-789', timestamp: 1234567890 }
211
+ // All fields real API returns
212
+ };
213
+ ```
214
+
215
+ ### Gate Function
216
+
217
+ ```
218
+ BEFORE creating mock responses:
219
+ Check: "What fields does the real API response contain?"
220
+
221
+ Actions:
222
+ 1. Examine actual API response from docs/examples
223
+ 2. Include ALL fields system might consume downstream
224
+ 3. Verify mock matches real response schema completely
225
+
226
+ Critical:
227
+ If you're creating a mock, you must understand the ENTIRE structure
228
+ Partial mocks fail silently when code depends on omitted fields
229
+
230
+ If uncertain: Include all documented fields
231
+ ```
232
+
233
+ ## Anti-Pattern 5: Integration Tests as Afterthought
234
+
235
+ **The violation:**
236
+ ```
237
+ ✅ Implementation complete
238
+ ❌ No tests written
239
+ "Ready for testing"
240
+ ```
241
+
242
+ **Why this is wrong:**
243
+ - Testing is part of implementation, not optional follow-up
244
+ - TDD would have caught this
245
+ - Can't claim complete without tests
246
+
247
+ **The fix:**
248
+ ```
249
+ TDD cycle:
250
+ 1. Write failing test
251
+ 2. Implement to pass
252
+ 3. Refactor
253
+ 4. THEN claim complete
254
+ ```
255
+
256
+ ## When Mocks Become Too Complex
257
+
258
+ **Warning signs:**
259
+ - Mock setup longer than test logic
260
+ - Mocking everything to make test pass
261
+ - Mocks missing methods real components have
262
+ - Test breaks when mock changes
263
+
264
+ **your human partner's question:** "Do we need to be using a mock here?"
265
+
266
+ **Consider:** Integration tests with real components often simpler than complex mocks
267
+
268
+ ## TDD Prevents These Anti-Patterns
269
+
270
+ **Why TDD helps:**
271
+ 1. **Write test first** → Forces you to think about what you're actually testing
272
+ 2. **Watch it fail** → Confirms test tests real behavior, not mocks
273
+ 3. **Minimal implementation** → No test-only methods creep in
274
+ 4. **Real dependencies** → You see what the test actually needs before mocking
275
+
276
+ **If you're testing mock behavior, you violated TDD** - you added mocks without watching test fail against real code first.
277
+
278
+ ## Quick Reference
279
+
280
+ | Anti-Pattern | Fix |
281
+ |--------------|-----|
282
+ | Assert on mock elements | Test real component or unmock it |
283
+ | Test-only methods in production | Move to test utilities |
284
+ | Mock without understanding | Understand dependencies first, mock minimally |
285
+ | Incomplete mocks | Mirror real API completely |
286
+ | Tests as afterthought | TDD - tests first |
287
+ | Over-complex mocks | Consider integration tests |
288
+
289
+ ## Red Flags
290
+
291
+ - Assertion checks for `*-mock` test IDs
292
+ - Methods only called in test files
293
+ - Mock setup is >50% of test
294
+ - Test fails when you remove mock
295
+ - Can't explain why mock is needed
296
+ - Mocking "just to be safe"
297
+
298
+ ## The Bottom Line
299
+
300
+ **Mocks are tools to isolate, not things to test.**
301
+
302
+ If TDD reveals you're testing mock behavior, you've gone wrong.
303
+
304
+ Fix: Test real behavior or question why you're mocking at all.