tlc-claude-code 1.5.3 → 1.5.4
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/.claude/commands/tlc/audit.md +129 -0
- package/.claude/commands/tlc/autofix.md +217 -0
- package/.claude/commands/tlc/bug.md +255 -0
- package/.claude/commands/tlc/build.md +731 -0
- package/.claude/commands/tlc/checklist.md +212 -0
- package/.claude/commands/tlc/ci.md +414 -0
- package/.claude/commands/tlc/claim.md +189 -0
- package/.claude/commands/tlc/cleanup.md +187 -0
- package/.claude/commands/tlc/complete.md +160 -0
- package/.claude/commands/tlc/config.md +395 -0
- package/.claude/commands/tlc/coverage.md +222 -0
- package/.claude/commands/tlc/deploy.md +723 -0
- package/.claude/commands/tlc/discuss.md +185 -0
- package/.claude/commands/tlc/docs.md +194 -0
- package/.claude/commands/tlc/edge-cases.md +241 -0
- package/.claude/commands/tlc/export.md +456 -0
- package/.claude/commands/tlc/help.md +169 -0
- package/.claude/commands/tlc/import-project.md +246 -0
- package/.claude/commands/tlc/init.md +443 -0
- package/.claude/commands/tlc/issues.md +376 -0
- package/.claude/commands/tlc/llm.md +111 -0
- package/.claude/commands/tlc/new-milestone.md +172 -0
- package/.claude/commands/tlc/new-project.md +399 -0
- package/.claude/commands/tlc/next.md +129 -0
- package/.claude/commands/tlc/outdated.md +200 -0
- package/.claude/commands/tlc/plan.md +224 -0
- package/.claude/commands/tlc/progress.md +153 -0
- package/.claude/commands/tlc/quality.md +185 -0
- package/.claude/commands/tlc/quick.md +52 -0
- package/.claude/commands/tlc/refactor.md +190 -0
- package/.claude/commands/tlc/release.md +135 -0
- package/.claude/commands/tlc/review-pr.md +184 -0
- package/.claude/commands/tlc/review.md +200 -0
- package/.claude/commands/tlc/security.md +195 -0
- package/.claude/commands/tlc/server.md +19 -0
- package/.claude/commands/tlc/start.md +137 -0
- package/.claude/commands/tlc/status.md +65 -0
- package/.claude/commands/tlc/sync.md +652 -0
- package/.claude/commands/tlc/tlc.md +279 -0
- package/.claude/commands/tlc/verify.md +159 -0
- package/.claude/commands/tlc/who.md +151 -0
- package/bin/postinstall.js +54 -0
- package/package.json +3 -1
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
# /tlc:config - Configure Test Frameworks
|
|
2
|
+
|
|
3
|
+
Manage test framework settings for your project.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
/tlc:config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration File
|
|
12
|
+
|
|
13
|
+
TLC stores test preferences in `.tlc.json` at the project root:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"testFrameworks": {
|
|
18
|
+
"primary": "mocha",
|
|
19
|
+
"installed": ["mocha", "chai", "sinon", "proxyquire"],
|
|
20
|
+
"run": ["mocha"]
|
|
21
|
+
},
|
|
22
|
+
"testCommand": "npm test",
|
|
23
|
+
"testDirectory": "test"
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Fields
|
|
28
|
+
|
|
29
|
+
| Field | Description |
|
|
30
|
+
|-------|-------------|
|
|
31
|
+
| `primary` | Main test framework for new tests |
|
|
32
|
+
| `installed` | All test libraries available in project |
|
|
33
|
+
| `run` | Which frameworks to execute (subset of installed) |
|
|
34
|
+
| `testCommand` | Command to run tests |
|
|
35
|
+
| `testDirectory` | Where test files live |
|
|
36
|
+
|
|
37
|
+
## Supported Frameworks
|
|
38
|
+
|
|
39
|
+
### Default Stack (Recommended)
|
|
40
|
+
|
|
41
|
+
TLC defaults to the mocha ecosystem for new projects:
|
|
42
|
+
|
|
43
|
+
| Library | Purpose |
|
|
44
|
+
|---------|---------|
|
|
45
|
+
| **mocha** | Test runner |
|
|
46
|
+
| **chai** | Assertions (expect, should, assert) |
|
|
47
|
+
| **sinon** | Mocks, stubs, spies |
|
|
48
|
+
| **proxyquire** | Module mocking/dependency injection |
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install -D mocha chai sinon proxyquire @types/mocha @types/chai @types/sinon
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Alternative Frameworks
|
|
55
|
+
|
|
56
|
+
| Framework | Use Case |
|
|
57
|
+
|-----------|----------|
|
|
58
|
+
| **vitest** | Vite projects, fast, ESM-native |
|
|
59
|
+
| **jest** | React/Meta ecosystem, all-in-one |
|
|
60
|
+
| **pytest** | Python projects |
|
|
61
|
+
| **go test** | Go projects (built-in) |
|
|
62
|
+
| **rspec** | Ruby projects |
|
|
63
|
+
|
|
64
|
+
## Process
|
|
65
|
+
|
|
66
|
+
### Step 1: Check for Existing Config
|
|
67
|
+
|
|
68
|
+
Look for `.tlc.json` in project root.
|
|
69
|
+
|
|
70
|
+
If exists, display current settings:
|
|
71
|
+
```
|
|
72
|
+
Current TLC Configuration:
|
|
73
|
+
|
|
74
|
+
Test Framework: mocha
|
|
75
|
+
Libraries: mocha, chai, sinon, proxyquire
|
|
76
|
+
Run Command: npm test
|
|
77
|
+
Test Directory: test/
|
|
78
|
+
|
|
79
|
+
What would you like to do?
|
|
80
|
+
1) View/edit frameworks to run
|
|
81
|
+
2) Add a new framework
|
|
82
|
+
3) Change primary framework
|
|
83
|
+
4) Reset to defaults
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Step 2: First-Time Setup
|
|
87
|
+
|
|
88
|
+
If no config exists, check for existing tests:
|
|
89
|
+
|
|
90
|
+
1. **Detect installed frameworks** from package.json/dependencies
|
|
91
|
+
2. **Detect test files** patterns in use
|
|
92
|
+
3. **Propose configuration** based on findings
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
No TLC config found. Analyzing project...
|
|
96
|
+
|
|
97
|
+
Detected:
|
|
98
|
+
- jest (installed)
|
|
99
|
+
- 47 test files using Jest patterns
|
|
100
|
+
|
|
101
|
+
Options:
|
|
102
|
+
1) Keep Jest as primary (detected)
|
|
103
|
+
2) Add mocha alongside Jest
|
|
104
|
+
3) Switch to mocha (TLC default)
|
|
105
|
+
4) Custom configuration
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Step 3: Multi-Framework Setup
|
|
109
|
+
|
|
110
|
+
When multiple frameworks coexist:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
Multiple test frameworks detected:
|
|
114
|
+
- mocha: test/unit/*.test.js (23 files)
|
|
115
|
+
- jest: __tests__/*.spec.js (15 files)
|
|
116
|
+
|
|
117
|
+
Configure which to run:
|
|
118
|
+
[x] mocha - run these tests
|
|
119
|
+
[x] jest - run these tests
|
|
120
|
+
[ ] Run all frameworks
|
|
121
|
+
|
|
122
|
+
Test commands:
|
|
123
|
+
mocha: npx mocha 'test/**/*.test.js'
|
|
124
|
+
jest: npx jest
|
|
125
|
+
combined: npm test (runs both)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Step 4: Save Configuration
|
|
129
|
+
|
|
130
|
+
Write `.tlc.json`:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"testFrameworks": {
|
|
135
|
+
"primary": "mocha",
|
|
136
|
+
"installed": ["mocha", "chai", "sinon", "proxyquire", "jest"],
|
|
137
|
+
"run": ["mocha", "jest"]
|
|
138
|
+
},
|
|
139
|
+
"commands": {
|
|
140
|
+
"mocha": "npx mocha 'test/**/*.test.js'",
|
|
141
|
+
"jest": "npx jest",
|
|
142
|
+
"all": "npm test"
|
|
143
|
+
},
|
|
144
|
+
"testDirectory": "test",
|
|
145
|
+
"patterns": {
|
|
146
|
+
"mocha": "test/**/*.test.js",
|
|
147
|
+
"jest": "__tests__/**/*.spec.js"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Step 5: Update package.json
|
|
153
|
+
|
|
154
|
+
Ensure test scripts are configured:
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"scripts": {
|
|
159
|
+
"test": "npm run test:mocha && npm run test:jest",
|
|
160
|
+
"test:mocha": "mocha 'test/**/*.test.js'",
|
|
161
|
+
"test:jest": "jest",
|
|
162
|
+
"test:watch": "mocha --watch 'test/**/*.test.js'"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Example: Adding a Framework
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
> /tlc:config
|
|
171
|
+
|
|
172
|
+
Current: mocha (primary)
|
|
173
|
+
|
|
174
|
+
What would you like to do?
|
|
175
|
+
> 2) Add a new framework
|
|
176
|
+
|
|
177
|
+
Available frameworks to add:
|
|
178
|
+
1) jest - All-in-one testing (React ecosystem)
|
|
179
|
+
2) vitest - Fast, Vite-native
|
|
180
|
+
3) Other (specify)
|
|
181
|
+
|
|
182
|
+
> 1) jest
|
|
183
|
+
|
|
184
|
+
Installing jest...
|
|
185
|
+
npm install -D jest @types/jest
|
|
186
|
+
|
|
187
|
+
Configure jest test location:
|
|
188
|
+
> __tests__/
|
|
189
|
+
|
|
190
|
+
Updated .tlc.json:
|
|
191
|
+
installed: mocha, chai, sinon, proxyquire, jest
|
|
192
|
+
run: mocha, jest
|
|
193
|
+
|
|
194
|
+
Run which tests?
|
|
195
|
+
1) All frameworks (mocha + jest)
|
|
196
|
+
2) Only mocha
|
|
197
|
+
3) Only jest
|
|
198
|
+
4) Let me choose per-run
|
|
199
|
+
|
|
200
|
+
> 1) All frameworks
|
|
201
|
+
|
|
202
|
+
Done. Run 'npm test' to execute all test suites.
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Example: Project with Existing Jest
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
> /tlc:config
|
|
209
|
+
|
|
210
|
+
Detected: jest (47 test files)
|
|
211
|
+
|
|
212
|
+
Your project uses Jest. Options:
|
|
213
|
+
|
|
214
|
+
1) Keep Jest only
|
|
215
|
+
2) Add mocha for new tests, keep Jest for existing
|
|
216
|
+
3) Migrate to mocha (will need to convert tests)
|
|
217
|
+
|
|
218
|
+
> 2) Add mocha for new tests
|
|
219
|
+
|
|
220
|
+
Setting up mocha alongside Jest...
|
|
221
|
+
|
|
222
|
+
New tests will use: mocha + chai + sinon
|
|
223
|
+
Existing tests remain: jest
|
|
224
|
+
|
|
225
|
+
Updated scripts:
|
|
226
|
+
npm test - runs both
|
|
227
|
+
npm run test:new - runs mocha only
|
|
228
|
+
npm run test:legacy - runs jest only
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Enterprise Configuration (v1.4+)
|
|
232
|
+
|
|
233
|
+
Run `/tlc:config --enterprise` to configure enterprise features:
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
Enterprise Features Configuration
|
|
237
|
+
|
|
238
|
+
1) Audit Logging
|
|
239
|
+
2) Zero-Data-Retention
|
|
240
|
+
3) SSO Integration
|
|
241
|
+
4) Compliance (SOC 2)
|
|
242
|
+
5) All of the above
|
|
243
|
+
6) Back to main menu
|
|
244
|
+
|
|
245
|
+
Which to configure? [1-6]:
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Audit Logging Setup
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
Audit Logging Configuration
|
|
252
|
+
|
|
253
|
+
Enable audit logging? (Y/n)
|
|
254
|
+
|
|
255
|
+
Storage location: [.tlc/audit/]
|
|
256
|
+
Retention period: [90d]
|
|
257
|
+
|
|
258
|
+
SIEM Export:
|
|
259
|
+
1) None
|
|
260
|
+
2) JSON
|
|
261
|
+
3) Splunk HEC
|
|
262
|
+
4) CEF (ArcSight)
|
|
263
|
+
|
|
264
|
+
> 3
|
|
265
|
+
|
|
266
|
+
Splunk endpoint: https://splunk.example.com/hec
|
|
267
|
+
Splunk token: [enter token]
|
|
268
|
+
|
|
269
|
+
✓ Audit logging configured
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Zero-Data-Retention Setup
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
Zero-Data-Retention Mode
|
|
276
|
+
|
|
277
|
+
For HIPAA/PCI-DSS compliance, TLC can operate in zero-retention mode:
|
|
278
|
+
• Ephemeral storage (AES-256-GCM encrypted)
|
|
279
|
+
• Auto-purge on session end
|
|
280
|
+
• Sensitive data never written to disk
|
|
281
|
+
|
|
282
|
+
Enable zero-retention mode? (Y/n)
|
|
283
|
+
|
|
284
|
+
Sensitive patterns to detect:
|
|
285
|
+
[x] API keys
|
|
286
|
+
[x] Passwords
|
|
287
|
+
[x] Tokens
|
|
288
|
+
[x] Credit card numbers
|
|
289
|
+
[ ] Custom pattern: ___
|
|
290
|
+
|
|
291
|
+
✓ Zero-retention mode enabled
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### SSO Setup
|
|
295
|
+
|
|
296
|
+
```
|
|
297
|
+
SSO Configuration
|
|
298
|
+
|
|
299
|
+
Add identity provider:
|
|
300
|
+
1) OAuth 2.0 (GitHub, Google, Azure AD)
|
|
301
|
+
2) SAML 2.0 (Okta, OneLogin, custom)
|
|
302
|
+
|
|
303
|
+
> 1
|
|
304
|
+
|
|
305
|
+
Select OAuth provider:
|
|
306
|
+
1) GitHub
|
|
307
|
+
2) Google
|
|
308
|
+
3) Azure AD
|
|
309
|
+
4) Custom
|
|
310
|
+
|
|
311
|
+
> 1
|
|
312
|
+
|
|
313
|
+
Client ID: [enter]
|
|
314
|
+
Client Secret: [enter]
|
|
315
|
+
|
|
316
|
+
Test connection? (Y/n)
|
|
317
|
+
✓ GitHub OAuth configured
|
|
318
|
+
|
|
319
|
+
Enable MFA? (Y/n)
|
|
320
|
+
> Y
|
|
321
|
+
|
|
322
|
+
MFA methods:
|
|
323
|
+
[x] TOTP (Authenticator app)
|
|
324
|
+
[x] Backup codes
|
|
325
|
+
|
|
326
|
+
✓ MFA enabled
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Compliance Setup
|
|
330
|
+
|
|
331
|
+
```
|
|
332
|
+
Compliance Configuration
|
|
333
|
+
|
|
334
|
+
Framework:
|
|
335
|
+
1) SOC 2 Type II
|
|
336
|
+
2) Custom
|
|
337
|
+
|
|
338
|
+
> 1
|
|
339
|
+
|
|
340
|
+
Trust Service Categories to track:
|
|
341
|
+
[x] Security (CC1-CC9)
|
|
342
|
+
[x] Availability (A1)
|
|
343
|
+
[x] Processing Integrity (PI1)
|
|
344
|
+
[x] Confidentiality (C1)
|
|
345
|
+
[x] Privacy (P1-P8)
|
|
346
|
+
|
|
347
|
+
Evidence auto-collection: (Y/n)
|
|
348
|
+
Evidence directory: [.tlc/compliance/evidence/]
|
|
349
|
+
|
|
350
|
+
✓ SOC 2 compliance configured
|
|
351
|
+
|
|
352
|
+
Run /tlc:compliance status to see your compliance score
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Enterprise Config in .tlc.json
|
|
356
|
+
|
|
357
|
+
```json
|
|
358
|
+
{
|
|
359
|
+
"enterprise": {
|
|
360
|
+
"enabled": true,
|
|
361
|
+
"audit": {
|
|
362
|
+
"enabled": true,
|
|
363
|
+
"storage": ".tlc/audit/",
|
|
364
|
+
"retention": "90d",
|
|
365
|
+
"siem": {
|
|
366
|
+
"format": "splunk",
|
|
367
|
+
"endpoint": "https://splunk.example.com/hec"
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
"zeroRetention": {
|
|
371
|
+
"enabled": true,
|
|
372
|
+
"sensitivePatterns": ["password", "api_key", "token"]
|
|
373
|
+
},
|
|
374
|
+
"sso": {
|
|
375
|
+
"providers": {
|
|
376
|
+
"github": { "type": "oauth", "clientId": "xxx" }
|
|
377
|
+
},
|
|
378
|
+
"mfa": { "required": true, "methods": ["totp", "backup"] }
|
|
379
|
+
},
|
|
380
|
+
"compliance": {
|
|
381
|
+
"framework": "soc2",
|
|
382
|
+
"categories": ["Security", "Availability", "Confidentiality"],
|
|
383
|
+
"autoCollect": true
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
## Notes
|
|
390
|
+
|
|
391
|
+
- TLC defaults to mocha for consistency across projects
|
|
392
|
+
- Multiple frameworks can coexist when inheriting codebases
|
|
393
|
+
- Use `run` array to control which frameworks execute
|
|
394
|
+
- The `primary` framework is used for new test generation
|
|
395
|
+
- Enterprise features are opt-in and don't affect non-enterprise users
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# /tlc: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 `/tlc: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 `/tlc: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 /tlc:build backlog later
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**If "Yes":**
|
|
127
|
+
|
|
128
|
+
Write tests 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 /tlc:build backlog to start writing tests.
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Usage
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
/tlc:coverage
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
No arguments needed. Scans entire codebase.
|