plan-flow-skill 1.0.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 (124) hide show
  1. package/.claude/commands/create-contract.md +468 -0
  2. package/.claude/commands/create-plan.md +512 -0
  3. package/.claude/commands/discovery-plan.md +561 -0
  4. package/.claude/commands/execute-plan.md +682 -0
  5. package/.claude/commands/review-code.md +459 -0
  6. package/.claude/commands/review-pr.md +651 -0
  7. package/.claude/commands/setup.md +1609 -0
  8. package/.claude/commands/write-tests.md +543 -0
  9. package/.claude/rules/core/allowed-patterns.md +175 -0
  10. package/.claude/rules/core/complexity-scoring.md +225 -0
  11. package/.claude/rules/core/forbidden-patterns.md +253 -0
  12. package/.claude/rules/languages/python-patterns.md +6 -0
  13. package/.claude/rules/languages/typescript-patterns.md +7 -0
  14. package/.claude/rules/patterns/contract-patterns.md +332 -0
  15. package/.claude/rules/patterns/discovery-patterns.md +342 -0
  16. package/.claude/rules/patterns/discovery-templates.md +319 -0
  17. package/.claude/rules/patterns/jest-patterns.md +482 -0
  18. package/.claude/rules/patterns/plans-patterns.md +225 -0
  19. package/.claude/rules/patterns/plans-templates.md +227 -0
  20. package/.claude/rules/patterns/pytest-patterns.md +457 -0
  21. package/.claude/rules/patterns/review-code-templates.md +305 -0
  22. package/.claude/rules/patterns/review-pr-patterns.md +360 -0
  23. package/.claude/rules/tools/auth-pr-tool.md +30 -0
  24. package/.claude/rules/tools/interactive-questions-tool.md +235 -0
  25. package/.claude/rules/tools/jest-testing-tool.md +73 -0
  26. package/.claude/rules/tools/plan-mode-tool.md +164 -0
  27. package/.claude/rules/tools/pytest-testing-tool.md +121 -0
  28. package/.claude/rules/tools/reference-expansion-tool.md +326 -0
  29. package/LICENSE +21 -0
  30. package/README.md +167 -0
  31. package/dist/cli/commands/init.d.ts +6 -0
  32. package/dist/cli/commands/init.d.ts.map +1 -0
  33. package/dist/cli/commands/init.js +139 -0
  34. package/dist/cli/commands/init.js.map +1 -0
  35. package/dist/cli/handlers/claude.d.ts +9 -0
  36. package/dist/cli/handlers/claude.d.ts.map +1 -0
  37. package/dist/cli/handlers/claude.js +119 -0
  38. package/dist/cli/handlers/claude.js.map +1 -0
  39. package/dist/cli/handlers/codex.d.ts +9 -0
  40. package/dist/cli/handlers/codex.d.ts.map +1 -0
  41. package/dist/cli/handlers/codex.js +100 -0
  42. package/dist/cli/handlers/codex.js.map +1 -0
  43. package/dist/cli/handlers/cursor.d.ts +8 -0
  44. package/dist/cli/handlers/cursor.d.ts.map +1 -0
  45. package/dist/cli/handlers/cursor.js +34 -0
  46. package/dist/cli/handlers/cursor.js.map +1 -0
  47. package/dist/cli/handlers/openclaw.d.ts +8 -0
  48. package/dist/cli/handlers/openclaw.d.ts.map +1 -0
  49. package/dist/cli/handlers/openclaw.js +34 -0
  50. package/dist/cli/handlers/openclaw.js.map +1 -0
  51. package/dist/cli/handlers/shared.d.ts +9 -0
  52. package/dist/cli/handlers/shared.d.ts.map +1 -0
  53. package/dist/cli/handlers/shared.js +44 -0
  54. package/dist/cli/handlers/shared.js.map +1 -0
  55. package/dist/cli/index.d.ts +8 -0
  56. package/dist/cli/index.d.ts.map +1 -0
  57. package/dist/cli/index.js +43 -0
  58. package/dist/cli/index.js.map +1 -0
  59. package/dist/cli/types.d.ts +26 -0
  60. package/dist/cli/types.d.ts.map +1 -0
  61. package/dist/cli/types.js +5 -0
  62. package/dist/cli/types.js.map +1 -0
  63. package/dist/cli/utils/files.d.ts +37 -0
  64. package/dist/cli/utils/files.d.ts.map +1 -0
  65. package/dist/cli/utils/files.js +122 -0
  66. package/dist/cli/utils/files.js.map +1 -0
  67. package/dist/cli/utils/logger.d.ts +11 -0
  68. package/dist/cli/utils/logger.d.ts.map +1 -0
  69. package/dist/cli/utils/logger.js +34 -0
  70. package/dist/cli/utils/logger.js.map +1 -0
  71. package/dist/cli/utils/prompts.d.ts +10 -0
  72. package/dist/cli/utils/prompts.d.ts.map +1 -0
  73. package/dist/cli/utils/prompts.js +65 -0
  74. package/dist/cli/utils/prompts.js.map +1 -0
  75. package/dist/test/setup.d.ts +5 -0
  76. package/dist/test/setup.d.ts.map +1 -0
  77. package/dist/test/setup.js +7 -0
  78. package/dist/test/setup.js.map +1 -0
  79. package/package.json +63 -0
  80. package/rules/core/_index.mdc +89 -0
  81. package/rules/core/allowed-patterns.mdc +185 -0
  82. package/rules/core/complexity-scoring.mdc +235 -0
  83. package/rules/core/forbidden-patterns.mdc +263 -0
  84. package/rules/languages/_index.mdc +80 -0
  85. package/rules/languages/python-patterns.mdc +188 -0
  86. package/rules/languages/typescript-patterns.mdc +128 -0
  87. package/rules/patterns/_index.mdc +185 -0
  88. package/rules/patterns/contract-patterns.mdc +344 -0
  89. package/rules/patterns/discovery-patterns.mdc +354 -0
  90. package/rules/patterns/discovery-templates.mdc +329 -0
  91. package/rules/patterns/jest-patterns.mdc +492 -0
  92. package/rules/patterns/plans-patterns.mdc +237 -0
  93. package/rules/patterns/plans-templates.mdc +237 -0
  94. package/rules/patterns/pytest-patterns.mdc +467 -0
  95. package/rules/patterns/review-code-templates.mdc +315 -0
  96. package/rules/patterns/review-pr-patterns.mdc +370 -0
  97. package/rules/skills/_index.mdc +174 -0
  98. package/rules/skills/create-contract-skill.mdc +239 -0
  99. package/rules/skills/create-plan-skill.mdc +271 -0
  100. package/rules/skills/discovery-skill.mdc +295 -0
  101. package/rules/skills/execute-plan-skill.mdc +388 -0
  102. package/rules/skills/review-code-skill.mdc +308 -0
  103. package/rules/skills/review-pr-skill.mdc +496 -0
  104. package/rules/skills/setup-skill.mdc +923 -0
  105. package/rules/skills/write-tests-skill.mdc +294 -0
  106. package/rules/templates/index-template.mdc +126 -0
  107. package/rules/tools/_index.mdc +114 -0
  108. package/rules/tools/auth-pr-tool.mdc +362 -0
  109. package/rules/tools/interactive-questions-tool.mdc +337 -0
  110. package/rules/tools/jest-testing-tool.mdc +96 -0
  111. package/rules/tools/plan-mode-tool.mdc +229 -0
  112. package/rules/tools/pytest-testing-tool.mdc +144 -0
  113. package/rules/tools/reference-expansion-tool.mdc +338 -0
  114. package/skills/plan-flow/SKILL.md +109 -0
  115. package/skills/plan-flow/create-contract/SKILL.md +139 -0
  116. package/skills/plan-flow/create-plan/SKILL.md +93 -0
  117. package/skills/plan-flow/discovery/SKILL.md +85 -0
  118. package/skills/plan-flow/execute-plan/SKILL.md +89 -0
  119. package/skills/plan-flow/review-code/SKILL.md +100 -0
  120. package/skills/plan-flow/review-pr/SKILL.md +122 -0
  121. package/skills/plan-flow/setup/SKILL.md +73 -0
  122. package/skills/plan-flow/write-tests/SKILL.md +115 -0
  123. package/templates/shared/AGENTS.md.template +60 -0
  124. package/templates/shared/CLAUDE.md.template +62 -0
