@simplysm/sd-claude 13.0.78 → 13.0.80

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 (64) hide show
  1. package/claude/rules/sd-claude-rules.md +4 -63
  2. package/claude/rules/sd-simplysm-usage.md +7 -0
  3. package/claude/sd-session-start.sh +10 -0
  4. package/claude/skills/sd-api-review/SKILL.md +89 -0
  5. package/claude/skills/sd-check/SKILL.md +55 -57
  6. package/claude/skills/sd-commit/SKILL.md +37 -42
  7. package/claude/skills/sd-debug/SKILL.md +75 -265
  8. package/claude/skills/sd-document/SKILL.md +63 -53
  9. package/claude/skills/sd-document/_common.py +94 -0
  10. package/claude/skills/sd-document/extract_docx.py +19 -48
  11. package/claude/skills/sd-document/extract_pdf.py +22 -50
  12. package/claude/skills/sd-document/extract_pptx.py +17 -40
  13. package/claude/skills/sd-document/extract_xlsx.py +19 -40
  14. package/claude/skills/sd-email-analyze/SKILL.md +23 -31
  15. package/claude/skills/sd-email-analyze/email-analyzer.py +79 -65
  16. package/claude/skills/sd-init/SKILL.md +133 -0
  17. package/claude/skills/sd-plan/SKILL.md +69 -120
  18. package/claude/skills/sd-readme/SKILL.md +106 -131
  19. package/claude/skills/sd-review/SKILL.md +38 -155
  20. package/claude/skills/sd-simplify/SKILL.md +59 -0
  21. package/package.json +3 -2
  22. package/README.md +0 -297
  23. package/claude/refs/sd-angular.md +0 -127
  24. package/claude/refs/sd-code-conventions.md +0 -155
  25. package/claude/refs/sd-directories.md +0 -7
  26. package/claude/refs/sd-library-issue.md +0 -7
  27. package/claude/refs/sd-migration.md +0 -7
  28. package/claude/refs/sd-orm-v12.md +0 -81
  29. package/claude/refs/sd-orm.md +0 -23
  30. package/claude/refs/sd-service.md +0 -5
  31. package/claude/refs/sd-simplysm-docs.md +0 -52
  32. package/claude/refs/sd-solid.md +0 -68
  33. package/claude/refs/sd-workflow.md +0 -25
  34. package/claude/rules/sd-refs-linker.md +0 -52
  35. package/claude/sd-statusline.js +0 -296
  36. package/claude/skills/sd-api-name-review/SKILL.md +0 -154
  37. package/claude/skills/sd-brainstorm/SKILL.md +0 -215
  38. package/claude/skills/sd-debug/condition-based-waiting-example.ts +0 -158
  39. package/claude/skills/sd-debug/condition-based-waiting.md +0 -114
  40. package/claude/skills/sd-debug/defense-in-depth.md +0 -128
  41. package/claude/skills/sd-debug/find-polluter.sh +0 -64
  42. package/claude/skills/sd-debug/root-cause-tracing.md +0 -168
  43. package/claude/skills/sd-discuss/SKILL.md +0 -91
  44. package/claude/skills/sd-explore/SKILL.md +0 -118
  45. package/claude/skills/sd-plan-dev/SKILL.md +0 -294
  46. package/claude/skills/sd-plan-dev/code-quality-reviewer-prompt.md +0 -49
  47. package/claude/skills/sd-plan-dev/final-review-prompt.md +0 -50
  48. package/claude/skills/sd-plan-dev/implementer-prompt.md +0 -60
  49. package/claude/skills/sd-plan-dev/spec-reviewer-prompt.md +0 -45
  50. package/claude/skills/sd-review/api-reviewer-prompt.md +0 -75
  51. package/claude/skills/sd-review/code-reviewer-prompt.md +0 -82
  52. package/claude/skills/sd-review/convention-checker-prompt.md +0 -61
  53. package/claude/skills/sd-review/refactoring-analyzer-prompt.md +0 -92
  54. package/claude/skills/sd-skill/SKILL.md +0 -417
  55. package/claude/skills/sd-skill/anthropic-best-practices.md +0 -156
  56. package/claude/skills/sd-skill/cso-guide.md +0 -161
  57. package/claude/skills/sd-skill/examples/CLAUDE_MD_TESTING.md +0 -200
  58. package/claude/skills/sd-skill/persuasion-principles.md +0 -220
  59. package/claude/skills/sd-skill/testing-skills-with-subagents.md +0 -408
  60. package/claude/skills/sd-skill/writing-guide.md +0 -159
  61. package/claude/skills/sd-tdd/SKILL.md +0 -385
  62. package/claude/skills/sd-tdd/testing-anti-patterns.md +0 -317
  63. package/claude/skills/sd-use/SKILL.md +0 -67
  64. package/claude/skills/sd-worktree/SKILL.md +0 -78
