@wbern/claude-instructions 1.18.1 → 1.19.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.
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  [![Made with Claude Code](https://img.shields.io/badge/Made%20with-Claude%20Code-blueviolet)](https://claude.ai/code)
10
10
  [![Contributors](https://img.shields.io/github/contributors/wbern/claude-instructions)](https://github.com/wbern/claude-instructions/graphs/contributors)
11
11
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen)](https://github.com/wbern/claude-instructions/pulls)
12
- [![Commands](https://img.shields.io/badge/commands-22-blue)](https://github.com/wbern/claude-instructions#available-commands)
12
+ [![Commands](https://img.shields.io/badge/commands-23-blue)](https://github.com/wbern/claude-instructions#available-commands)
13
13
 
14
14
  ```
15
15
  _==/ i i \==_
@@ -214,6 +214,7 @@ flowchart TB
214
214
  - `/green` - Execute TDD Green Phase - write minimal implementation to pass the failing test
215
215
  - `/refactor` - Execute TDD Refactor Phase - improve code structure while keeping tests green
216
216
  - `/cycle` - Execute complete TDD cycle - Red, Green, and Refactor phases in sequence
217
+ - `/tdd-review` - Review test suite quality against FIRST principles and TDD anti-patterns
217
218
 
218
219
  ### Workflow
219
220
 
@@ -475,3 +476,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for development workflow, build system, a
475
476
  ## Credits
476
477
 
477
478
  TDD workflow instructions adapted from [TDD Guard](https://github.com/nizos/tdd-guard) by Nizar.
479
+
480
+ FIRST principles and test quality criteria from [TDD Manifesto](https://tddmanifesto.com/).
481
+
482
+ Example kata from [Cyber-Dojo](https://cyber-dojo.org/).
@@ -163,9 +163,30 @@ For each detected category with changes, run a targeted review. Skip categories
163
163
 
164
164
  ### Tests Review Criteria
165
165
 
166
- - Coverage: Edge cases, error paths, boundaries
167
- - Assertion quality: Specific assertions, not just "no error"
168
- - Flaky patterns: Timing dependencies, order dependencies, shared state
166
+ #### FIRST Principles
167
+
168
+ | Principle | What to Check |
169
+ |-----------|---------------|
170
+ | **Fast** | Tests complete quickly, no I/O, no network calls, no sleep()/setTimeout delays |
171
+ | **Independent** | No shared mutable state, no execution order dependencies between tests |
172
+ | **Repeatable** | No Date.now(), no Math.random() without seeding, no external service dependencies |
173
+ | **Self-validating** | Meaningful assertions that verify behavior, no manual verification needed |
174
+
175
+ #### TDD Anti-patterns
176
+
177
+ | Anti-pattern | Detection Signals |
178
+ |--------------|-------------------|
179
+ | **The Liar** | `expect(true).toBe(true)`, empty test bodies, tests with no assertions |
180
+ | **Excessive Setup** | >20 lines of arrange code, >5 mocks, deep nested object construction |
181
+ | **The One** | >5 assertions testing unrelated behaviors in a single test |
182
+ | **The Peeping Tom** | Testing private methods, asserting on internal state, tests that break on any refactor |
183
+ | **The Slow Poke** | Real database/network calls, file I/O, hard-coded timeouts |
184
+
185
+ #### Test Structure (AAA Pattern)
186
+
187
+ - **Arrange**: Clear setup with minimal fixtures
188
+ - **Act**: Single action being tested
189
+ - **Assert**: Specific, behavior-focused assertions
169
190
 
170
191
  ### Docs Review Criteria
171
192
 
@@ -128,6 +128,12 @@
128
128
  "category": "Workflow",
129
129
  "order": 10
130
130
  },
131
+ "tdd-review.md": {
132
+ "description": "Review test suite quality against FIRST principles and TDD anti-patterns",
133
+ "hint": "Review tests",
134
+ "category": "Test-Driven Development",
135
+ "order": 45
136
+ },
131
137
  "tdd.md": {
132
138
  "description": "Remind agent about TDD approach and continue conversation",
133
139
  "hint": "TDD reminder",
@@ -93,3 +93,11 @@ This phase is **not part of the regular TDD workflow** and must only be applied
93
93
  - In the refactor phase, it is perfectly fine to refactor both test and implementation code. That said, completely new functionality is not allowed. Types, clean up, abstractions, and helpers are allowed as long as they do not introduce new behavior.
94
94
  - Adding types, interfaces, or a constant in order to replace magic values is perfectly fine during refactoring.
95
95
  - Provide the agent with helpful directions so that they do not get stuck when blocking them.
96
+
97
+ ### Test Structure (AAA Pattern)
98
+
99
+ Structure each test with clear phases:
100
+
101
+ - **Arrange**: Set up test data and preconditions (keep minimal)
102
+ - **Act**: Execute the single action being tested
103
+ - **Assert**: Verify the expected outcome with specific assertions
@@ -92,4 +92,14 @@ This phase is **not part of the regular TDD workflow** and must only be applied
92
92
  - Adding types, interfaces, or a constant in order to replace magic values is perfectly fine during refactoring.
93
93
  - Provide the agent with helpful directions so that they do not get stuck when blocking them.
94
94
 
95
+ ### Watch for Brittle Tests
96
+
97
+ When refactoring implementation, watch for **Peeping Tom** tests that:
98
+
99
+ - Test private methods or internal state directly
100
+ - Assert on implementation details rather than behavior
101
+ - Break on any refactoring even when behavior is preserved
102
+
103
+ If tests fail after a pure refactoring (no behavior change), consider whether the tests are testing implementation rather than behavior.
104
+
95
105
  1. **Consistency check** - Look for inconsistent patterns, naming conventions, or structure across the codebase
@@ -0,0 +1,102 @@
1
+ ---
2
+ description: Review test suite quality against FIRST principles and TDD anti-patterns
3
+ argument-hint: [optional test file or directory path]
4
+ ---
5
+
6
+ ## General Guidelines
7
+
8
+ ### Output Style
9
+
10
+ - **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
11
+ - Write natural, descriptive code without meta-commentary about the development process
12
+ - The code should speak for itself - TDD is the process, not the product
13
+
14
+ Beads is available for task tracking. Use `mcp__beads__*` tools to manage issues (the user interacts via `bd` commands).
15
+
16
+ (If there was no info above, fallback to:
17
+
18
+ 1. Context of the conversation, if there's an immediate thing
19
+ 2. `bd ready` to see what to work on next and start from there)
20
+
21
+ # Test Quality Review
22
+
23
+ Analyze test files against FIRST principles and TDD best practices.
24
+
25
+ ## Phase 1: Scope
26
+
27
+ | Input | Action |
28
+ |-------|--------|
29
+ | No argument | Find all test files in project |
30
+ | File path | Analyze specific test file |
31
+ | Directory | Analyze tests in directory |
32
+
33
+ Detect test files using common patterns: `*.test.*`, `*.spec.*`, `*.stories.*`, `__tests__/**`
34
+
35
+ Also check for framework-specific patterns based on the project's languages and tools (e.g., `*_test.go`, `*_test.py`, `Test*.java`, `*.feature` for BDD).
36
+
37
+ ## Phase 2: Analysis
38
+
39
+ For each test file, check against these criteria:
40
+
41
+ ### Quality Criteria
42
+
43
+ #### FIRST Principles
44
+
45
+ | Principle | What to Check |
46
+ |-----------|---------------|
47
+ | **Fast** | Tests complete quickly, no I/O, no network calls, no sleep()/setTimeout delays |
48
+ | **Independent** | No shared mutable state, no execution order dependencies between tests |
49
+ | **Repeatable** | No Date.now(), no Math.random() without seeding, no external service dependencies |
50
+ | **Self-validating** | Meaningful assertions that verify behavior, no manual verification needed |
51
+
52
+ #### TDD Anti-patterns
53
+
54
+ | Anti-pattern | Detection Signals |
55
+ |--------------|-------------------|
56
+ | **The Liar** | `expect(true).toBe(true)`, empty test bodies, tests with no assertions |
57
+ | **Excessive Setup** | >20 lines of arrange code, >5 mocks, deep nested object construction |
58
+ | **The One** | >5 assertions testing unrelated behaviors in a single test |
59
+ | **The Peeping Tom** | Testing private methods, asserting on internal state, tests that break on any refactor |
60
+ | **The Slow Poke** | Real database/network calls, file I/O, hard-coded timeouts |
61
+
62
+ #### Test Structure (AAA Pattern)
63
+
64
+ - **Arrange**: Clear setup with minimal fixtures
65
+ - **Act**: Single action being tested
66
+ - **Assert**: Specific, behavior-focused assertions
67
+
68
+ ## Phase 3: Report
69
+
70
+ Output a structured report:
71
+
72
+ ```
73
+ ## Test Quality Report
74
+
75
+ ### Summary
76
+ - Files analyzed: N
77
+ - Tests found: N
78
+ - Issues found: N (X blockers, Y warnings)
79
+
80
+ ### By File
81
+
82
+ #### path/to/file.test.ts
83
+
84
+ | Line | Issue | Severity | Description |
85
+ |------|-------|----------|-------------|
86
+ | 15 | The Liar | blocker | Test has no assertions |
87
+ | 42 | Slow Poke | warning | Uses setTimeout(500) |
88
+
89
+ ### Recommendations
90
+ - [ ] Fix blockers before merge
91
+ - [ ] Consider refactoring tests with excessive setup
92
+ ```
93
+
94
+ ### Severity Levels
95
+
96
+ - **blocker**: Must fix - test provides false confidence (The Liar, no assertions)
97
+ - **warning**: Should fix - test quality issue (Slow Poke, Excessive Setup)
98
+ - **info**: Consider - style or structure suggestion (AAA pattern)
99
+
100
+ ---
101
+
102
+ Test path (leave empty for all tests): $ARGUMENTS
@@ -161,9 +161,30 @@ For each detected category with changes, run a targeted review. Skip categories
161
161
 
162
162
  ### Tests Review Criteria
163
163
 
164
- - Coverage: Edge cases, error paths, boundaries
165
- - Assertion quality: Specific assertions, not just "no error"
166
- - Flaky patterns: Timing dependencies, order dependencies, shared state
164
+ #### FIRST Principles
165
+
166
+ | Principle | What to Check |
167
+ |-----------|---------------|
168
+ | **Fast** | Tests complete quickly, no I/O, no network calls, no sleep()/setTimeout delays |
169
+ | **Independent** | No shared mutable state, no execution order dependencies between tests |
170
+ | **Repeatable** | No Date.now(), no Math.random() without seeding, no external service dependencies |
171
+ | **Self-validating** | Meaningful assertions that verify behavior, no manual verification needed |
172
+
173
+ #### TDD Anti-patterns
174
+
175
+ | Anti-pattern | Detection Signals |
176
+ |--------------|-------------------|
177
+ | **The Liar** | `expect(true).toBe(true)`, empty test bodies, tests with no assertions |
178
+ | **Excessive Setup** | >20 lines of arrange code, >5 mocks, deep nested object construction |
179
+ | **The One** | >5 assertions testing unrelated behaviors in a single test |
180
+ | **The Peeping Tom** | Testing private methods, asserting on internal state, tests that break on any refactor |
181
+ | **The Slow Poke** | Real database/network calls, file I/O, hard-coded timeouts |
182
+
183
+ #### Test Structure (AAA Pattern)
184
+
185
+ - **Arrange**: Clear setup with minimal fixtures
186
+ - **Act**: Single action being tested
187
+ - **Assert**: Specific, behavior-focused assertions
167
188
 
168
189
  ### Docs Review Criteria
169
190
 
@@ -128,6 +128,12 @@
128
128
  "category": "Workflow",
129
129
  "order": 10
130
130
  },
131
+ "tdd-review.md": {
132
+ "description": "Review test suite quality against FIRST principles and TDD anti-patterns",
133
+ "hint": "Review tests",
134
+ "category": "Test-Driven Development",
135
+ "order": 45
136
+ },
131
137
  "tdd.md": {
132
138
  "description": "Remind agent about TDD approach and continue conversation",
133
139
  "hint": "TDD reminder",
@@ -88,3 +88,11 @@ This phase is **not part of the regular TDD workflow** and must only be applied
88
88
  - In the refactor phase, it is perfectly fine to refactor both test and implementation code. That said, completely new functionality is not allowed. Types, clean up, abstractions, and helpers are allowed as long as they do not introduce new behavior.
89
89
  - Adding types, interfaces, or a constant in order to replace magic values is perfectly fine during refactoring.
90
90
  - Provide the agent with helpful directions so that they do not get stuck when blocking them.
91
+
92
+ ### Test Structure (AAA Pattern)
93
+
94
+ Structure each test with clear phases:
95
+
96
+ - **Arrange**: Set up test data and preconditions (keep minimal)
97
+ - **Act**: Execute the single action being tested
98
+ - **Assert**: Verify the expected outcome with specific assertions
@@ -87,4 +87,14 @@ This phase is **not part of the regular TDD workflow** and must only be applied
87
87
  - Adding types, interfaces, or a constant in order to replace magic values is perfectly fine during refactoring.
88
88
  - Provide the agent with helpful directions so that they do not get stuck when blocking them.
89
89
 
90
+ ### Watch for Brittle Tests
91
+
92
+ When refactoring implementation, watch for **Peeping Tom** tests that:
93
+
94
+ - Test private methods or internal state directly
95
+ - Assert on implementation details rather than behavior
96
+ - Break on any refactoring even when behavior is preserved
97
+
98
+ If tests fail after a pure refactoring (no behavior change), consider whether the tests are testing implementation rather than behavior.
99
+
90
100
  1. **Consistency check** - Look for inconsistent patterns, naming conventions, or structure across the codebase
@@ -0,0 +1,97 @@
1
+ ---
2
+ description: Review test suite quality against FIRST principles and TDD anti-patterns
3
+ argument-hint: [optional test file or directory path]
4
+ ---
5
+
6
+ ## General Guidelines
7
+
8
+ ### Output Style
9
+
10
+ - **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
11
+ - Write natural, descriptive code without meta-commentary about the development process
12
+ - The code should speak for itself - TDD is the process, not the product
13
+
14
+ (If there was no info above, fallback to the context of the conversation)
15
+
16
+ # Test Quality Review
17
+
18
+ Analyze test files against FIRST principles and TDD best practices.
19
+
20
+ ## Phase 1: Scope
21
+
22
+ | Input | Action |
23
+ |-------|--------|
24
+ | No argument | Find all test files in project |
25
+ | File path | Analyze specific test file |
26
+ | Directory | Analyze tests in directory |
27
+
28
+ Detect test files using common patterns: `*.test.*`, `*.spec.*`, `*.stories.*`, `__tests__/**`
29
+
30
+ Also check for framework-specific patterns based on the project's languages and tools (e.g., `*_test.go`, `*_test.py`, `Test*.java`, `*.feature` for BDD).
31
+
32
+ ## Phase 2: Analysis
33
+
34
+ For each test file, check against these criteria:
35
+
36
+ ### Quality Criteria
37
+
38
+ #### FIRST Principles
39
+
40
+ | Principle | What to Check |
41
+ |-----------|---------------|
42
+ | **Fast** | Tests complete quickly, no I/O, no network calls, no sleep()/setTimeout delays |
43
+ | **Independent** | No shared mutable state, no execution order dependencies between tests |
44
+ | **Repeatable** | No Date.now(), no Math.random() without seeding, no external service dependencies |
45
+ | **Self-validating** | Meaningful assertions that verify behavior, no manual verification needed |
46
+
47
+ #### TDD Anti-patterns
48
+
49
+ | Anti-pattern | Detection Signals |
50
+ |--------------|-------------------|
51
+ | **The Liar** | `expect(true).toBe(true)`, empty test bodies, tests with no assertions |
52
+ | **Excessive Setup** | >20 lines of arrange code, >5 mocks, deep nested object construction |
53
+ | **The One** | >5 assertions testing unrelated behaviors in a single test |
54
+ | **The Peeping Tom** | Testing private methods, asserting on internal state, tests that break on any refactor |
55
+ | **The Slow Poke** | Real database/network calls, file I/O, hard-coded timeouts |
56
+
57
+ #### Test Structure (AAA Pattern)
58
+
59
+ - **Arrange**: Clear setup with minimal fixtures
60
+ - **Act**: Single action being tested
61
+ - **Assert**: Specific, behavior-focused assertions
62
+
63
+ ## Phase 3: Report
64
+
65
+ Output a structured report:
66
+
67
+ ```
68
+ ## Test Quality Report
69
+
70
+ ### Summary
71
+ - Files analyzed: N
72
+ - Tests found: N
73
+ - Issues found: N (X blockers, Y warnings)
74
+
75
+ ### By File
76
+
77
+ #### path/to/file.test.ts
78
+
79
+ | Line | Issue | Severity | Description |
80
+ |------|-------|----------|-------------|
81
+ | 15 | The Liar | blocker | Test has no assertions |
82
+ | 42 | Slow Poke | warning | Uses setTimeout(500) |
83
+
84
+ ### Recommendations
85
+ - [ ] Fix blockers before merge
86
+ - [ ] Consider refactoring tests with excessive setup
87
+ ```
88
+
89
+ ### Severity Levels
90
+
91
+ - **blocker**: Must fix - test provides false confidence (The Liar, no assertions)
92
+ - **warning**: Should fix - test quality issue (Slow Poke, Excessive Setup)
93
+ - **info**: Consider - style or structure suggestion (AAA pattern)
94
+
95
+ ---
96
+
97
+ Test path (leave empty for all tests): $ARGUMENTS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wbern/claude-instructions",
3
- "version": "1.18.1",
3
+ "version": "1.19.0",
4
4
  "description": "TDD workflow commands for Claude Code CLI",
5
5
  "type": "module",
6
6
  "bin": "./bin/cli.js",
@@ -53,6 +53,7 @@
53
53
  "jscpd": "^4.0.5",
54
54
  "knip": "^5.70.2",
55
55
  "lint-staged": "^16.2.7",
56
+ "markdownlint": "^0.40.0",
56
57
  "markdownlint-cli": "^0.46.0",
57
58
  "picocolors": "^1.1.1",
58
59
  "prettier": "^3.7.2",