@@ -0,0 +1,543 @@
1
+ ---
2
+ description: This command takes a minimum coverage percentage as input and orchestrates the test writing process
3
+ ---
4
+
5
+ # Write Tests - Coverage Improvement Command
6
+
7
+ ## Command Description
8
+
9
+ This command takes a minimum coverage percentage as input and orchestrates the test writing process by invoking the `write-tests` skill to achieve the target coverage across all files.
10
+
11
+ **Output**: Creates/updates test files to achieve the specified coverage percentage.
12
+
13
+ ---
14
+
15
+
16
+ ## Help
17
+
18
+ **If the user invokes this command with `-help`, display only this section and stop:**
19
+
20
+ ```
21
+ /write-tests - Write Tests for Coverage Target
22
+
23
+ DESCRIPTION:
24
+ Analyzes current test coverage and iteratively writes or improves tests
25
+ until the target coverage percentage is achieved across all files.
26
+
27
+ USAGE:
28
+ /write-tests <coverage_percentage>
29
+ /write-tests -help
30
+
31
+ ARGUMENTS:
32
+ coverage_percentage Target minimum coverage (e.g., 80, 90, 100)
33
+
34
+ EXAMPLES:
35
+ /write-tests 80 # Achieve 80% coverage
36
+ /write-tests 95 # Achieve 95% coverage
37
+ /write-tests 100 # Achieve 100% coverage
38
+
39
+ OUTPUT:
40
+ - Creates/updates test files
41
+ - Achieves target coverage across all metrics
42
+
43
+ WORKFLOW:
44
+ 1. Runs initial coverage analysis
45
+ 2. Creates work queue (lowest coverage first)
46
+ 3. For each file below target:
47
+ - Analyzes source code
48
+ - Identifies untested paths
49
+ - Writes/improves tests
50
+ - Verifies coverage improved
51
+ 4. Final verification of all metrics
52
+
53
+ COVERAGE METRICS (all must meet target):
54
+ - Lines Most important metric
55
+ - Branches All conditional paths
56
+ - Functions All exported functions
57
+ - Statements Usually follows lines
58
+
59
+ SUPPORTED FRAMEWORKS:
60
+ - Jest (JavaScript/TypeScript)
61
+ - Pytest (Python)
62
+
63
+ RECOMMENDED MODEL:
64
+ Claude Opus 4.5 or Sonnet 4.5 for best results
65
+
66
+ RELATED COMMANDS:
67
+ /execute-plan Tests are the last phase of plan execution
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Critical Rules
73
+
74
+ | Rule | Description |
75
+ | ------------------------ | -------------------------------------------------------- |
76
+ | **Complete and Stop** | After presenting results, STOP and wait for user |
77
+
78
+ ---
79
+
80
+ ## Instructions
81
+
82
+ ### Step 1: Validate Inputs
83
+
84
+ | Input | Required | Description |
85
+ | --------------------- | -------- | ----------------------------------------------- |
86
+ | `coverage_percentage` | Yes | Target minimum coverage (e.g., 80, 90, 100) |
87
+
88
+ **Validation**:
89
+ - Must be a number between 1 and 100
90
+ - If invalid, ask for valid coverage percentage
91
+
92
+ ---
93
+
94
+ ### Step 2: Detect Testing Framework
95
+
96
+ Identify the testing framework:
97
+
98
+ | Framework | Detection |
99
+ | --------- | --------------------------------------------- |
100
+ | Jest | `jest.config.js`, `package.json` with jest |
101
+ | Pytest | `pytest.ini`, `pyproject.toml`, `conftest.py` |
102
+
103
+ If unable to detect, ask user which framework to use.
104
+
105
+ ---
106
+
107
+ ### Step 3: Invoke Write Tests Skill
108
+
109
+ The skill will:
110
+
111
+ 1. Run initial coverage analysis
112
+ 2. Create work queue (lowest coverage first)
113
+ 3. For each file below target:
114
+ - Analyze source code
115
+ - Identify untested paths
116
+ - Write/improve tests
117
+ - Verify coverage improved
118
+ 4. Run final verification
119
+
120
+ See: `.claude/rules/skills/write-tests-skill.md`
121
+
122
+ ---
123
+
124
+ ### Step 4: Present Results
125
+
126
+ After the skill completes, present summary:
127
+
128
+ ```markdown
129
+ Coverage Target Achieved!
130
+
131
+ **Target**: [X]%
132
+ **Final Coverage**: [Y]%
133
+
134
+ **Summary**:
135
+ - X files updated
136
+ - Y new test files created
137
+ - Z tests added
138
+
139
+ All metrics (Lines, Branches, Functions, Statements) meet the target.
140
+ ```
141
+
142
+ **CRITICAL**: This command is now complete. STOP and wait for the user.
143
+
144
+ ---
145
+
146
+ ## Flow Diagram
147
+
148
+ ```
149
+ +------------------------------------------+
150
+ | /write-tests COMMAND |
151
+ +------------------------------------------+
152
+ |
153
+ v
154
+ +------------------------------------------+
155
+ | Step 1: Validate Inputs |
156
+ | - Check coverage percentage is valid |
157
+ +------------------------------------------+
158
+ |
159
+ v
160
+ +------------------------------------------+
161
+ | Step 2: Detect Testing Framework |
162
+ | - Jest or Pytest |
163
+ +------------------------------------------+
164
+ |
165
+ v
166
+ +------------------------------------------+
167
+ | Step 3: Invoke Write Tests Skill |
168
+ | - Skill handles all test writing logic |
169
+ | - See write-tests-skill.md |
170
+ +------------------------------------------+
171
+ |
172
+ v
173
+ +------------------------------------------+
174
+ | Step 4: Present Results |
175
+ | - Show coverage summary |
176
+ | - Confirm all metrics met |
177
+ +------------------------------------------+
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Coverage Priorities
183
+
184
+ 1. **Lines**: Most important
185
+ 2. **Branches**: Cover all conditional paths
186
+ 3. **Functions**: Ensure all exported functions are tested
187
+ 4. **Statements**: Usually follows lines coverage
188
+
189
+ ---
190
+
191
+ ## Example Usage
192
+
193
+ **User**: `/write-tests 80`
194
+
195
+ **Execution**:
196
+
197
+ 1. Validate input: 80% is valid
198
+ 2. Detect framework: Jest (found jest.config.js)
199
+ 3. Invoke write-tests skill
200
+ 4. Present final coverage summary
201
+
202
+ ---
203
+
204
+ ## Context Optimization
205
+
206
+ This command uses hierarchical context loading to reduce context consumption. Instead of loading full files, load indexes first and expand specific sections on-demand.
207
+
208
+ ### Recommended Loading Order
209
+
210
+ 1. **Always load first**: This command file (`commands/write-tests.md`)
211
+ 2. **Load indexes**: Load `_index.md` files for relevant folders
212
+ 3. **Expand on-demand**: Use reference codes to load specific sections when needed
213
+
214
+ ### Index Files for Writing Tests
215
+
216
+ | Index | When to Load |
217
+ |-------|--------------|
218
+ | `rules/skills/_index.md` | To understand test writing workflow |
219
+ | `rules/patterns/_index.md` | For testing patterns |
220
+ | `rules/tools/_index.md` | For testing tool commands |
221
+
222
+ ### Reference Codes for Writing Tests
223
+
224
+ | Code | Description | When to Expand |
225
+ |------|-------------|----------------|
226
+ | SKL-TEST-1 | Write tests skill workflow | Understanding full process |
227
+ | PTN-JEST-1 | Jest test structure | Writing Jest tests |
228
+ | PTN-JEST-2 | Jest mocking patterns | When mocking is needed |
229
+ | PTN-PYTEST-1 | Pytest test structure | Writing Pytest tests |
230
+ | PTN-PYTEST-2 | Pytest fixtures | When fixtures are needed |
231
+ | TLS-JEST-1 | Jest commands | Running Jest tests |
232
+ | TLS-PYTEST-1 | Pytest commands | Running Pytest tests |
233
+
234
+ ### Expansion Instructions
235
+
236
+ When executing this command:
237
+
238
+ 1. **Start with indexes**: Read `rules/skills/_index.md` and `rules/patterns/_index.md`
239
+ 2. **Detect framework first**: Determine Jest or Pytest before expanding patterns
240
+ 3. **Expand framework-specific**: Only load PTN-JEST-* or PTN-PYTEST-*, not both
241
+ 4. **Expand tool commands**: Load TLS-JEST-* or TLS-PYTEST-* for running tests
242
+ 5. **Don't expand everything**: Only load patterns relevant to detected framework
243
+
244
+ ---
245
+
246
+ ## Related Resources
247
+
248
+ | Resource | Purpose |
249
+ | ------------------------- | ------------------------------- |
250
+ | `rules/skills/_index.md` | Index of skills with reference codes |
251
+ | `rules/patterns/_index.md` | Index of patterns with reference codes |
252
+ | `rules/tools/_index.md` | Index of tools with reference codes |
253
+ | `write-tests-skill.md` | Skill that writes the tests |
254
+ | `jest-patterns.md` | Jest testing patterns |
255
+ | `pytest-patterns.md` | Pytest testing patterns |
256
+ | `jest-testing-tool.md` | Jest commands and utilities |
257
+ | `pytest-testing-tool.md` | Pytest commands and utilities |
258
+ | `/execute-plan` command | Tests are last phase of plans |
259
+
260
+ ---
261
+
262
+ # Implementation Details
263
+
264
+
265
+ ## Inputs
266
+
267
+ | Input | Required | Description |
268
+ | ------------------- | -------- | ------------------------------------------------ |
269
+ | `target_coverage` | Yes | Minimum coverage percentage (e.g., 80, 90, 100) |
270
+ | `framework` | Optional | Testing framework (Jest or Pytest, auto-detected)|
271
+ | `specific_files` | Optional | Specific files to focus on |
272
+
273
+ ---
274
+
275
+ ## Workflow
276
+
277
+ ### Step 1: Detect Testing Framework
278
+
279
+ Identify the testing framework based on project files:
280
+
281
+ | Framework | Detection |
282
+ | --------- | --------------------------------------------- |
283
+ | Jest | `jest.config.js`, `package.json` with jest |
284
+ | Pytest | `pytest.ini`, `pyproject.toml`, `conftest.py` |
285
+
286
+ Load the appropriate patterns:
287
+ - Jest: `.claude/rules/patterns/jest-patterns.md`
288
+ - Pytest: `.claude/rules/patterns/pytest-patterns.md`
289
+
290
+ ---
291
+
292
+ ### Step 2: Run Initial Coverage Analysis
293
+
294
+ Run the coverage command:
295
+
296
+ **Jest**:
297
+ ```bash
298
+ npm run test -- --coverage
299
+ ```
300
+
301
+ **Pytest**:
302
+ ```bash
303
+ pytest --cov=src --cov-report=term-missing
304
+ ```
305
+
306
+ Parse the results to identify:
307
+ - Current coverage per file
308
+ - Files below target
309
+ - Uncovered lines/branches
310
+
311
+ ---
312
+
313
+ ### Step 3: Create Work Queue
314
+
315
+ Sort files by coverage (lowest first):
316
+
317
+ ```markdown
318
+ ## Coverage Work Queue
319
+
320
+ | File | Current | Target | Gap | Priority |
321
+ | --------------------------- | ------- | ------ | ---- | -------- |
322
+ | src/services/userService.ts | 45% | 80% | 35% | 1 |
323
+ | src/utils/validation.ts | 60% | 80% | 20% | 2 |
324
+ | src/components/Button.tsx | 75% | 80% | 5% | 3 |
325
+ ```
326
+
327
+ ---
328
+
329
+ ### Step 4: For Each File Below Target
330
+
331
+ For each file in the work queue:
332
+
333
+ #### 4.1: Analyze Source File
334
+
335
+ 1. Read the source file
336
+ 2. Identify all functions/methods
337
+ 3. Check existing tests (if any)
338
+ 4. Identify uncovered code paths:
339
+ - Uncovered functions
340
+ - Uncovered branches (if/else, switch)
341
+ - Error handling paths
342
+ - Edge cases
343
+
344
+ #### 4.2: Write/Improve Tests
345
+
346
+ 1. Create test file if missing
347
+ 2. Add tests for uncovered lines
348
+ 3. Follow testing patterns from patterns file
349
+
350
+ **Test File Naming**:
351
+ - Jest: `*.test.ts`, `*.spec.ts`
352
+ - Pytest: `test_*.py`, `*_test.py`
353
+
354
+ **Test Structure**:
355
+
356
+ ```typescript
357
+ // Jest example
358
+ describe('FunctionName', () => {
359
+ describe('when condition', () => {
360
+ it('should expected behavior', () => {
361
+ // Arrange
362
+ // Act
363
+ // Assert
364
+ });
365
+ });
366
+ });
367
+ ```
368
+
369
+ ```python
370
+ # Pytest example
371
+ class TestFunctionName:
372
+ def test_when_condition_should_expected_behavior(self):
373
+ # Arrange
374
+ # Act
375
+ # Assert
376
+ ```
377
+
378
+ #### 4.3: Verify File Coverage
379
+
380
+ After writing tests, run coverage for the specific file:
381
+
382
+ **Jest**:
383
+ ```bash
384
+ npm run test -- --coverage --collectCoverageFrom="src/path/file.ts"
385
+ ```
386
+
387
+ **Pytest**:
388
+ ```bash
389
+ pytest tests/test_file.py --cov=src/module --cov-report=term-missing
390
+ ```
391
+
392
+ **CRITICAL**: ALL metrics must meet target:
393
+ - Lines
394
+ - Statements
395
+ - Branches
396
+ - Functions
397
+
398
+ If not met, continue adding tests until all metrics pass.
399
+
400
+ ---
401
+
402
+ ### Step 5: Final Verification
403
+
404
+ After all files are processed, run full coverage:
405
+
406
+ **Jest**:
407
+ ```bash
408
+ npm run test -- --coverage
409
+ ```
410
+
411
+ **Pytest**:
412
+ ```bash
413
+ pytest --cov=src --cov-report=term-missing
414
+ ```
415
+
416
+ Verify all files meet the target coverage.
417
+
418
+ ---
419
+
420
+ ## Coverage Metrics Priority
421
+
422
+ 1. **Lines**: Most important metric
423
+ 2. **Branches**: Cover all conditional paths (if/else, ternary, switch)
424
+ 3. **Functions**: Ensure all exported functions are tested
425
+ 4. **Statements**: Usually follows lines coverage
426
+
427
+ ---
428
+
429
+ ## Test Writing Guidelines
430
+
431
+ ### What to Test
432
+
433
+ | Priority | What to Test | Why |
434
+ | -------- | ------------------------------- | -------------------------------- |
435
+ | High | Public API / Exported functions | Contract with consumers |
436
+ | High | Error handling paths | Critical for reliability |
437
+ | High | Edge cases | Often source of bugs |
438
+ | Medium | Happy path scenarios | Basic functionality |
439
+ | Medium | Boundary conditions | Off-by-one errors |
440
+ | Low | Private helper functions | Tested via public API |
441
+
442
+ ### Test Quality Checklist
443
+
444
+ - [ ] Tests are independent (no shared state)
445
+ - [ ] Tests have clear names describing behavior
446
+ - [ ] Tests follow AAA pattern (Arrange, Act, Assert)
447
+ - [ ] Mocks are minimal and focused
448
+ - [ ] Edge cases are covered
449
+ - [ ] Error scenarios are tested
450
+
451
+ ---
452
+
453
+ ## Handling Common Patterns
454
+
455
+ ### Async Functions
456
+
457
+ ```typescript
458
+ it('should handle async operation', async () => {
459
+ const result = await asyncFunction();
460
+ expect(result).toBe(expected);
461
+ });
462
+ ```
463
+
464
+ ### Error Throwing
465
+
466
+ ```typescript
467
+ it('should throw error for invalid input', () => {
468
+ expect(() => functionWithValidation(null)).toThrow('Invalid input');
469
+ });
470
+ ```
471
+
472
+ ### Mocking Dependencies
473
+
474
+ ```typescript
475
+ jest.mock('./dependency', () => ({
476
+ dependencyFunction: jest.fn().mockReturnValue('mocked'),
477
+ }));
478
+ ```
479
+
480
+ ---
481
+
482
+ ## Output Format
483
+
484
+ Present progress after each file:
485
+
486
+ ```markdown
487
+ ## Test Progress: [file_path]
488
+
489
+ **Before**: 45% coverage
490
+ **After**: 82% coverage
491
+
492
+ **Tests Added**:
493
+ - test_when_valid_input_returns_result
494
+ - test_when_invalid_input_throws_error
495
+ - test_edge_case_empty_string
496
+
497
+ **Metrics**:
498
+ | Metric | Before | After | Target | Status |
499
+ | ---------- | ------ | ------ | ------ | ------ |
500
+ | Lines | 45% | 82% | 80% | Pass |
501
+ | Branches | 30% | 80% | 80% | Pass |
502
+ | Functions | 50% | 100% | 80% | Pass |
503
+ | Statements | 45% | 82% | 80% | Pass |
504
+ ```
505
+
506
+ ---
507
+
508
+ ## Final Report
509
+
510
+ After completion, present summary:
511
+
512
+ ```markdown
513
+ ## Coverage Target Achieved!
514
+
515
+ **Target**: [X]%
516
+ **Final Coverage**: [Y]%
517
+
518
+ ### Files Updated:
519
+
520
+ | File | Before | After |
521
+ | --------------------------- | ------ | ------ |
522
+ | src/services/userService.ts | 45% | 85% |
523
+ | src/utils/validation.ts | 60% | 92% |
524
+
525
+ ### Tests Created/Updated:
526
+
527
+ - Created: X new test files
528
+ - Updated: Y existing test files
529
+ - Total tests added: Z
530
+
531
+ All metrics meet or exceed the target coverage.
532
+ ```
533
+
534
+ ---
535
+
536
+ ## Related Files
537
+
538
+ | File | Purpose |
539
+ | ------------------------------------------- | ------------------------------- |
540
+ | `.claude/rules/patterns/jest-patterns.md` | Jest testing patterns |
541
+ | `.claude/rules/patterns/pytest-patterns.md`| Pytest testing patterns |
542
+ | `.claude/rules/tools/jest-testing-tool.md` | Jest commands and utilities |
543
+ | `.claude/rules/tools/pytest-testing-tool.md`| Pytest commands and utilities |
@@ -0,0 +1,175 @@
1
+
2
+ ## How to Use This File
3
+
4
+ 1. **Add patterns** that represent your team's coding standards
5
+ 2. **Include examples** showing the correct way to implement each pattern
6
+ 3. **Explain why** each pattern is beneficial
7
+ 4. **Reference tools/rules** if applicable (ESLint, SonarQube, etc.)
8
+
9
+ ---
10
+
11
+ ## Example Pattern Structure
12
+
13
+ ### Pattern Name
14
+
15
+ Brief description of what this pattern accomplishes.
16
+
17
+ ```typescript
18
+ // GOOD - Example of the correct approach
19
+ const example = doThingCorrectly()
20
+
21
+ // Optionally show the contrast
22
+ // BAD - What to avoid (but keep this minimal)
23
+ const badExample = doThingWrong()
24
+ ```
25
+
26
+ **Why**: Explain the benefit of following this pattern.
27
+
28
+ **Guidelines**:
29
+
30
+ - Specific guideline 1
31
+ - Specific guideline 2
32
+
33
+ ---
34
+
35
+ ## Example Patterns
36
+
37
+ ### 1. Descriptive Naming
38
+
39
+ Use clear, descriptive names for functions, variables, and components.
40
+
41
+ ```typescript
42
+ // GOOD - Clear intent
43
+ function calculateOrderTotal(items: OrderItem[]): number
44
+ function fetchUserProfile(userId: string): Promise<User>
45
+ const isAuthenticated = checkAuthStatus()
46
+
47
+ // GOOD - Component names describe what they render
48
+ export const UserProfileCard = () => { ... }
49
+ export const OrderSummaryTable = () => { ... }
50
+ ```
51
+
52
+ **Why**: Improves code readability and makes the codebase self-documenting.
53
+
54
+ ---
55
+
56
+ ### 2. Single Responsibility
57
+
58
+ Each function/component should do one thing well.
59
+
60
+ ```typescript
61
+ // GOOD - Focused function
62
+ function formatCurrency(amount: number): string {
63
+ return new Intl.NumberFormat('en-US', {
64
+ style: 'currency',
65
+ currency: 'USD',
66
+ }).format(amount)
67
+ }
68
+
69
+ // GOOD - Focused component
70
+ const PriceDisplay = ({ amount }: { amount: number }) => (
71
+ <span className="price">{formatCurrency(amount)}</span>
72
+ )
73
+ ```
74
+
75
+ **Why**: Easier to test, maintain, and reuse.
76
+
77
+ ---
78
+
79
+ ### 3. Error Handling
80
+
81
+ Handle errors explicitly with meaningful messages.
82
+
83
+ ```typescript
84
+ // GOOD - Explicit error handling
85
+ async function fetchData(url: string) {
86
+ try {
87
+ const response = await fetch(url)
88
+ if (!response.ok) {
89
+ throw new ApiError(`Request failed: ${response.status}`)
90
+ }
91
+ return response.json()
92
+ } catch (error) {
93
+ logger.error('Failed to fetch data', { url, error })
94
+ throw error
95
+ }
96
+ }
97
+ ```
98
+
99
+ **Why**: Makes debugging easier and provides better user feedback.
100
+
101
+ ---
102
+
103
+ ### 4. Type Safety
104
+
105
+ Leverage TypeScript's type system to catch errors at compile time.
106
+
107
+ ```typescript
108
+ // GOOD - Explicit types for function signatures
109
+ interface User {
110
+ id: string
111
+ name: string
112
+ email: string
113
+ }
114
+
115
+ function createUser(input: CreateUserInput): User {
116
+ // Implementation
117
+ }
118
+
119
+ // GOOD - Use type inference where appropriate
120
+ const users = await fetchUsers() // Type inferred from function return
121
+ ```
122
+
123
+ **Why**: Catches errors before runtime and improves IDE autocomplete.
124
+
125
+ ---
126
+
127
+ ### 5. Consistent Code Organization
128
+
129
+ Follow a consistent structure for files and folders.
130
+
131
+ ```
132
+ src/
133
+ ├── components/ # UI components
134
+ ├── hooks/ # Custom React hooks
135
+ ├── utils/ # Utility functions
136
+ ├── types/ # TypeScript type definitions
137
+ ├── services/ # API and external service integrations
138
+ └── stores/ # State management
139
+ ```
140
+
141
+ **Why**: Makes the codebase navigable and predictable.
142
+
143
+ ---
144
+
145
+ ## Adding Your Patterns
146
+
147
+ When adding new patterns to this file:
148
+
149
+ 1. **Start with the pattern name** as a heading
150
+ 2. **Provide code examples** showing the correct approach
151
+ 3. **Explain the "Why"** - benefits of the pattern
152
+ 4. **Add guidelines** for edge cases or nuances
153
+ 5. **Reference external rules** if applicable (linting, etc.)
154
+
155
+ ---
156
+
157
+ ## Template for New Patterns
158
+
159
+ ```markdown
160
+ ### Pattern Name
161
+
162
+ Brief description of what this pattern accomplishes.
163
+
164
+ \`\`\`typescript
165
+ // GOOD - Example code
166
+ const example = correctApproach()
167
+ \`\`\`
168
+
169
+ **Why**: Explanation of benefits.
170
+
171
+ **Guidelines**:
172
+
173
+ - Guideline 1
174
+ - Guideline 2
175
+ ```