@nst173/superpowers-ccg 1.3.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 (97) hide show
  1. package/.agent/skills/brainstorming/SKILL.md +26 -0
  2. package/.agent/skills/coordinating-multi-model-work/SKILL.md +29 -0
  3. package/.agent/skills/executing-plans/SKILL.md +27 -0
  4. package/.agent/skills/using-superpowers/SKILL.md +29 -0
  5. package/.agent/skills/verifying-before-completion/SKILL.md +20 -0
  6. package/.agent/skills/writing-plans/SKILL.md +29 -0
  7. package/.cursor/agents/code-reviewer.md +22 -0
  8. package/.cursor/commands/brainstorm.md +11 -0
  9. package/.cursor/commands/execute-plan.md +12 -0
  10. package/.cursor/commands/write-plan.md +11 -0
  11. package/.cursor/hook-scripts/after-file-edit.mjs +3 -0
  12. package/.cursor/hook-scripts/before-shell-execution.mjs +3 -0
  13. package/.cursor/hook-scripts/session-end.mjs +3 -0
  14. package/.cursor/hooks.json +21 -0
  15. package/.cursor/mcp.json +20 -0
  16. package/.cursor/rules/checkpoint-protocol.mdc +11 -0
  17. package/.cursor/rules/orchestrator-routing.mdc +12 -0
  18. package/.cursor/rules/token-discipline.mdc +12 -0
  19. package/.cursor/skills/brainstorming/SKILL.md +26 -0
  20. package/.cursor/skills/coordinating-multi-model-work/SKILL.md +29 -0
  21. package/.cursor/skills/executing-plans/SKILL.md +27 -0
  22. package/.cursor/skills/using-superpowers/SKILL.md +29 -0
  23. package/.cursor/skills/verifying-before-completion/SKILL.md +20 -0
  24. package/.cursor/skills/writing-plans/SKILL.md +29 -0
  25. package/AGENTS.md +23 -0
  26. package/CLAUDE.md +78 -0
  27. package/GEMINI.md +27 -0
  28. package/LICENSE +21 -0
  29. package/README.md +171 -0
  30. package/agents/code-reviewer.md +54 -0
  31. package/cli/superpowers-ccg.mjs +8 -0
  32. package/commands/brainstorm.md +6 -0
  33. package/commands/execute-plan.md +6 -0
  34. package/commands/write-plan.md +6 -0
  35. package/config/antigravity/mcp_config.example.json +26 -0
  36. package/hooks/hooks.json +37 -0
  37. package/hooks/pre-tool-use-task.sh +4 -0
  38. package/hooks/run-hook.cmd +19 -0
  39. package/hooks/session-start.sh +72 -0
  40. package/hooks/user-prompt-submit.sh +31 -0
  41. package/package.json +56 -0
  42. package/skills/EVALUATION.md +201 -0
  43. package/skills/brainstorming/SKILL.md +120 -0
  44. package/skills/coordinating-multi-model-work/GATE.md +36 -0
  45. package/skills/coordinating-multi-model-work/INTEGRATION.md +51 -0
  46. package/skills/coordinating-multi-model-work/SKILL.md +51 -0
  47. package/skills/coordinating-multi-model-work/checkpoints.md +31 -0
  48. package/skills/coordinating-multi-model-work/cross-validation.md +37 -0
  49. package/skills/coordinating-multi-model-work/prompts/codex-base.md +40 -0
  50. package/skills/coordinating-multi-model-work/prompts/gemini-base.md +41 -0
  51. package/skills/coordinating-multi-model-work/review-chain.md +25 -0
  52. package/skills/coordinating-multi-model-work/routing-decision.md +50 -0
  53. package/skills/debugging-systematically/CREATION-LOG.md +119 -0
  54. package/skills/debugging-systematically/SKILL.md +325 -0
  55. package/skills/debugging-systematically/condition-based-waiting-example.ts +158 -0
  56. package/skills/debugging-systematically/condition-based-waiting.md +115 -0
  57. package/skills/debugging-systematically/defense-in-depth.md +122 -0
  58. package/skills/debugging-systematically/find-polluter.sh +63 -0
  59. package/skills/debugging-systematically/root-cause-tracing.md +169 -0
  60. package/skills/debugging-systematically/test-academic.md +14 -0
  61. package/skills/debugging-systematically/test-pressure-1.md +58 -0
  62. package/skills/debugging-systematically/test-pressure-2.md +68 -0
  63. package/skills/debugging-systematically/test-pressure-3.md +69 -0
  64. package/skills/developing-with-subagents/SKILL.md +51 -0
  65. package/skills/developing-with-subagents/code-quality-reviewer-prompt.md +30 -0
  66. package/skills/developing-with-subagents/implementer-prompt.md +41 -0
  67. package/skills/developing-with-subagents/spec-reviewer-prompt.md +25 -0
  68. package/skills/dispatching-parallel-agents/SKILL.md +195 -0
  69. package/skills/executing-plans/SKILL.md +67 -0
  70. package/skills/finishing-development-branches/SKILL.md +208 -0
  71. package/skills/practicing-test-driven-development/SKILL.md +346 -0
  72. package/skills/practicing-test-driven-development/testing-anti-patterns.md +299 -0
  73. package/skills/receiving-code-review/SKILL.md +221 -0
  74. package/skills/requesting-code-review/SKILL.md +127 -0
  75. package/skills/requesting-code-review/code-reviewer.md +146 -0
  76. package/skills/shared/multi-model-integration-section.md +32 -0
  77. package/skills/shared/protocol-threshold.md +46 -0
  78. package/skills/shared/supplementary-tools.md +132 -0
  79. package/skills/shared/task-format-reference.md +83 -0
  80. package/skills/using-git-worktrees/SKILL.md +225 -0
  81. package/skills/using-superpowers/SKILL.md +101 -0
  82. package/skills/verifying-before-completion/SKILL.md +159 -0
  83. package/skills/writing-plans/SKILL.md +55 -0
  84. package/skills/writing-skills/CHECKLIST.md +92 -0
  85. package/skills/writing-skills/SKILL.md +111 -0
  86. package/skills/writing-skills/STRUCTURE.md +208 -0
  87. package/skills/writing-skills/TESTING.md +155 -0
  88. package/skills/writing-skills/anthropic-best-practices.md +1150 -0
  89. package/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  90. package/skills/writing-skills/graphviz-conventions.dot +172 -0
  91. package/skills/writing-skills/persuasion-principles.md +187 -0
  92. package/skills/writing-skills/render-graphs.js +168 -0
  93. package/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  94. package/src/cli.mjs +165 -0
  95. package/src/constants.mjs +7 -0
  96. package/src/install.mjs +186 -0
  97. package/src/io.mjs +81 -0
