tdd-claude-code 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/bin/install.js +2 -1
- package/coverage.md +155 -0
- package/help.md +3 -0
- package/init.md +76 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ You use `/tdd:*` commands for everything. Never touch `/gsd:*` directly.
|
|
|
30
30
|
/tdd:new-project New project from scratch
|
|
31
31
|
OR
|
|
32
32
|
/tdd:init Add TDD to existing codebase
|
|
33
|
+
/tdd:coverage Analyze gaps, write retro tests (optional)
|
|
33
34
|
↓
|
|
34
35
|
/tdd:discuss 1 Shape how phase 1 gets built
|
|
35
36
|
/tdd:plan 1 Create task plans
|
|
@@ -58,6 +59,7 @@ You run one command. Tests get written before code. Automatically.
|
|
|
58
59
|
|---------|--------------|
|
|
59
60
|
| `/tdd:new-project` | Start project with test infrastructure |
|
|
60
61
|
| `/tdd:init` | Add TDD to existing codebase |
|
|
62
|
+
| `/tdd:coverage` | Analyze gaps, write tests for existing code |
|
|
61
63
|
| `/tdd:discuss [N]` | Capture implementation preferences |
|
|
62
64
|
| `/tdd:plan [N]` | Create task plans |
|
|
63
65
|
| `/tdd:build <N>` | **Write tests → implement → verify** |
|
package/bin/install.js
CHANGED
|
@@ -26,11 +26,12 @@ ${c.cyan} ████████╗██████╗ ██████
|
|
|
26
26
|
╚═╝ ╚═════╝ ╚═════╝${c.reset}
|
|
27
27
|
`;
|
|
28
28
|
|
|
29
|
-
const VERSION = '0.
|
|
29
|
+
const VERSION = '0.4.0';
|
|
30
30
|
|
|
31
31
|
const COMMANDS = [
|
|
32
32
|
'new-project.md',
|
|
33
33
|
'init.md',
|
|
34
|
+
'coverage.md',
|
|
34
35
|
'discuss.md',
|
|
35
36
|
'plan.md',
|
|
36
37
|
'build.md',
|
package/coverage.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# /tdd:coverage - Analyze Test Coverage Gaps
|
|
2
|
+
|
|
3
|
+
Scan existing code, identify what's untested, and offer to write retrospective tests.
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
- After `/tdd:init` to add tests to existing code
|
|
8
|
+
- Anytime you want to improve test coverage
|
|
9
|
+
- When joining a project to understand test gaps
|
|
10
|
+
- After "vibe coding" a feature without tests
|
|
11
|
+
|
|
12
|
+
## Process
|
|
13
|
+
|
|
14
|
+
### 1. Detect Test Framework
|
|
15
|
+
|
|
16
|
+
Identify the test setup:
|
|
17
|
+
- Framework: vitest, jest, pytest, go test, rspec, cargo test
|
|
18
|
+
- Test directory: `tests/`, `__tests__/`, `spec/`, etc.
|
|
19
|
+
- Test patterns: `*.test.ts`, `*_test.py`, etc.
|
|
20
|
+
|
|
21
|
+
If no test framework found, suggest running `/tdd:init` first.
|
|
22
|
+
|
|
23
|
+
### 2. Scan Source Files
|
|
24
|
+
|
|
25
|
+
Identify all source files:
|
|
26
|
+
- `src/**/*`, `lib/**/*`, `app/**/*`, `pkg/**/*`
|
|
27
|
+
- Exclude: node_modules, vendor, dist, build, .git
|
|
28
|
+
|
|
29
|
+
Categorize by type:
|
|
30
|
+
- **API/Routes**: files handling HTTP endpoints
|
|
31
|
+
- **Services**: business logic modules
|
|
32
|
+
- **Components**: UI components (React, Vue, etc.)
|
|
33
|
+
- **Utils**: helper functions
|
|
34
|
+
- **Models**: data structures, schemas
|
|
35
|
+
- **Config**: configuration files (skip testing)
|
|
36
|
+
|
|
37
|
+
### 3. Match Tests to Source
|
|
38
|
+
|
|
39
|
+
For each source file, look for corresponding test:
|
|
40
|
+
- `src/auth/login.ts` → `tests/auth/login.test.ts` or `src/auth/login.test.ts`
|
|
41
|
+
- `lib/utils.py` → `tests/test_utils.py` or `tests/utils_test.py`
|
|
42
|
+
- `pkg/api/handler.go` → `pkg/api/handler_test.go`
|
|
43
|
+
|
|
44
|
+
### 4. Identify Critical Paths
|
|
45
|
+
|
|
46
|
+
Flag high-priority untested code:
|
|
47
|
+
- **Auth**: login, logout, session, token, password, oauth
|
|
48
|
+
- **Payments**: payment, billing, charge, subscription, stripe, checkout
|
|
49
|
+
- **Data mutations**: create, update, delete, save, remove
|
|
50
|
+
- **Security**: validate, sanitize, permission, role, access
|
|
51
|
+
|
|
52
|
+
### 5. Present Coverage Analysis
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
Test Coverage Analysis
|
|
56
|
+
|
|
57
|
+
Source files: 24
|
|
58
|
+
Test files: 8
|
|
59
|
+
Coverage: 33% (8/24 files have tests)
|
|
60
|
+
|
|
61
|
+
Tested:
|
|
62
|
+
✓ src/utils/format.ts (src/utils/format.test.ts)
|
|
63
|
+
✓ src/api/health.ts (tests/api/health.test.ts)
|
|
64
|
+
... [list all]
|
|
65
|
+
|
|
66
|
+
Untested - Critical:
|
|
67
|
+
✗ src/services/payment.ts - Stripe integration, checkout flow
|
|
68
|
+
✗ src/api/auth.ts - login, session management
|
|
69
|
+
✗ src/middleware/auth.ts - JWT validation
|
|
70
|
+
|
|
71
|
+
Untested - High Priority:
|
|
72
|
+
✗ src/api/users.ts - user CRUD operations
|
|
73
|
+
✗ src/services/email.ts - transactional emails
|
|
74
|
+
|
|
75
|
+
Untested - Standard:
|
|
76
|
+
✗ src/utils/helpers.ts - utility functions
|
|
77
|
+
✗ src/components/Header.tsx - navigation component
|
|
78
|
+
... [list all]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 6. Offer Retrospective Test Writing
|
|
82
|
+
|
|
83
|
+
Ask the user:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
Would you like to write tests for existing code?
|
|
87
|
+
|
|
88
|
+
1) Yes - critical paths only (fastest)
|
|
89
|
+
2) Yes - critical + high priority
|
|
90
|
+
3) Yes - everything untested
|
|
91
|
+
4) No - just wanted the report
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**If tests requested:**
|
|
95
|
+
|
|
96
|
+
Create `.planning/TEST-BACKLOG.md`:
|
|
97
|
+
|
|
98
|
+
```markdown
|
|
99
|
+
# Test Backlog
|
|
100
|
+
|
|
101
|
+
Generated: [date]
|
|
102
|
+
Coverage before: 33% (8/24)
|
|
103
|
+
|
|
104
|
+
## Critical (auth, payments, security)
|
|
105
|
+
- [ ] src/services/payment.ts - Stripe integration
|
|
106
|
+
- [ ] src/api/auth.ts - login/logout flows
|
|
107
|
+
- [ ] src/middleware/auth.ts - JWT validation
|
|
108
|
+
|
|
109
|
+
## High Priority (data mutations, core logic)
|
|
110
|
+
- [ ] src/api/users.ts - CRUD operations
|
|
111
|
+
- [ ] src/services/email.ts - email sending
|
|
112
|
+
|
|
113
|
+
## Standard (utils, components, helpers)
|
|
114
|
+
- [ ] src/utils/helpers.ts
|
|
115
|
+
- [ ] src/components/Header.tsx
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Then ask:
|
|
119
|
+
```
|
|
120
|
+
Start writing tests now?
|
|
121
|
+
|
|
122
|
+
1) Yes - begin with first critical item
|
|
123
|
+
2) No - I'll run /tdd:build backlog later
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**If "Yes":**
|
|
127
|
+
|
|
128
|
+
For each file, write tests that capture current behavior:
|
|
129
|
+
1. Read the source file
|
|
130
|
+
2. Identify exported functions/classes
|
|
131
|
+
3. Write tests for each public interface
|
|
132
|
+
4. Run tests to verify they pass (code already exists)
|
|
133
|
+
5. Mark item complete in backlog
|
|
134
|
+
|
|
135
|
+
### 7. Report Summary
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
Coverage analysis complete.
|
|
139
|
+
|
|
140
|
+
Before: 33% (8/24 files)
|
|
141
|
+
Backlog created: .planning/TEST-BACKLOG.md
|
|
142
|
+
- Critical: 3 files
|
|
143
|
+
- High priority: 2 files
|
|
144
|
+
- Standard: 11 files
|
|
145
|
+
|
|
146
|
+
Run /tdd:build backlog to start writing tests.
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Usage
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
/tdd:coverage
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
No arguments needed. Scans entire codebase.
|
package/help.md
CHANGED
|
@@ -10,6 +10,7 @@ TDD-first workflow powered by GSD. You use `/tdd:*` for everything — tests hap
|
|
|
10
10
|
|---------|--------------|
|
|
11
11
|
| `/tdd:new-project` | Start new project with test infrastructure |
|
|
12
12
|
| `/tdd:init` | Add TDD to existing codebase |
|
|
13
|
+
| `/tdd:coverage` | Analyze gaps, write tests for existing code |
|
|
13
14
|
|
|
14
15
|
### Core Workflow
|
|
15
16
|
|
|
@@ -47,6 +48,7 @@ TDD-first workflow powered by GSD. You use `/tdd:*` for everything — tests hap
|
|
|
47
48
|
/tdd:new-project New project from scratch
|
|
48
49
|
OR
|
|
49
50
|
/tdd:init Existing codebase
|
|
51
|
+
/tdd:coverage Analyze gaps, write retro tests (optional)
|
|
50
52
|
↓
|
|
51
53
|
/tdd:discuss 1 Shape how phase 1 gets built
|
|
52
54
|
/tdd:plan 1 Create task plans
|
|
@@ -90,6 +92,7 @@ TDD commands call GSD internally:
|
|
|
90
92
|
|-------------|-------|
|
|
91
93
|
| `/tdd:new-project` | `/gsd:new-project` + test setup |
|
|
92
94
|
| `/tdd:init` | scan + test setup (no GSD call) |
|
|
95
|
+
| `/tdd:coverage` | scan + write tests (no GSD call) |
|
|
93
96
|
| `/tdd:discuss` | `/gsd:discuss-phase` |
|
|
94
97
|
| `/tdd:plan` | `/gsd:plan-phase` |
|
|
95
98
|
| `/tdd:build` | write tests + `/gsd:execute-phase` |
|
package/init.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# /tdd:init - Initialize TDD in Existing Project
|
|
2
2
|
|
|
3
|
-
Add TDD workflow to an existing codebase.
|
|
3
|
+
Add TDD workflow to an existing codebase. Analyzes what you have, identifies gaps, and offers to write tests for existing code.
|
|
4
4
|
|
|
5
5
|
## When to Use
|
|
6
6
|
|
|
@@ -9,6 +9,12 @@ Add TDD workflow to an existing codebase.
|
|
|
9
9
|
- You're joining a project mid-development
|
|
10
10
|
- You want to adopt TDD on a "vibe coded" project
|
|
11
11
|
|
|
12
|
+
This command will:
|
|
13
|
+
1. Set up test infrastructure (if missing)
|
|
14
|
+
2. **Analyze your existing code** to understand what it does
|
|
15
|
+
3. **Identify untested modules** and critical paths
|
|
16
|
+
4. **Ask if you want retrospective tests** written for existing code
|
|
17
|
+
|
|
12
18
|
For brand new projects with no code, use `/tdd:new-project` instead.
|
|
13
19
|
|
|
14
20
|
## Process
|
|
@@ -87,7 +93,72 @@ Scan the codebase and generate summary:
|
|
|
87
93
|
- Entry points (main files, API routes, etc.)
|
|
88
94
|
- Dependencies and their roles
|
|
89
95
|
|
|
90
|
-
### 7.
|
|
96
|
+
### 7. Identify Untested Code
|
|
97
|
+
|
|
98
|
+
Compare source files against test files to identify:
|
|
99
|
+
- Modules/components with no corresponding tests
|
|
100
|
+
- Key functions that lack test coverage
|
|
101
|
+
- Critical paths (auth, payments, data mutations) without tests
|
|
102
|
+
|
|
103
|
+
Present findings:
|
|
104
|
+
```
|
|
105
|
+
Code Coverage Analysis:
|
|
106
|
+
|
|
107
|
+
Tested:
|
|
108
|
+
✓ src/auth/login.ts (tests/auth/login.test.ts)
|
|
109
|
+
✓ src/utils/format.ts (tests/utils/format.test.ts)
|
|
110
|
+
|
|
111
|
+
Untested:
|
|
112
|
+
✗ src/api/users.ts - CRUD operations, no tests
|
|
113
|
+
✗ src/services/payment.ts - payment processing, no tests
|
|
114
|
+
✗ src/components/Dashboard.tsx - main UI, no tests
|
|
115
|
+
|
|
116
|
+
Critical paths without tests: 2 (auth, payments)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 8. Offer Retrospective Test Writing
|
|
120
|
+
|
|
121
|
+
Ask the user:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
Would you like to write tests for existing code?
|
|
125
|
+
|
|
126
|
+
1) Yes - prioritize critical paths first
|
|
127
|
+
2) Yes - write tests for everything
|
|
128
|
+
3) No - only use TDD for new features going forward
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**If option 1 or 2 selected:**
|
|
132
|
+
|
|
133
|
+
Create `.planning/BACKLOG.md` with test tasks:
|
|
134
|
+
|
|
135
|
+
```markdown
|
|
136
|
+
# Test Backlog
|
|
137
|
+
|
|
138
|
+
## Critical (write first)
|
|
139
|
+
- [ ] src/services/payment.ts - payment processing logic
|
|
140
|
+
- [ ] src/api/auth.ts - authentication flows
|
|
141
|
+
|
|
142
|
+
## High Priority
|
|
143
|
+
- [ ] src/api/users.ts - user CRUD operations
|
|
144
|
+
- [ ] src/middleware/validation.ts - input validation
|
|
145
|
+
|
|
146
|
+
## Standard
|
|
147
|
+
- [ ] src/utils/helpers.ts - utility functions
|
|
148
|
+
- [ ] src/components/Dashboard.tsx - dashboard rendering
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Then ask:
|
|
152
|
+
```
|
|
153
|
+
Start writing tests now, or save backlog for later?
|
|
154
|
+
|
|
155
|
+
1) Start now - begin with critical paths
|
|
156
|
+
2) Later - I'll run /tdd:build backlog when ready
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**If "Start now":** Begin writing tests for the first critical path item using Red-Green-Refactor (but code already exists, so focus on capturing current behavior).
|
|
160
|
+
|
|
161
|
+
### 9. Create or Update PROJECT.md
|
|
91
162
|
|
|
92
163
|
If PROJECT.md doesn't exist, create it with:
|
|
93
164
|
|
|
@@ -122,7 +193,7 @@ Tests are written BEFORE implementation, not after.
|
|
|
122
193
|
|
|
123
194
|
If PROJECT.md exists, append the TDD section only.
|
|
124
195
|
|
|
125
|
-
###
|
|
196
|
+
### 10. Report Summary
|
|
126
197
|
|
|
127
198
|
```
|
|
128
199
|
TDD initialized for [project name]
|
|
@@ -131,9 +202,10 @@ Stack: [detected]
|
|
|
131
202
|
Test framework: [framework] (existing/newly configured)
|
|
132
203
|
Test directory: [path]
|
|
133
204
|
Existing tests: [count] files
|
|
205
|
+
Untested files: [count] identified
|
|
134
206
|
|
|
135
207
|
Next steps:
|
|
136
|
-
- Run /tdd:
|
|
208
|
+
- Run /tdd:build backlog to write tests for existing code
|
|
137
209
|
- Run /tdd:discuss to plan new features with TDD
|
|
138
210
|
- Run /tdd:quick for ad-hoc tasks with tests
|
|
139
211
|
```
|