tdd-claude-code 0.3.0 → 0.4.1
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/build.md +66 -56
- package/coverage.md +222 -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.1';
|
|
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/build.md
CHANGED
|
@@ -32,61 +32,60 @@ Check what's already set up:
|
|
|
32
32
|
- `spec/` directory → RSpec
|
|
33
33
|
- None found → Set up based on PROJECT.md stack (see framework defaults below)
|
|
34
34
|
|
|
35
|
-
### Step 3:
|
|
35
|
+
### Step 3: Plan Tests for Each Task
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Before writing any tests, create a test plan for each task in the phase.
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
You are a TDD Test Writer. Write failing tests that define expected behavior BEFORE implementation.
|
|
39
|
+
For each task in the plan:
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
1. **Read the task** — understand what behavior is being specified
|
|
42
|
+
2. **Identify test cases:**
|
|
43
|
+
- Happy path (expected inputs → expected outputs)
|
|
44
|
+
- Edge cases mentioned in `<action>`
|
|
45
|
+
- Error conditions from `<verify>`
|
|
46
|
+
3. **Create test plan entry**
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
{PROJECT.md contents}
|
|
46
|
-
</project>
|
|
48
|
+
Create `.planning/phases/{phase}-TEST-PLAN.md`:
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
</plan>
|
|
50
|
+
```markdown
|
|
51
|
+
# Phase {N} Test Plan
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
{Detected or default framework}
|
|
54
|
-
</test_framework>
|
|
53
|
+
## Task: {task-id} - {task-title}
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
{List any existing test files for patterns, or "None - this is a new project"}
|
|
58
|
-
</existing_tests>
|
|
55
|
+
### File: tests/{feature}.test.ts
|
|
59
56
|
|
|
60
|
-
|
|
57
|
+
| Test | Type | Expected Result |
|
|
58
|
+
|------|------|-----------------|
|
|
59
|
+
| user can log in with valid credentials | happy path | returns user object |
|
|
60
|
+
| login rejects invalid password | error | throws AuthError |
|
|
61
|
+
| login rejects empty email | edge case | throws ValidationError |
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
### Dependencies to mock:
|
|
64
|
+
- database connection
|
|
65
|
+
- email service
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
---
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Test File Patterns
|
|
69
|
+
## Task: {task-id-2} - {task-title-2}
|
|
70
|
+
...
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Step 4: Write Tests One Task at a Time
|
|
74
|
+
|
|
75
|
+
**For each task in the test plan, sequentially:**
|
|
76
|
+
|
|
77
|
+
#### 4a. Write test file for this task
|
|
78
|
+
|
|
79
|
+
Follow the project's test patterns. Test names should describe expected behavior:
|
|
80
|
+
```
|
|
81
|
+
✓ "user can log in with valid credentials"
|
|
82
|
+
✓ "login rejects invalid password with 401"
|
|
83
|
+
✗ "test login" (too vague)
|
|
84
|
+
```
|
|
85
85
|
|
|
86
86
|
**Vitest/Jest (TypeScript):**
|
|
87
87
|
```typescript
|
|
88
88
|
import { describe, it, expect } from 'vitest'
|
|
89
|
-
// Import from where code WILL exist
|
|
90
89
|
import { login } from '../src/auth/login'
|
|
91
90
|
|
|
92
91
|
describe('login', () => {
|
|
@@ -106,7 +105,6 @@ describe('login', () => {
|
|
|
106
105
|
**pytest (Python):**
|
|
107
106
|
```python
|
|
108
107
|
import pytest
|
|
109
|
-
# Import from where code WILL exist
|
|
110
108
|
from src.auth import login
|
|
111
109
|
|
|
112
110
|
def test_login_returns_user_for_valid_credentials():
|
|
@@ -118,28 +116,40 @@ def test_login_raises_for_invalid_password():
|
|
|
118
116
|
login("user@test.com", "wrong")
|
|
119
117
|
```
|
|
120
118
|
|
|
121
|
-
|
|
119
|
+
#### 4b. Run this test file
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm test -- tests/auth/login.test.ts # vitest
|
|
123
|
+
pytest tests/test_login.py # pytest
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Verify:
|
|
127
|
+
- ✅ Tests execute (no syntax errors)
|
|
128
|
+
- ✅ Tests FAIL (not pass, not skip)
|
|
129
|
+
- ❌ If import errors, add mocks/stubs and retry
|
|
130
|
+
|
|
131
|
+
#### 4c. Commit this test file
|
|
122
132
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
-
|
|
126
|
-
|
|
127
|
-
- `spec/{feature}_spec.rb`
|
|
133
|
+
```bash
|
|
134
|
+
git add tests/auth/login.test.ts
|
|
135
|
+
git commit -m "test: add login tests (red) - phase {N}"
|
|
136
|
+
```
|
|
128
137
|
|
|
129
|
-
|
|
138
|
+
#### 4d. Move to next task
|
|
130
139
|
|
|
131
|
-
|
|
140
|
+
Repeat 4a-4c for each task in the test plan.
|
|
132
141
|
|
|
142
|
+
**Critical Rules:**
|
|
133
143
|
- Tests must be **syntactically valid** and **runnable**
|
|
134
144
|
- Tests must **FAIL** because code doesn't exist yet
|
|
135
145
|
- Tests must NOT **ERROR** from import issues — mock if needed
|
|
136
146
|
- Do NOT write any implementation code
|
|
137
147
|
- Do NOT skip or stub out the actual assertions
|
|
138
|
-
|
|
148
|
+
- **One task at a time, verify, commit, then next**
|
|
139
149
|
|
|
140
|
-
### Step
|
|
150
|
+
### Step 5: Verify All Tests Fail (Red)
|
|
141
151
|
|
|
142
|
-
Run the test suite:
|
|
152
|
+
Run the full test suite:
|
|
143
153
|
```bash
|
|
144
154
|
npm test # or vitest run, pytest, etc.
|
|
145
155
|
```
|
|
@@ -150,7 +160,7 @@ Check output:
|
|
|
150
160
|
- ❌ If tests error on imports, add mocks and retry
|
|
151
161
|
- ❌ If tests pass, something's wrong — investigate
|
|
152
162
|
|
|
153
|
-
### Step
|
|
163
|
+
### Step 6: Create Test Summary
|
|
154
164
|
|
|
155
165
|
Create `.planning/phases/{phase}-TESTS.md`:
|
|
156
166
|
|
|
@@ -180,13 +190,13 @@ Status: ✅ All tests failing (Red)
|
|
|
180
190
|
| session persists across requests | 01-task-2 |
|
|
181
191
|
```
|
|
182
192
|
|
|
183
|
-
### Step
|
|
193
|
+
### Step 7: Execute Implementation (Green)
|
|
184
194
|
|
|
185
195
|
Call `/gsd:execute-phase {phase_number}`
|
|
186
196
|
|
|
187
197
|
GSD's executor implements the code. Tests provide concrete pass/fail targets.
|
|
188
198
|
|
|
189
|
-
### Step
|
|
199
|
+
### Step 8: Verify All Tests Pass (Green)
|
|
190
200
|
|
|
191
201
|
After execution completes, run tests again:
|
|
192
202
|
```bash
|
|
@@ -197,7 +207,7 @@ Check output:
|
|
|
197
207
|
- ✅ All tests PASS → Continue to verify
|
|
198
208
|
- ❌ Some tests fail → Report which tasks need fixes
|
|
199
209
|
|
|
200
|
-
### Step
|
|
210
|
+
### Step 9: Update Test Summary
|
|
201
211
|
|
|
202
212
|
Update `.planning/phases/{phase}-TESTS.md`:
|
|
203
213
|
|
package/coverage.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
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
|
+
Write tests using GSD-style execution — one file at a time with verification and commits.
|
|
129
|
+
|
|
130
|
+
#### For each file in the backlog (sequentially):
|
|
131
|
+
|
|
132
|
+
**a) Plan tests for this file**
|
|
133
|
+
|
|
134
|
+
Read the source file and create test plan:
|
|
135
|
+
```markdown
|
|
136
|
+
## File: src/services/payment.ts
|
|
137
|
+
|
|
138
|
+
### Exports:
|
|
139
|
+
- createCharge(amount, customerId)
|
|
140
|
+
- refundCharge(chargeId)
|
|
141
|
+
- getPaymentHistory(customerId)
|
|
142
|
+
|
|
143
|
+
### Test cases:
|
|
144
|
+
| Function | Test | Type |
|
|
145
|
+
|----------|------|------|
|
|
146
|
+
| createCharge | creates charge for valid customer | happy path |
|
|
147
|
+
| createCharge | rejects negative amount | edge case |
|
|
148
|
+
| createCharge | handles Stripe API error | error |
|
|
149
|
+
| refundCharge | refunds existing charge | happy path |
|
|
150
|
+
| refundCharge | fails for invalid chargeId | error |
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**b) Write test file**
|
|
154
|
+
|
|
155
|
+
Create tests that capture current behavior:
|
|
156
|
+
```typescript
|
|
157
|
+
import { describe, it, expect } from 'vitest'
|
|
158
|
+
import { createCharge, refundCharge } from '../src/services/payment'
|
|
159
|
+
|
|
160
|
+
describe('createCharge', () => {
|
|
161
|
+
it('creates charge for valid customer', async () => {
|
|
162
|
+
const result = await createCharge(1000, 'cust_123')
|
|
163
|
+
expect(result.id).toBeDefined()
|
|
164
|
+
expect(result.amount).toBe(1000)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
it('rejects negative amount', async () => {
|
|
168
|
+
await expect(createCharge(-100, 'cust_123'))
|
|
169
|
+
.rejects.toThrow()
|
|
170
|
+
})
|
|
171
|
+
})
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**c) Run tests for this file**
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
npm test -- tests/services/payment.test.ts
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Verify:
|
|
181
|
+
- ✅ Tests PASS (code already exists)
|
|
182
|
+
- ❌ If tests fail, investigate — either test is wrong or found a bug
|
|
183
|
+
|
|
184
|
+
**d) Commit this test file**
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
git add tests/services/payment.test.ts
|
|
188
|
+
git commit -m "test: add payment service tests"
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**e) Update backlog**
|
|
192
|
+
|
|
193
|
+
Mark item complete in `.planning/TEST-BACKLOG.md`:
|
|
194
|
+
```markdown
|
|
195
|
+
- [x] src/services/payment.ts - payment processing logic ✅
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**f) Move to next file**
|
|
199
|
+
|
|
200
|
+
Repeat a-e for each file in the backlog.
|
|
201
|
+
|
|
202
|
+
### 7. Report Summary
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
Coverage analysis complete.
|
|
206
|
+
|
|
207
|
+
Before: 33% (8/24 files)
|
|
208
|
+
Backlog created: .planning/TEST-BACKLOG.md
|
|
209
|
+
- Critical: 3 files
|
|
210
|
+
- High priority: 2 files
|
|
211
|
+
- Standard: 11 files
|
|
212
|
+
|
|
213
|
+
Run /tdd:build backlog to start writing tests.
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Usage
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
/tdd:coverage
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
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
|
```
|