@@ -0,0 +1,346 @@
1
+ ---
2
+ name: practicing-test-driven-development
3
+ description: "Write failing tests before implementation code using red-green-refactor cycle. Use when: implementing features, fixing bugs, refactoring code, or changing behavior. Keywords: TDD, test first, unit test, red-green, failing test"
4
+ ---
5
+
6
+ # Test-Driven Development (TDD)
7
+
8
+ ## Contents
9
+
10
+ - [Overview](#overview)
11
+ - [The Iron Law](#the-iron-law)
12
+ - [Red-Green-Refactor](#red-green-refactor)
13
+ - [Good Tests](#good-tests)
14
+ - [Red Flags](#red-flags---stop-and-start-over)
15
+ - [Verification Checklist](#verification-checklist)
16
+ - [Multi-Model Test Generation](#multi-model-test-generation)
17
+
18
+ ## Overview
19
+
20
+ Write the test first. Watch it fail. Write minimal code to pass.
21
+
22
+ **Core principle:** If you didn't watch the test fail, you don't know if it tests the right thing.
23
+
24
+ **Violating the letter of the rules is violating the spirit of the rules.**
25
+
26
+ ## Protocol Threshold (Required)
27
+
28
+ Follow `skills/shared/protocol-threshold.md`. The hook injects CP reminders automatically.
29
+
30
+ ## When to Use
31
+
32
+ **Always:**
33
+
34
+ - New features
35
+ - Bug fixes
36
+ - Refactoring
37
+ - Behavior changes
38
+
39
+ **Exceptions (ask your human partner):**
40
+
41
+ - Throwaway prototypes
42
+ - Generated code
43
+ - Configuration files
44
+
45
+ Thinking "skip TDD just this once"? Stop. That's rationalization.
46
+
47
+ ## The Iron Law
48
+
49
+ ```
50
+ NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
51
+ ```
52
+
53
+ Write code before the test? Delete it. Start over.
54
+
55
+ **No exceptions:**
56
+
57
+ - Don't keep it as "reference"
58
+ - Don't "adapt" it while writing tests
59
+ - Don't look at it
60
+ - Delete means delete
61
+
62
+ Implement fresh from tests. Period.
63
+
64
+ ## Red-Green-Refactor
65
+
66
+ ```dot
67
+ digraph tdd_cycle {
68
+ rankdir=LR;
69
+ red [label="RED\nWrite failing test", shape=box, style=filled, fillcolor="#ffcccc"];
70
+ verify_red [label="Verify fails\ncorrectly", shape=diamond];
71
+ green [label="GREEN\nMinimal code", shape=box, style=filled, fillcolor="#ccffcc"];
72
+ verify_green [label="Verify passes\nAll green", shape=diamond];
73
+ refactor [label="REFACTOR\nClean up", shape=box, style=filled, fillcolor="#ccccff"];
74
+ next [label="Next", shape=ellipse];
75
+
76
+ red -> verify_red;
77
+ verify_red -> green [label="yes"];
78
+ verify_red -> red [label="wrong\nfailure"];
79
+ green -> verify_green;
80
+ verify_green -> refactor [label="yes"];
81
+ verify_green -> green [label="no"];
82
+ refactor -> verify_green [label="stay\ngreen"];
83
+ verify_green -> next;
84
+ next -> red;
85
+ }
86
+ ```
87
+
88
+ ### RED - Write Failing Test
89
+
90
+ Write one minimal test showing what should happen.
91
+
92
+ **► CP1 (Task Analysis):** Before writing test, apply `coordinating-multi-model-work/checkpoints.md`.
93
+
94
+ **✅ Good example:**
95
+
96
+ ```typescript
97
+ test("retries failed operations 3 times", async () => {
98
+ let attempts = 0;
99
+ const operation = () => {
100
+ attempts++;
101
+ if (attempts < 3) throw new Error("fail");
102
+ return "success";
103
+ };
104
+
105
+ const result = await retryOperation(operation);
106
+
107
+ expect(result).toBe("success");
108
+ expect(attempts).toBe(3);
109
+ });
110
+ ```
111
+
112
+ Clear name, tests real behavior, one thing
113
+
114
+ **❌ Bad example:**
115
+
116
+ ```typescript
117
+ test("retry works", async () => {
118
+ const mock = jest
119
+ .fn()
120
+ .mockRejectedValueOnce(new Error())
121
+ .mockRejectedValueOnce(new Error())
122
+ .mockResolvedValueOnce("success");
123
+ await retryOperation(mock);
124
+ expect(mock).toHaveBeenCalledTimes(3);
125
+ });
126
+ ```
127
+
128
+ Vague name, tests mock not code
129
+
130
+ **Requirements:**
131
+
132
+ - One behavior
133
+ - Clear name
134
+ - Real code (no mocks unless unavoidable)
135
+
136
+ ### Verify RED - Watch It Fail
137
+
138
+ **MANDATORY. Never skip.**
139
+
140
+ ```bash
141
+ npm test path/to/test.test.ts
142
+ ```
143
+
144
+ Confirm:
145
+
146
+ - Test fails (not errors)
147
+ - Failure message is expected
148
+ - Fails because feature missing (not typos)
149
+
150
+ **Test passes?** You're testing existing behavior. Fix test.
151
+
152
+ **Test errors?** Fix error, re-run until it fails correctly.
153
+
154
+ ### GREEN - Minimal Code
155
+
156
+ Write simplest code to pass the test.
157
+
158
+ **► CP3 (Quality Gate):** After implementation passes, apply `coordinating-multi-model-work/checkpoints.md`.
159
+
160
+ **✅ Good example:**
161
+
162
+ ```typescript
163
+ async function retryOperation<T>(fn: () => Promise<T>): Promise<T> {
164
+ for (let i = 0; i < 3; i++) {
165
+ try {
166
+ return await fn();
167
+ } catch (e) {
168
+ if (i === 2) throw e;
169
+ }
170
+ }
171
+ throw new Error("unreachable");
172
+ }
173
+ ```
174
+
175
+ Just enough to pass
176
+
177
+ **❌ Bad example:**
178
+
179
+ ```typescript
180
+ async function retryOperation<T>(
181
+ fn: () => Promise<T>,
182
+ options?: {
183
+ maxRetries?: number;
184
+ backoff?: "linear" | "exponential";
185
+ onRetry?: (attempt: number) => void;
186
+ },
187
+ ): Promise<T> {
188
+ // YAGNI
189
+ }
190
+ ```
191
+
192
+ Over-engineered
193
+
194
+ Don't add features, refactor other code, or "improve" beyond the test.
195
+
196
+ ### Verify GREEN - Watch It Pass
197
+
198
+ **MANDATORY.**
199
+
200
+ ```bash
201
+ npm test path/to/test.test.ts
202
+ ```
203
+
204
+ Confirm:
205
+
206
+ - Test passes
207
+ - Other tests still pass
208
+ - Output pristine (no errors, warnings)
209
+
210
+ **Test fails?** Fix code, not test.
211
+
212
+ **Other tests fail?** Fix now.
213
+
214
+ ### REFACTOR - Clean Up
215
+
216
+ After green only:
217
+
218
+ - Remove duplication
219
+ - Improve names
220
+ - Extract helpers
221
+
222
+ Keep tests green. Don't add behavior.
223
+
224
+ ### Repeat
225
+
226
+ Next failing test for next feature.
227
+
228
+ ## Good Tests
229
+
230
+ | Quality | Good | Bad |
231
+ | ---------------- | ----------------------------------- | --------------------------------------------------- |
232
+ | **Minimal** | One thing. "and" in name? Split it. | `test('validates email and domain and whitespace')` |
233
+ | **Clear** | Name describes behavior | `test('test1')` |
234
+ | **Shows intent** | Demonstrates desired API | Obscures what code should do |
235
+
236
+ ## Red Flags - STOP and Start Over
237
+
238
+ - Code before test
239
+ - Test after implementation
240
+ - Test passes immediately
241
+ - Can't explain why test failed
242
+ - Tests added "later"
243
+ - Rationalizing "just this once"
244
+ - "I already manually tested it"
245
+ - "Tests after achieve the same purpose"
246
+ - "It's about spirit not ritual"
247
+ - "Keep as reference" or "adapt existing code"
248
+ - "Already spent X hours, deleting is wasteful"
249
+ - "TDD is dogmatic, I'm being pragmatic"
250
+ - "This is different because..."
251
+
252
+ **All of these mean: Delete code. Start over with TDD.**
253
+
254
+ ## Example: Bug Fix
255
+
256
+ **Bug:** Empty email accepted
257
+
258
+ **RED**
259
+
260
+ ```typescript
261
+ test("rejects empty email", async () => {
262
+ const result = await submitForm({ email: "" });
263
+ expect(result.error).toBe("Email required");
264
+ });
265
+ ```
266
+
267
+ **Verify RED**
268
+
269
+ ```bash
270
+ $ npm test
271
+ FAIL: expected 'Email required', got undefined
272
+ ```
273
+
274
+ **GREEN**
275
+
276
+ ```typescript
277
+ function submitForm(data: FormData) {
278
+ if (!data.email?.trim()) {
279
+ return { error: "Email required" };
280
+ }
281
+ // ...
282
+ }
283
+ ```
284
+
285
+ **Verify GREEN**
286
+
287
+ ```bash
288
+ $ npm test
289
+ PASS
290
+ ```
291
+
292
+ **REFACTOR**
293
+ Extract validation for multiple fields if needed.
294
+
295
+ ## Verification Checklist
296
+
297
+ Before marking work complete:
298
+
299
+ - [ ] Every new function/method has a test
300
+ - [ ] Watched each test fail before implementing
301
+ - [ ] Each test failed for expected reason (feature missing, not typo)
302
+ - [ ] Wrote minimal code to pass each test
303
+ - [ ] All tests pass
304
+ - [ ] Output pristine (no errors, warnings)
305
+ - [ ] Tests use real code (mocks only if unavoidable)
306
+ - [ ] Edge cases and errors covered
307
+
308
+ Can't check all boxes? You skipped TDD. Start over.
309
+
310
+ ## When Stuck
311
+
312
+ | Problem | Solution |
313
+ | ---------------------- | -------------------------------------------------------------------- |
314
+ | Don't know how to test | Write wished-for API. Write assertion first. Ask your human partner. |
315
+ | Test too complicated | Design too complicated. Simplify interface. |
316
+ | Must mock everything | Code too coupled. Use dependency injection. |
317
+ | Test setup huge | Extract helpers. Still complex? Simplify design. |
318
+
319
+ ## Debugging Integration
320
+
321
+ Bug found? Write failing test reproducing it. Follow TDD cycle. Test proves fix and prevents regression.
322
+
323
+ Never fix bugs without a test.
324
+
325
+ ## Testing Anti-Patterns
326
+
327
+ When adding mocks or test utilities, read @testing-anti-patterns.md to avoid common pitfalls:
328
+
329
+ - Testing mock behavior instead of real behavior
330
+ - Adding test-only methods to production classes
331
+ - Mocking without understanding dependencies
332
+
333
+ ## Multi-Model Test Generation
334
+
335
+ See `skills/shared/multi-model-integration-section.md` for routing, invocation, and fallback rules.
336
+
337
+ **CRITICAL:** Generated tests **must still follow TDD cycle** — run them to confirm they fail (RED) before implementing.
338
+
339
+ ## Final Rule
340
+
341
+ ```
342
+ Production code → test exists and failed first
343
+ Otherwise → not TDD
344
+ ```
345
+
346
+ No exceptions without your human partner's permission.
@@ -0,0 +1,299 @@
1
+ # Testing Anti-Patterns
2
+
3
+ **Load this reference when:** writing or changing tests, adding mocks, or tempted to add test-only methods to production code.
4
+
5
+ ## Overview
6
+
7
+ Tests must verify real behavior, not mock behavior. Mocks are a means to isolate, not the thing being tested.
8
+
9
+ **Core principle:** Test what the code does, not what the mocks do.
10
+
11
+ **Following strict TDD prevents these anti-patterns.**
12
+
13
+ ## The Iron Laws
14
+
15
+ ```
16
+ 1. NEVER test mock behavior
17
+ 2. NEVER add test-only methods to production classes
18
+ 3. NEVER mock without understanding dependencies
19
+ ```
20
+
21
+ ## Anti-Pattern 1: Testing Mock Behavior
22
+
23
+ **The violation:**
24
+ ```typescript
25
+ // ❌ BAD: Testing that the mock exists
26
+ test('renders sidebar', () => {
27
+ render(<Page />);
28
+ expect(screen.getByTestId('sidebar-mock')).toBeInTheDocument();
29
+ });
30
+ ```
31
+
32
+ **Why this is wrong:**
33
+ - You're verifying the mock works, not that the component works
34
+ - Test passes when mock is present, fails when it's not
35
+ - Tells you nothing about real behavior
36
+
37
+ **your human partner's correction:** "Are we testing the behavior of a mock?"
38
+
39
+ **The fix:**
40
+ ```typescript
41
+ // ✅ GOOD: Test real component or don't mock it
42
+ test('renders sidebar', () => {
43
+ render(<Page />); // Don't mock sidebar
44
+ expect(screen.getByRole('navigation')).toBeInTheDocument();
45
+ });
46
+
47
+ // OR if sidebar must be mocked for isolation:
48
+ // Don't assert on the mock - test Page's behavior with sidebar present
49
+ ```
50
+
51
+ ### Gate Function
52
+
53
+ ```
54
+ BEFORE asserting on any mock element:
55
+ Ask: "Am I testing real component behavior or just mock existence?"
56
+
57
+ IF testing mock existence:
58
+ STOP - Delete the assertion or unmock the component
59
+
60
+ Test real behavior instead
61
+ ```
62
+
63
+ ## Anti-Pattern 2: Test-Only Methods in Production
64
+
65
+ **The violation:**
66
+ ```typescript
67
+ // ❌ BAD: destroy() only used in tests
68
+ class Session {
69
+ async destroy() { // Looks like production API!
70
+ await this._workspaceManager?.destroyWorkspace(this.id);
71
+ // ... cleanup
72
+ }
73
+ }
74
+
75
+ // In tests
76
+ afterEach(() => session.destroy());
77
+ ```
78
+
79
+ **Why this is wrong:**
80
+ - Production class polluted with test-only code
81
+ - Dangerous if accidentally called in production
82
+ - Violates YAGNI and separation of concerns
83
+ - Confuses object lifecycle with entity lifecycle
84
+
85
+ **The fix:**
86
+ ```typescript
87
+ // ✅ GOOD: Test utilities handle test cleanup
88
+ // Session has no destroy() - it's stateless in production
89
+
90
+ // In test-utils/
91
+ export async function cleanupSession(session: Session) {
92
+ const workspace = session.getWorkspaceInfo();
93
+ if (workspace) {
94
+ await workspaceManager.destroyWorkspace(workspace.id);
95
+ }
96
+ }
97
+
98
+ // In tests
99
+ afterEach(() => cleanupSession(session));
100
+ ```
101
+
102
+ ### Gate Function
103
+
104
+ ```
105
+ BEFORE adding any method to production class:
106
+ Ask: "Is this only used by tests?"
107
+
108
+ IF yes:
109
+ STOP - Don't add it
110
+ Put it in test utilities instead
111
+
112
+ Ask: "Does this class own this resource's lifecycle?"
113
+
114
+ IF no:
115
+ STOP - Wrong class for this method
116
+ ```
117
+
118
+ ## Anti-Pattern 3: Mocking Without Understanding
119
+
120
+ **The violation:**
121
+ ```typescript
122
+ // ❌ BAD: Mock breaks test logic
123
+ test('detects duplicate server', () => {
124
+ // Mock prevents config write that test depends on!
125
+ vi.mock('ToolCatalog', () => ({
126
+ discoverAndCacheTools: vi.fn().mockResolvedValue(undefined)
127
+ }));
128
+
129
+ await addServer(config);
130
+ await addServer(config); // Should throw - but won't!
131
+ });
132
+ ```
133
+
134
+ **Why this is wrong:**
135
+ - Mocked method had side effect test depended on (writing config)
136
+ - Over-mocking to "be safe" breaks actual behavior
137
+ - Test passes for wrong reason or fails mysteriously
138
+
139
+ **The fix:**
140
+ ```typescript
141
+ // ✅ GOOD: Mock at correct level
142
+ test('detects duplicate server', () => {
143
+ // Mock the slow part, preserve behavior test needs
144
+ vi.mock('MCPServerManager'); // Just mock slow server startup
145
+
146
+ await addServer(config); // Config written
147
+ await addServer(config); // Duplicate detected ✓
148
+ });
149
+ ```
150
+
151
+ ### Gate Function
152
+
153
+ ```
154
+ BEFORE mocking any method:
155
+ STOP - Don't mock yet
156
+
157
+ 1. Ask: "What side effects does the real method have?"
158
+ 2. Ask: "Does this test depend on any of those side effects?"
159
+ 3. Ask: "Do I fully understand what this test needs?"
160
+
161
+ IF depends on side effects:
162
+ Mock at lower level (the actual slow/external operation)
163
+ OR use test doubles that preserve necessary behavior
164
+ NOT the high-level method the test depends on
165
+
166
+ IF unsure what test depends on:
167
+ Run test with real implementation FIRST
168
+ Observe what actually needs to happen
169
+ THEN add minimal mocking at the right level
170
+
171
+ Red flags:
172
+ - "I'll mock this to be safe"
173
+ - "This might be slow, better mock it"
174
+ - Mocking without understanding the dependency chain
175
+ ```
176
+
177
+ ## Anti-Pattern 4: Incomplete Mocks
178
+
179
+ **The violation:**
180
+ ```typescript
181
+ // ❌ BAD: Partial mock - only fields you think you need
182
+ const mockResponse = {
183
+ status: 'success',
184
+ data: { userId: '123', name: 'Alice' }
185
+ // Missing: metadata that downstream code uses
186
+ };
187
+
188
+ // Later: breaks when code accesses response.metadata.requestId
189
+ ```
190
+
191
+ **Why this is wrong:**
192
+ - **Partial mocks hide structural assumptions** - You only mocked fields you know about
193
+ - **Downstream code may depend on fields you didn't include** - Silent failures
194
+ - **Tests pass but integration fails** - Mock incomplete, real API complete
195
+ - **False confidence** - Test proves nothing about real behavior
196
+
197
+ **The Iron Rule:** Mock the COMPLETE data structure as it exists in reality, not just fields your immediate test uses.
198
+
199
+ **The fix:**
200
+ ```typescript
201
+ // ✅ GOOD: Mirror real API completeness
202
+ const mockResponse = {
203
+ status: 'success',
204
+ data: { userId: '123', name: 'Alice' },
205
+ metadata: { requestId: 'req-789', timestamp: 1234567890 }
206
+ // All fields real API returns
207
+ };
208
+ ```
209
+
210
+ ### Gate Function
211
+
212
+ ```
213
+ BEFORE creating mock responses:
214
+ Check: "What fields does the real API response contain?"
215
+
216
+ Actions:
217
+ 1. Examine actual API response from docs/examples
218
+ 2. Include ALL fields system might consume downstream
219
+ 3. Verify mock matches real response schema completely
220
+
221
+ Critical:
222
+ If you're creating a mock, you must understand the ENTIRE structure
223
+ Partial mocks fail silently when code depends on omitted fields
224
+
225
+ If uncertain: Include all documented fields
226
+ ```
227
+
228
+ ## Anti-Pattern 5: Integration Tests as Afterthought
229
+
230
+ **The violation:**
231
+ ```
232
+ ✅ Implementation complete
233
+ ❌ No tests written
234
+ "Ready for testing"
235
+ ```
236
+
237
+ **Why this is wrong:**
238
+ - Testing is part of implementation, not optional follow-up
239
+ - TDD would have caught this
240
+ - Can't claim complete without tests
241
+
242
+ **The fix:**
243
+ ```
244
+ TDD cycle:
245
+ 1. Write failing test
246
+ 2. Implement to pass
247
+ 3. Refactor
248
+ 4. THEN claim complete
249
+ ```
250
+
251
+ ## When Mocks Become Too Complex
252
+
253
+ **Warning signs:**
254
+ - Mock setup longer than test logic
255
+ - Mocking everything to make test pass
256
+ - Mocks missing methods real components have
257
+ - Test breaks when mock changes
258
+
259
+ **your human partner's question:** "Do we need to be using a mock here?"
260
+
261
+ **Consider:** Integration tests with real components often simpler than complex mocks
262
+
263
+ ## TDD Prevents These Anti-Patterns
264
+
265
+ **Why TDD helps:**
266
+ 1. **Write test first** → Forces you to think about what you're actually testing
267
+ 2. **Watch it fail** → Confirms test tests real behavior, not mocks
268
+ 3. **Minimal implementation** → No test-only methods creep in
269
+ 4. **Real dependencies** → You see what the test actually needs before mocking
270
+
271
+ **If you're testing mock behavior, you violated TDD** - you added mocks without watching test fail against real code first.
272
+
273
+ ## Quick Reference
274
+
275
+ | Anti-Pattern | Fix |
276
+ |--------------|-----|
277
+ | Assert on mock elements | Test real component or unmock it |
278
+ | Test-only methods in production | Move to test utilities |
279
+ | Mock without understanding | Understand dependencies first, mock minimally |
280
+ | Incomplete mocks | Mirror real API completely |
281
+ | Tests as afterthought | TDD - tests first |
282
+ | Over-complex mocks | Consider integration tests |
283
+
284
+ ## Red Flags
285
+
286
+ - Assertion checks for `*-mock` test IDs
287
+ - Methods only called in test files
288
+ - Mock setup is >50% of test
289
+ - Test fails when you remove mock
290
+ - Can't explain why mock is needed
291
+ - Mocking "just to be safe"
292
+
293
+ ## The Bottom Line
294
+
295
+ **Mocks are tools to isolate, not things to test.**
296
+
297
+ If TDD reveals you're testing mock behavior, you've gone wrong.
298
+
299
+ Fix: Test real behavior or question why you're mocking at all.