@@ -1,385 +0,0 @@
1
- ---
2
- name: sd-tdd
3
- description: "TDD - failing test first, then implement (explicit invocation only)"
4
- user-invocable: false
5
- ---
6
-
7
- # Test-Driven Development (TDD)
8
-
9
- ## Overview
10
-
11
- Write the test first. Watch it fail. Write minimal code to pass.
12
-
13
- **Core principle:** If you didn't watch the test fail, you don't know if it tests the right thing.
14
-
15
- **Violating the letter of the rules is violating the spirit of the rules.**
16
-
17
- ## When to Use
18
-
19
- **Always:**
20
-
21
- - New features
22
- - Bug fixes
23
- - Refactoring
24
- - Behavior changes
25
-
26
- **Exceptions (ask your human partner):**
27
-
28
- - Throwaway prototypes
29
- - Generated code
30
- - Configuration files
31
-
32
- Thinking "skip TDD just this once"? Stop. That's rationalization.
33
-
34
- ## The Iron Law
35
-
36
- ```
37
- NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
38
- ```
39
-
40
- Write code before the test? Delete it. Start over.
41
-
42
- **No exceptions:**
43
-
44
- - Don't keep it as "reference"
45
- - Don't "adapt" it while writing tests
46
- - Don't look at it
47
- - Delete means delete
48
-
49
- Implement fresh from tests. Period.
50
-
51
- ## Red-Green-Refactor
52
-
53
- ```mermaid
54
- flowchart LR
55
- A["RED<br>Write failing test"]:::red --> B{"Verify fails<br>correctly"}
56
- B -->|yes| C["GREEN<br>Minimal code"]:::green
57
- B -->|"wrong failure"| A
58
- C --> D{"Verify passes<br>All green"}
59
- D -->|yes| E["REFACTOR<br>Clean up"]:::blue
60
- D -->|no| C
61
- E -->|"stay green"| D
62
- D --> F(["Next"])
63
- F --> A
64
-
65
- classDef red fill:#ffcccc
66
- classDef green fill:#ccffcc
67
- classDef blue fill:#ccccff
68
- ```
69
-
70
- ### RED - Write Failing Test
71
-
72
- Write one minimal test showing what should happen.
73
-
74
- <Good>
75
- ```typescript
76
- test('retries failed operations 3 times', async () => {
77
- let attempts = 0;
78
- const operation = () => {
79
- attempts++;
80
- if (attempts < 3) throw new Error('fail');
81
- return 'success';
82
- };
83
-
84
- const result = await retryOperation(operation);
85
-
86
- expect(result).toBe('success');
87
- expect(attempts).toBe(3);
88
- });
89
-
90
- ````
91
- Clear name, tests real behavior, one thing
92
- </Good>
93
-
94
- <Bad>
95
- ```typescript
96
- test('retry works', async () => {
97
- const mock = jest.fn()
98
- .mockRejectedValueOnce(new Error())
99
- .mockRejectedValueOnce(new Error())
100
- .mockResolvedValueOnce('success');
101
- await retryOperation(mock);
102
- expect(mock).toHaveBeenCalledTimes(3);
103
- });
104
- ````
105
-
106
- Vague name, tests mock not code
107
- </Bad>
108
-
109
- **Requirements:**
110
-
111
- - One behavior
112
- - Clear name
113
- - Real code (no mocks unless unavoidable)
114
-
115
- ### Verify RED - Watch It Fail
116
-
117
- **MANDATORY. Never skip.**
118
-
119
- ```bash
120
- npx vitest path/to/test.spec.ts --run
121
- ```
122
-
123
- Confirm:
124
-
125
- - Test fails (not errors)
126
- - Failure message is expected
127
- - Fails because feature missing (not typos)
128
-
129
- **Test passes?** You're testing existing behavior. Fix test.
130
-
131
- **Test errors?** Fix error, re-run until it fails correctly.
132
-
133
- ### GREEN - Minimal Code
134
-
135
- Write simplest code to pass the test.
136
-
137
- <Good>
138
- ```typescript
139
- async function retryOperation<T>(fn: () => Promise<T>): Promise<T> {
140
- for (let i = 0; i < 3; i++) {
141
- try {
142
- return await fn();
143
- } catch (e) {
144
- if (i === 2) throw e;
145
- }
146
- }
147
- throw new Error('unreachable');
148
- }
149
- ```
150
- Just enough to pass
151
- </Good>
152
-
153
- <Bad>
154
- ```typescript
155
- async function retryOperation<T>(
156
- fn: () => Promise<T>,
157
- options?: {
158
- maxRetries?: number;
159
- backoff?: 'linear' | 'exponential';
160
- onRetry?: (attempt: number) => void;
161
- }
162
- ): Promise<T> {
163
- // YAGNI
164
- }
165
- ```
166
- Over-engineered
167
- </Bad>
168
-
169
- Don't add features, refactor other code, or "improve" beyond the test.
170
-
171
- ### Verify GREEN - Watch It Pass
172
-
173
- **MANDATORY.**
174
-
175
- ```bash
176
- npx vitest path/to/test.spec.ts --run
177
- ```
178
-
179
- Confirm:
180
-
181
- - Test passes
182
- - Other tests still pass
183
- - Output pristine (no errors, warnings)
184
-
185
- **Test fails?** Fix code, not test.
186
-
187
- **Other tests fail?** Fix now.
188
-
189
- ### REFACTOR - Clean Up
190
-
191
- After green only:
192
-
193
- - Remove duplication
194
- - Improve names
195
- - Extract helpers
196
-
197
- Keep tests green. Don't add behavior.
198
-
199
- ### Repeat
200
-
201
- Next failing test for next feature.
202
-
203
- ## Good Tests
204
-
205
- | Quality | Good | Bad |
206
- | ---------------- | ----------------------------------- | --------------------------------------------------- |
207
- | **Minimal** | One thing. "and" in name? Split it. | `test('validates email and domain and whitespace')` |
208
- | **Clear** | Name describes behavior | `test('test1')` |
209
- | **Shows intent** | Demonstrates desired API | Obscures what code should do |
210
-
211
- ## Why Order Matters
212
-
213
- **"I'll write tests after to verify it works"**
214
-
215
- Tests written after code pass immediately. Passing immediately proves nothing:
216
-
217
- - Might test wrong thing
218
- - Might test implementation, not behavior
219
- - Might miss edge cases you forgot
220
- - You never saw it catch the bug
221
-
222
- Test-first forces you to see the test fail, proving it actually tests something.
223
-
224
- **"I already manually tested all the edge cases"**
225
-
226
- Manual testing is ad-hoc. You think you tested everything but:
227
-
228
- - No record of what you tested
229
- - Can't re-run when code changes
230
- - Easy to forget cases under pressure
231
- - "It worked when I tried it" ≠ comprehensive
232
-
233
- Automated tests are systematic. They run the same way every time.
234
-
235
- **"Deleting X hours of work is wasteful"**
236
-
237
- Sunk cost fallacy. The time is already gone. Your choice now:
238
-
239
- - Delete and rewrite with TDD (X more hours, high confidence)
240
- - Keep it and add tests after (30 min, low confidence, likely bugs)
241
-
242
- The "waste" is keeping code you can't trust. Working code without real tests is technical debt.
243
-
244
- **"TDD is dogmatic, being pragmatic means adapting"**
245
-
246
- TDD IS pragmatic:
247
-
248
- - Finds bugs before commit (faster than debugging after)
249
- - Prevents regressions (tests catch breaks immediately)
250
- - Documents behavior (tests show how to use code)
251
- - Enables refactoring (change freely, tests catch breaks)
252
-
253
- "Pragmatic" shortcuts = debugging in production = slower.
254
-
255
- **"Tests after achieve the same goals - it's spirit not ritual"**
256
-
257
- No. Tests-after answer "What does this do?" Tests-first answer "What should this do?"
258
-
259
- Tests-after are biased by your implementation. You test what you built, not what's required. You verify remembered edge cases, not discovered ones.
260
-
261
- Tests-first force edge case discovery before implementing. Tests-after verify you remembered everything (you didn't).
262
-
263
- 30 minutes of tests after ≠ TDD. You get coverage, lose proof tests work.
264
-
265
- ## Common Rationalizations
266
-
267
- | Excuse | Reality |
268
- | -------------------------------------- | ----------------------------------------------------------------------- |
269
- | "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
270
- | "I'll test after" | Tests passing immediately prove nothing. |
271
- | "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
272
- | "Already manually tested" | Ad-hoc ≠ systematic. No record, can't re-run. |
273
- | "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is technical debt. |
274
- | "Keep as reference, write tests first" | You'll adapt it. That's testing after. Delete means delete. |
275
- | "Need to explore first" | Fine. Throw away exploration, start with TDD. |
276
- | "Test hard = design unclear" | Listen to test. Hard to test = hard to use. |
277
- | "TDD will slow me down" | TDD faster than debugging. Pragmatic = test-first. |
278
- | "Manual test faster" | Manual doesn't prove edge cases. You'll re-test every change. |
279
- | "Existing code has no tests" | You're improving it. Add tests for existing code. |
280
-
281
- ## Red Flags - STOP and Start Over
282
-
283
- - Code before test
284
- - Test after implementation
285
- - Test passes immediately
286
- - Can't explain why test failed
287
- - Tests added "later"
288
- - Rationalizing "just this once"
289
- - "I already manually tested it"
290
- - "Tests after achieve the same purpose"
291
- - "It's about spirit not ritual"
292
- - "Keep as reference" or "adapt existing code"
293
- - "Already spent X hours, deleting is wasteful"
294
- - "TDD is dogmatic, I'm being pragmatic"
295
- - "This is different because..."
296
-
297
- **All of these mean: Delete code. Start over with TDD.**
298
-
299
- ## Example: Bug Fix
300
-
301
- **Bug:** Empty email accepted
302
-
303
- **RED**
304
-
305
- ```typescript
306
- test("rejects empty email", async () => {
307
- const result = await submitForm({ email: "" });
308
- expect(result.error).toBe("Email required");
309
- });
310
- ```
311
-
312
- **Verify RED**
313
-
314
- ```bash
315
- $ npx vitest path/to/test.spec.ts --run
316
- FAIL: expected 'Email required', got undefined
317
- ```
318
-
319
- **GREEN**
320
-
321
- ```typescript
322
- function submitForm(data: FormData) {
323
- if (!data.email?.trim()) {
324
- return { error: "Email required" };
325
- }
326
- // ...
327
- }
328
- ```
329
-
330
- **Verify GREEN**
331
-
332
- ```bash
333
- $ npx vitest path/to/test.spec.ts --run
334
- PASS
335
- ```
336
-
337
- **REFACTOR**
338
- Extract validation for multiple fields if needed.
339
-
340
- ## Verification Checklist
341
-
342
- Before marking work complete:
343
-
344
- - [ ] Every new function/method has a test
345
- - [ ] Watched each test fail before implementing
346
- - [ ] Each test failed for expected reason (feature missing, not typo)
347
- - [ ] Wrote minimal code to pass each test
348
- - [ ] All tests pass
349
- - [ ] Output pristine (no errors, warnings)
350
- - [ ] Tests use real code (mocks only if unavoidable)
351
- - [ ] Edge cases and errors covered
352
-
353
- Can't check all boxes? You skipped TDD. Start over.
354
-
355
- ## When Stuck
356
-
357
- | Problem | Solution |
358
- | ---------------------- | -------------------------------------------------------------------- |
359
- | Don't know how to test | Write wished-for API. Write assertion first. Ask your human partner. |
360
- | Test too complicated | Design too complicated. Simplify interface. |
361
- | Must mock everything | Code too coupled. Use dependency injection. |
362
- | Test setup huge | Extract helpers. Still complex? Simplify design. |
363
-
364
- ## Debugging Integration
365
-
366
- Bug found? Write failing test reproducing it. Follow TDD cycle. Test proves fix and prevents regression.
367
-
368
- Never fix bugs without a test.
369
-
370
- ## Testing Anti-Patterns
371
-
372
- When adding mocks or test utilities, read testing-anti-patterns.md to avoid common pitfalls:
373
-
374
- - Testing mock behavior instead of real behavior
375
- - Adding test-only methods to production classes
376
- - Mocking without understanding dependencies
377
-
378
- ## Final Rule
379
-
380
- ```
381
- Production code → test exists and failed first
382
- Otherwise → not TDD
383
- ```
384
-
385
- No exceptions without your human partner's permission.
@@ -1,317 +0,0 @@
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
-
25
- ```typescript
26
- // ❌ BAD: Testing that the mock exists
27
- test('renders sidebar', () => {
28
- render(<Page />);
29
- expect(screen.getByTestId('sidebar-mock')).toBeInTheDocument();
30
- });
31
- ```
32
-
33
- **Why this is wrong:**
34
-
35
- - You're verifying the mock works, not that the component works
36
- - Test passes when mock is present, fails when it's not
37
- - Tells you nothing about real behavior
38
-
39
- **your human partner's correction:** "Are we testing the behavior of a mock?"
40
-
41
- **The fix:**
42
-
43
- ```typescript
44
- // ✅ GOOD: Test real component or don't mock it
45
- test('renders sidebar', () => {
46
- render(<Page />); // Don't mock sidebar
47
- expect(screen.getByRole('navigation')).toBeInTheDocument();
48
- });
49
-
50
- // OR if sidebar must be mocked for isolation:
51
- // Don't assert on the mock - test Page's behavior with sidebar present
52
- ```
53
-
54
- ### Gate Function
55
-
56
- ```
57
- BEFORE asserting on any mock element:
58
- Ask: "Am I testing real component behavior or just mock existence?"
59
-
60
- IF testing mock existence:
61
- STOP - Delete the assertion or unmock the component
62
-
63
- Test real behavior instead
64
- ```
65
-
66
- ## Anti-Pattern 2: Test-Only Methods in Production
67
-
68
- **The violation:**
69
-
70
- ```typescript
71
- // ❌ BAD: destroy() only used in tests
72
- class Session {
73
- async destroy() {
74
- // 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
-
86
- - Production class polluted with test-only code
87
- - Dangerous if accidentally called in production
88
- - Violates YAGNI and separation of concerns
89
- - Confuses object lifecycle with entity lifecycle
90
-
91
- **The fix:**
92
-
93
- ```typescript
94
- // ✅ GOOD: Test utilities handle test cleanup
95
- // Session has no destroy() - it's stateless in production
96
-
97
- // In test-utils/
98
- export async function cleanupSession(session: Session) {
99
- const workspace = session.getWorkspaceInfo();
100
- if (workspace) {
101
- await workspaceManager.destroyWorkspace(workspace.id);
102
- }
103
- }
104
-
105
- // In tests
106
- afterEach(() => cleanupSession(session));
107
- ```
108
-
109
- ### Gate Function
110
-
111
- ```
112
- BEFORE adding any method to production class:
113
- Ask: "Is this only used by tests?"
114
-
115
- IF yes:
116
- STOP - Don't add it
117
- Put it in test utilities instead
118
-
119
- Ask: "Does this class own this resource's lifecycle?"
120
-
121
- IF no:
122
- STOP - Wrong class for this method
123
- ```
124
-
125
- ## Anti-Pattern 3: Mocking Without Understanding
126
-
127
- **The violation:**
128
-
129
- ```typescript
130
- // ❌ BAD: Mock breaks test logic
131
- test("detects duplicate server", () => {
132
- // Mock prevents config write that test depends on!
133
- vi.mock("ToolCatalog", () => ({
134
- discoverAndCacheTools: vi.fn().mockResolvedValue(undefined),
135
- }));
136
-
137
- await addServer(config);
138
- await addServer(config); // Should throw - but won't!
139
- });
140
- ```
141
-
142
- **Why this is wrong:**
143
-
144
- - Mocked method had side effect test depended on (writing config)
145
- - Over-mocking to "be safe" breaks actual behavior
146
- - Test passes for wrong reason or fails mysteriously
147
-
148
- **The fix:**
149
-
150
- ```typescript
151
- // ✅ GOOD: Mock at correct level
152
- test("detects duplicate server", () => {
153
- // Mock the slow part, preserve behavior test needs
154
- vi.mock("MCPServerManager"); // Just mock slow server startup
155
-
156
- await addServer(config); // Config written
157
- await addServer(config); // Duplicate detected ✓
158
- });
159
- ```
160
-
161
- ### Gate Function
162
-
163
- ```
164
- BEFORE mocking any method:
165
- STOP - Don't mock yet
166
-
167
- 1. Ask: "What side effects does the real method have?"
168
- 2. Ask: "Does this test depend on any of those side effects?"
169
- 3. Ask: "Do I fully understand what this test needs?"
170
-
171
- IF depends on side effects:
172
- Mock at lower level (the actual slow/external operation)
173
- OR use test doubles that preserve necessary behavior
174
- NOT the high-level method the test depends on
175
-
176
- IF unsure what test depends on:
177
- Run test with real implementation FIRST
178
- Observe what actually needs to happen
179
- THEN add minimal mocking at the right level
180
-
181
- Red flags:
182
- - "I'll mock this to be safe"
183
- - "This might be slow, better mock it"
184
- - Mocking without understanding the dependency chain
185
- ```
186
-
187
- ## Anti-Pattern 4: Incomplete Mocks
188
-
189
- **The violation:**
190
-
191
- ```typescript
192
- // ❌ BAD: Partial mock - only fields you think you need
193
- const mockResponse = {
194
- status: "success",
195
- data: { userId: "123", name: "Alice" },
196
- // Missing: metadata that downstream code uses
197
- };
198
-
199
- // Later: breaks when code accesses response.metadata.requestId
200
- ```
201
-
202
- **Why this is wrong:**
203
-
204
- - **Partial mocks hide structural assumptions** - You only mocked fields you know about
205
- - **Downstream code may depend on fields you didn't include** - Silent failures
206
- - **Tests pass but integration fails** - Mock incomplete, real API complete
207
- - **False confidence** - Test proves nothing about real behavior
208
-
209
- **The Iron Rule:** Mock the COMPLETE data structure as it exists in reality, not just fields your immediate test uses.
210
-
211
- **The fix:**
212
-
213
- ```typescript
214
- // ✅ GOOD: Mirror real API completeness
215
- const mockResponse = {
216
- status: "success",
217
- data: { userId: "123", name: "Alice" },
218
- metadata: { requestId: "req-789", timestamp: 1234567890 },
219
- // All fields real API returns
220
- };
221
- ```
222
-
223
- ### Gate Function
224
-
225
- ```
226
- BEFORE creating mock responses:
227
- Check: "What fields does the real API response contain?"
228
-
229
- Actions:
230
- 1. Examine actual API response from docs/examples
231
- 2. Include ALL fields system might consume downstream
232
- 3. Verify mock matches real response schema completely
233
-
234
- Critical:
235
- If you're creating a mock, you must understand the ENTIRE structure
236
- Partial mocks fail silently when code depends on omitted fields
237
-
238
- If uncertain: Include all documented fields
239
- ```
240
-
241
- ## Anti-Pattern 5: Integration Tests as Afterthought
242
-
243
- **The violation:**
244
-
245
- ```
246
- ✅ Implementation complete
247
- ❌ No tests written
248
- "Ready for testing"
249
- ```
250
-
251
- **Why this is wrong:**
252
-
253
- - Testing is part of implementation, not optional follow-up
254
- - TDD would have caught this
255
- - Can't claim complete without tests
256
-
257
- **The fix:**
258
-
259
- ```
260
- TDD cycle:
261
- 1. Write failing test
262
- 2. Implement to pass
263
- 3. Refactor
264
- 4. THEN claim complete
265
- ```
266
-
267
- ## When Mocks Become Too Complex
268
-
269
- **Warning signs:**
270
-
271
- - Mock setup longer than test logic
272
- - Mocking everything to make test pass
273
- - Mocks missing methods real components have
274
- - Test breaks when mock changes
275
-
276
- **your human partner's question:** "Do we need to be using a mock here?"
277
-
278
- **Consider:** Integration tests with real components often simpler than complex mocks
279
-
280
- ## TDD Prevents These Anti-Patterns
281
-
282
- **Why TDD helps:**
283
-
284
- 1. **Write test first** → Forces you to think about what you're actually testing
285
- 2. **Watch it fail** → Confirms test tests real behavior, not mocks
286
- 3. **Minimal implementation** → No test-only methods creep in
287
- 4. **Real dependencies** → You see what the test actually needs before mocking
288
-
289
- **If you're testing mock behavior, you violated TDD** - you added mocks without watching test fail against real code first.
290
-
291
- ## Quick Reference
292
-
293
- | Anti-Pattern | Fix |
294
- | ------------------------------- | --------------------------------------------- |
295
- | Assert on mock elements | Test real component or unmock it |
296
- | Test-only methods in production | Move to test utilities |
297
- | Mock without understanding | Understand dependencies first, mock minimally |
298
- | Incomplete mocks | Mirror real API completely |
299
- | Tests as afterthought | TDD - tests first |
300
- | Over-complex mocks | Consider integration tests |
301
-
302
- ## Red Flags
303
-
304
- - Assertion checks for `*-mock` test IDs
305
- - Methods only called in test files
306
- - Mock setup is >50% of test
307
- - Test fails when you remove mock
308
- - Can't explain why mock is needed
309
- - Mocking "just to be safe"
310
-
311
- ## The Bottom Line
312
-
313
- **Mocks are tools to isolate, not things to test.**
314
-
315
- If TDD reveals you're testing mock behavior, you've gone wrong.
316
-
317
- Fix: Test real behavior or question why you're mocking at all.