tdd-claude-code 0.4.0 → 0.4.2
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 +10 -12
- package/bin/install.js +1 -1
- package/build.md +69 -57
- package/coverage.md +73 -6
- package/help.md +11 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,14 +30,12 @@ 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
|
|
33
|
+
/tdd:coverage Write tests for existing code (optional)
|
|
34
34
|
↓
|
|
35
|
-
/tdd:discuss
|
|
36
|
-
/tdd:plan
|
|
37
|
-
/tdd:build
|
|
38
|
-
/tdd:verify
|
|
39
|
-
↓
|
|
40
|
-
...repeat for each phase...
|
|
35
|
+
/tdd:discuss Shape how it gets built
|
|
36
|
+
/tdd:plan Create task plans
|
|
37
|
+
/tdd:build Write tests → implement → tests pass ← TDD happens here
|
|
38
|
+
/tdd:verify Human acceptance testing
|
|
41
39
|
↓
|
|
42
40
|
/tdd:complete Tag release
|
|
43
41
|
```
|
|
@@ -60,11 +58,11 @@ You run one command. Tests get written before code. Automatically.
|
|
|
60
58
|
| `/tdd:new-project` | Start project with test infrastructure |
|
|
61
59
|
| `/tdd:init` | Add TDD to existing codebase |
|
|
62
60
|
| `/tdd:coverage` | Analyze gaps, write tests for existing code |
|
|
63
|
-
| `/tdd:discuss
|
|
64
|
-
| `/tdd:plan
|
|
65
|
-
| `/tdd:build
|
|
66
|
-
| `/tdd:verify
|
|
67
|
-
| `/tdd:status
|
|
61
|
+
| `/tdd:discuss` | Capture implementation preferences |
|
|
62
|
+
| `/tdd:plan` | Create task plans |
|
|
63
|
+
| `/tdd:build` | **Write tests → implement → verify** |
|
|
64
|
+
| `/tdd:verify` | Human acceptance testing |
|
|
65
|
+
| `/tdd:status` | Check test pass/fail |
|
|
68
66
|
| `/tdd:progress` | Where am I? |
|
|
69
67
|
| `/tdd:quick` | Ad-hoc task with tests |
|
|
70
68
|
| `/tdd:complete` | Tag release |
|
package/bin/install.js
CHANGED
package/build.md
CHANGED
|
@@ -14,9 +14,11 @@ This is the core TDD command. Tests before code, automatically.
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
16
|
```
|
|
17
|
-
/tdd:build
|
|
17
|
+
/tdd:build [phase_number]
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
Phase number is optional. Defaults to 1.
|
|
21
|
+
|
|
20
22
|
## Process
|
|
21
23
|
|
|
22
24
|
### Step 1: Load Plans
|
|
@@ -32,61 +34,60 @@ Check what's already set up:
|
|
|
32
34
|
- `spec/` directory → RSpec
|
|
33
35
|
- None found → Set up based on PROJECT.md stack (see framework defaults below)
|
|
34
36
|
|
|
35
|
-
### Step 3:
|
|
37
|
+
### Step 3: Plan Tests for Each Task
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
Before writing any tests, create a test plan for each task in the phase.
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
You are a TDD Test Writer. Write failing tests that define expected behavior BEFORE implementation.
|
|
41
|
+
For each task in the plan:
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
1. **Read the task** — understand what behavior is being specified
|
|
44
|
+
2. **Identify test cases:**
|
|
45
|
+
- Happy path (expected inputs → expected outputs)
|
|
46
|
+
- Edge cases mentioned in `<action>`
|
|
47
|
+
- Error conditions from `<verify>`
|
|
48
|
+
3. **Create test plan entry**
|
|
43
49
|
|
|
44
|
-
|
|
45
|
-
{PROJECT.md contents}
|
|
46
|
-
</project>
|
|
50
|
+
Create `.planning/phases/{phase}-TEST-PLAN.md`:
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
</plan>
|
|
52
|
+
```markdown
|
|
53
|
+
# Phase {N} Test Plan
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
{Detected or default framework}
|
|
54
|
-
</test_framework>
|
|
55
|
+
## Task: {task-id} - {task-title}
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
{List any existing test files for patterns, or "None - this is a new project"}
|
|
58
|
-
</existing_tests>
|
|
57
|
+
### File: tests/{feature}.test.ts
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
| Test | Type | Expected Result |
|
|
60
|
+
|------|------|-----------------|
|
|
61
|
+
| user can log in with valid credentials | happy path | returns user object |
|
|
62
|
+
| login rejects invalid password | error | throws AuthError |
|
|
63
|
+
| login rejects empty email | edge case | throws ValidationError |
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
### Dependencies to mock:
|
|
66
|
+
- database connection
|
|
67
|
+
- email service
|
|
63
68
|
|
|
64
|
-
|
|
69
|
+
---
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Test File Patterns
|
|
71
|
+
## Task: {task-id-2} - {task-title-2}
|
|
72
|
+
...
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Step 4: Write Tests One Task at a Time
|
|
76
|
+
|
|
77
|
+
**For each task in the test plan, sequentially:**
|
|
78
|
+
|
|
79
|
+
#### 4a. Write test file for this task
|
|
80
|
+
|
|
81
|
+
Follow the project's test patterns. Test names should describe expected behavior:
|
|
82
|
+
```
|
|
83
|
+
✓ "user can log in with valid credentials"
|
|
84
|
+
✓ "login rejects invalid password with 401"
|
|
85
|
+
✗ "test login" (too vague)
|
|
86
|
+
```
|
|
85
87
|
|
|
86
88
|
**Vitest/Jest (TypeScript):**
|
|
87
89
|
```typescript
|
|
88
90
|
import { describe, it, expect } from 'vitest'
|
|
89
|
-
// Import from where code WILL exist
|
|
90
91
|
import { login } from '../src/auth/login'
|
|
91
92
|
|
|
92
93
|
describe('login', () => {
|
|
@@ -106,7 +107,6 @@ describe('login', () => {
|
|
|
106
107
|
**pytest (Python):**
|
|
107
108
|
```python
|
|
108
109
|
import pytest
|
|
109
|
-
# Import from where code WILL exist
|
|
110
110
|
from src.auth import login
|
|
111
111
|
|
|
112
112
|
def test_login_returns_user_for_valid_credentials():
|
|
@@ -118,28 +118,40 @@ def test_login_raises_for_invalid_password():
|
|
|
118
118
|
login("user@test.com", "wrong")
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
#### 4b. Run this test file
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
```bash
|
|
124
|
+
npm test -- tests/auth/login.test.ts # vitest
|
|
125
|
+
pytest tests/test_login.py # pytest
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Verify:
|
|
129
|
+
- ✅ Tests execute (no syntax errors)
|
|
130
|
+
- ✅ Tests FAIL (not pass, not skip)
|
|
131
|
+
- ❌ If import errors, add mocks/stubs and retry
|
|
132
|
+
|
|
133
|
+
#### 4c. Commit this test file
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
git add tests/auth/login.test.ts
|
|
137
|
+
git commit -m "test: add login tests (red) - phase {N}"
|
|
138
|
+
```
|
|
128
139
|
|
|
129
|
-
|
|
140
|
+
#### 4d. Move to next task
|
|
130
141
|
|
|
131
|
-
|
|
142
|
+
Repeat 4a-4c for each task in the test plan.
|
|
132
143
|
|
|
144
|
+
**Critical Rules:**
|
|
133
145
|
- Tests must be **syntactically valid** and **runnable**
|
|
134
146
|
- Tests must **FAIL** because code doesn't exist yet
|
|
135
147
|
- Tests must NOT **ERROR** from import issues — mock if needed
|
|
136
148
|
- Do NOT write any implementation code
|
|
137
149
|
- Do NOT skip or stub out the actual assertions
|
|
138
|
-
|
|
150
|
+
- **One task at a time, verify, commit, then next**
|
|
139
151
|
|
|
140
|
-
### Step
|
|
152
|
+
### Step 5: Verify All Tests Fail (Red)
|
|
141
153
|
|
|
142
|
-
Run the test suite:
|
|
154
|
+
Run the full test suite:
|
|
143
155
|
```bash
|
|
144
156
|
npm test # or vitest run, pytest, etc.
|
|
145
157
|
```
|
|
@@ -150,7 +162,7 @@ Check output:
|
|
|
150
162
|
- ❌ If tests error on imports, add mocks and retry
|
|
151
163
|
- ❌ If tests pass, something's wrong — investigate
|
|
152
164
|
|
|
153
|
-
### Step
|
|
165
|
+
### Step 6: Create Test Summary
|
|
154
166
|
|
|
155
167
|
Create `.planning/phases/{phase}-TESTS.md`:
|
|
156
168
|
|
|
@@ -180,13 +192,13 @@ Status: ✅ All tests failing (Red)
|
|
|
180
192
|
| session persists across requests | 01-task-2 |
|
|
181
193
|
```
|
|
182
194
|
|
|
183
|
-
### Step
|
|
195
|
+
### Step 7: Execute Implementation (Green)
|
|
184
196
|
|
|
185
197
|
Call `/gsd:execute-phase {phase_number}`
|
|
186
198
|
|
|
187
199
|
GSD's executor implements the code. Tests provide concrete pass/fail targets.
|
|
188
200
|
|
|
189
|
-
### Step
|
|
201
|
+
### Step 8: Verify All Tests Pass (Green)
|
|
190
202
|
|
|
191
203
|
After execution completes, run tests again:
|
|
192
204
|
```bash
|
|
@@ -197,7 +209,7 @@ Check output:
|
|
|
197
209
|
- ✅ All tests PASS → Continue to verify
|
|
198
210
|
- ❌ Some tests fail → Report which tasks need fixes
|
|
199
211
|
|
|
200
|
-
### Step
|
|
212
|
+
### Step 9: Update Test Summary
|
|
201
213
|
|
|
202
214
|
Update `.planning/phases/{phase}-TESTS.md`:
|
|
203
215
|
|
package/coverage.md
CHANGED
|
@@ -125,12 +125,79 @@ Start writing tests now?
|
|
|
125
125
|
|
|
126
126
|
**If "Yes":**
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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.
|
|
134
201
|
|
|
135
202
|
### 7. Report Summary
|
|
136
203
|
|
package/help.md
CHANGED
|
@@ -16,10 +16,12 @@ TDD-first workflow powered by GSD. You use `/tdd:*` for everything — tests hap
|
|
|
16
16
|
|
|
17
17
|
| Command | What It Does |
|
|
18
18
|
|---------|--------------|
|
|
19
|
-
| `/tdd:discuss
|
|
20
|
-
| `/tdd:plan
|
|
21
|
-
| `/tdd:build
|
|
22
|
-
| `/tdd:verify
|
|
19
|
+
| `/tdd:discuss` | Capture implementation preferences |
|
|
20
|
+
| `/tdd:plan` | Research and create task plans |
|
|
21
|
+
| `/tdd:build` | **Write tests → implement → verify tests pass** |
|
|
22
|
+
| `/tdd:verify` | Human acceptance testing |
|
|
23
|
+
|
|
24
|
+
Phase number optional. Defaults to 1.
|
|
23
25
|
|
|
24
26
|
### Navigation
|
|
25
27
|
|
|
@@ -48,20 +50,14 @@ TDD-first workflow powered by GSD. You use `/tdd:*` for everything — tests hap
|
|
|
48
50
|
/tdd:new-project New project from scratch
|
|
49
51
|
OR
|
|
50
52
|
/tdd:init Existing codebase
|
|
51
|
-
/tdd:coverage
|
|
52
|
-
↓
|
|
53
|
-
/tdd:discuss 1 Shape how phase 1 gets built
|
|
54
|
-
/tdd:plan 1 Create task plans
|
|
55
|
-
/tdd:build 1 Write tests → implement → tests pass
|
|
56
|
-
/tdd:verify 1 Human acceptance testing
|
|
53
|
+
/tdd:coverage Write tests for existing code (optional)
|
|
57
54
|
↓
|
|
58
|
-
/tdd:discuss
|
|
59
|
-
/tdd:plan
|
|
60
|
-
/tdd:build
|
|
61
|
-
/tdd:verify
|
|
55
|
+
/tdd:discuss Shape how it gets built
|
|
56
|
+
/tdd:plan Create task plans
|
|
57
|
+
/tdd:build Write tests → implement → tests pass
|
|
58
|
+
/tdd:verify Human acceptance testing
|
|
62
59
|
↓
|
|
63
60
|
/tdd:complete Tag release
|
|
64
|
-
/tdd:new-milestone Start v2
|
|
65
61
|
```
|
|
66
62
|
|
|
67
63
|
## What Happens in `/tdd:build`
|