@champpaba/claude-agent-kit 2.7.0 → 2.8.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.
Files changed (44) hide show
  1. package/.claude/CLAUDE.md +49 -0
  2. package/.claude/commands/csetup.md +364 -38
  3. package/.claude/commands/cview.md +364 -364
  4. package/.claude/contexts/design/accessibility.md +611 -611
  5. package/.claude/contexts/design/layout.md +400 -400
  6. package/.claude/contexts/design/responsive.md +551 -551
  7. package/.claude/contexts/design/shadows.md +522 -522
  8. package/.claude/contexts/design/typography.md +465 -465
  9. package/.claude/contexts/domain/README.md +164 -164
  10. package/.claude/contexts/patterns/agent-coordination.md +388 -388
  11. package/.claude/contexts/patterns/development-principles.md +513 -513
  12. package/.claude/contexts/patterns/error-handling.md +478 -478
  13. package/.claude/contexts/patterns/logging.md +424 -424
  14. package/.claude/contexts/patterns/tdd-classification.md +516 -516
  15. package/.claude/contexts/patterns/testing.md +413 -413
  16. package/.claude/lib/tdd-classifier.md +345 -345
  17. package/.claude/lib/validation-gates.md +484 -484
  18. package/.claude/settings.local.json +42 -42
  19. package/.claude/templates/context-template.md +45 -45
  20. package/.claude/templates/flags-template.json +42 -42
  21. package/.claude/templates/phases-sections/accessibility-test.md +17 -17
  22. package/.claude/templates/phases-sections/api-design.md +37 -37
  23. package/.claude/templates/phases-sections/backend-tests.md +16 -16
  24. package/.claude/templates/phases-sections/backend.md +37 -37
  25. package/.claude/templates/phases-sections/business-logic-validation.md +16 -16
  26. package/.claude/templates/phases-sections/component-tests.md +17 -17
  27. package/.claude/templates/phases-sections/contract-backend.md +16 -16
  28. package/.claude/templates/phases-sections/contract-frontend.md +16 -16
  29. package/.claude/templates/phases-sections/database.md +35 -35
  30. package/.claude/templates/phases-sections/e2e-tests.md +16 -16
  31. package/.claude/templates/phases-sections/fix-implementation.md +17 -17
  32. package/.claude/templates/phases-sections/frontend-integration.md +18 -18
  33. package/.claude/templates/phases-sections/manual-flow-test.md +15 -15
  34. package/.claude/templates/phases-sections/manual-ux-test.md +16 -16
  35. package/.claude/templates/phases-sections/refactor-implementation.md +17 -17
  36. package/.claude/templates/phases-sections/refactor.md +16 -16
  37. package/.claude/templates/phases-sections/regression-tests.md +15 -15
  38. package/.claude/templates/phases-sections/responsive-test.md +16 -16
  39. package/.claude/templates/phases-sections/script-implementation.md +43 -43
  40. package/.claude/templates/phases-sections/test-coverage.md +16 -16
  41. package/.claude/templates/phases-sections/user-approval.md +14 -14
  42. package/LICENSE +21 -21
  43. package/README.md +25 -0
  44. package/package.json +8 -4
@@ -1,345 +1,345 @@
1
- # TDD Classification Logic
2
-
3
- > **Automatically determines which phases require TDD workflow**
4
-
5
- ---
6
-
7
- ## 🎯 Purpose
8
-
9
- Provides logic to classify tasks and determine whether they require TDD (Test-Driven Development) workflow. Ensures consistent TDD decisions across all changes.
10
-
11
- **Result Format:**
12
- ```
13
- TDD Decision:
14
- required: true/false
15
- reason: "Why TDD is/isn't required"
16
- workflow: "red-green-refactor" | "test-alongside" | "none"
17
- confidence: "high" | "medium" | "low"
18
- ```
19
-
20
- ---
21
-
22
- ## 🔍 Classification Rules
23
-
24
- ### Rule 1: Backend API Endpoints
25
-
26
- **Always TDD:**
27
- - Authentication logic (login, register, password, JWT)
28
- - Authorization logic (permissions, roles, access)
29
- - Payment processing (Stripe, charges, refunds)
30
- - Financial calculations
31
- - Data validation with business rules
32
- - External API integrations (SendGrid, webhooks)
33
-
34
- **Test-Alongside OK:**
35
- - Simple CRUD operations (basic findOne, findMany, create, update, delete)
36
- - Read-only endpoints with no business logic
37
- - Health check endpoints
38
-
39
- ### Rule 2: Frontend UI
40
-
41
- **TDD Required:**
42
- - Multi-step forms with complex validation
43
- - State machines (wizards, checkout flows, onboarding)
44
- - Complex client-side calculations
45
-
46
- **Test-Alongside OK:**
47
- - Presentational components
48
- - Simple forms
49
- - Static pages
50
-
51
- ### Rule 3: Database
52
-
53
- **Never TDD:**
54
- - Schema design
55
- - Migration files
56
- - Database setup scripts
57
-
58
- **Reason:** Schemas are declarative, not imperative logic
59
-
60
- ### Rule 4: Integration
61
-
62
- **Never TDD:**
63
- - Contract validation (validation itself, not implementation)
64
- - Report generation
65
- - Documentation
66
-
67
- ### Rule 5: Test-Debug
68
-
69
- **Never TDD:**
70
- - Test-debug agent writes tests - no TDD needed
71
-
72
- ---
73
-
74
- ## 🤖 Classification Logic
75
-
76
- **Main Claude should follow this logic in `/csetup` when generating phases.md:**
77
-
78
- ### Step 1: Determine Phase Type
79
-
80
- Identify agent type from phase:
81
- - backend, api, endpoint → Backend rules
82
- - frontend, ui, uxui-frontend → Frontend rules
83
- - database, schema, migration → Database rules
84
- - integration, contract, validation → Integration rules
85
- - test, test-debug → Test rules
86
-
87
- ### Step 2: Check Critical Keywords (Backend Only)
88
-
89
- **Critical keywords** (always TDD):
90
- - auth, login, register, password, token, jwt
91
- - payment, stripe, charge, refund, transaction
92
- - permission, role, access, authorization
93
- - email, notification, sendgrid, sms
94
- - webhook, callback, integration
95
- - calculation, formula, compute
96
- - validation, business rule, constraint
97
-
98
- **If found:**
99
- - TDD Required: YES
100
- - Reason: "Critical backend logic requires TDD for correctness"
101
- - Workflow: red-green-refactor
102
- - Confidence: high
103
-
104
- ### Step 3: Check CRUD Pattern (Backend Only)
105
-
106
- **CRUD keywords:**
107
- - list, get, fetch, read, retrieve, view
108
-
109
- **If simple CRUD:**
110
- - TDD Required: NO
111
- - Reason: "Simple CRUD read operation - test-alongside OK"
112
- - Workflow: test-alongside
113
- - Confidence: high
114
-
115
- ### Step 4: Check Complexity
116
-
117
- **Backend:**
118
- - Complex → TDD required (red-green-refactor, medium confidence)
119
- - Medium/Simple → test-alongside OK
120
-
121
- **Frontend:**
122
- - Check for complex UI keywords:
123
- - multi-step, wizard, stepper
124
- - state machine, workflow
125
- - validation, form validation
126
- - calculation, formula
127
- - checkout, payment form, onboarding
128
- - If found → TDD required (red-green-refactor, high confidence)
129
- - Otherwise → test-alongside OK
130
-
131
- **Database/Integration/Test:**
132
- - Always NO TDD (workflow: none, high confidence)
133
-
134
- ---
135
-
136
- ## 🔧 Complexity Estimation
137
-
138
- **How to estimate complexity:**
139
-
140
- 1. **Time-based scoring:**
141
- - < 30 minutes → +0 points
142
- - 30-90 minutes → +1 point
143
- - > 90 minutes → +2 points
144
-
145
- 2. **Keyword-based scoring:**
146
- - Contains: multiple, complex, advanced, sophisticated → +1 point
147
- - Contains: integration, calculation, validation → +1 point
148
- - Contains: business logic, algorithm, optimization → +1 point
149
-
150
- 3. **Length-based scoring:**
151
- - Description > 500 chars → +1 point
152
- - Description > 10 lines → +1 point
153
- - Keywords > 5 → +1 point
154
-
155
- 4. **Classification:**
156
- - Score ≤ 2 → simple
157
- - Score 3-5 → medium
158
- - Score > 5 → complex
159
-
160
- ---
161
-
162
- ## 📊 Usage in /csetup
163
-
164
- **When generating phases.md:**
165
-
166
- For each phase:
167
- 1. Extract task description from tasks.md
168
- 2. Extract keywords from description
169
- 3. Estimate complexity (time + keywords + length)
170
- 4. Classify TDD (phase type + keywords + complexity)
171
- 5. Add TDD metadata to phases.md
172
-
173
- **Phase metadata includes:**
174
- ```markdown
175
- | TDD | YES/NO |
176
- | TDD Reason | {reason} |
177
- | TDD Workflow | red-green-refactor / test-alongside / none |
178
- | Complexity | simple / medium / complex |
179
- ```
180
-
181
- ---
182
-
183
- ## 📝 Phase Metadata Format
184
-
185
- **Example output in phases.md:**
186
-
187
- ```markdown
188
- ## Phase 7: Backend Implementation
189
-
190
- | Metadata | Value |
191
- |----------|-------|
192
- | Phase | Backend Implementation |
193
- | Agent | backend |
194
- | TDD | YES |
195
- | TDD Reason | Critical backend logic requires TDD for correctness |
196
- | TDD Workflow | red-green-refactor |
197
- | Complexity | complex |
198
- | Estimated | 120 minutes |
199
-
200
- **TDD Required:** ✅ This phase MUST follow RED-GREEN-REFACTOR workflow.
201
-
202
- **Why TDD:**
203
- Critical backend logic requires TDD for correctness.
204
- Detected keywords: auth, login, jwt, validation
205
-
206
- **Workflow:**
207
- 1. 🔴 RED: Write tests FIRST (they should fail)
208
- 2. ✅ GREEN: Write minimal implementation to pass tests
209
- 3. 🔧 REFACTOR: Improve code quality while keeping tests green
210
- ```
211
-
212
- ---
213
-
214
- ## 🎯 Example Classifications
215
-
216
- ### Example 1: Authentication Endpoint
217
-
218
- **Input:**
219
- - Phase: backend
220
- - Task: "Implement POST /api/auth/login with JWT token generation"
221
- - Complexity: complex
222
- - Keywords: auth, login, jwt, password, validation
223
-
224
- **Output:**
225
- - TDD Required: YES
226
- - Reason: "Critical backend logic requires TDD for correctness"
227
- - Workflow: red-green-refactor
228
- - Confidence: high
229
-
230
- ### Example 2: Simple List Endpoint
231
-
232
- **Input:**
233
- - Phase: backend
234
- - Task: "Implement GET /api/posts to list all posts"
235
- - Complexity: simple
236
- - Keywords: get, list, read
237
-
238
- **Output:**
239
- - TDD Required: NO
240
- - Reason: "Simple CRUD read operation - test-alongside OK"
241
- - Workflow: test-alongside
242
- - Confidence: high
243
-
244
- ### Example 3: Multi-Step Form
245
-
246
- **Input:**
247
- - Phase: uxui-frontend
248
- - Task: "Create multi-step checkout wizard with validation"
249
- - Complexity: complex
250
- - Keywords: multi-step, wizard, checkout, validation
251
-
252
- **Output:**
253
- - TDD Required: YES
254
- - Reason: "Complex UI state machine requires TDD"
255
- - Workflow: red-green-refactor
256
- - Confidence: high
257
-
258
- ### Example 4: Simple UI Component
259
-
260
- **Input:**
261
- - Phase: uxui-frontend
262
- - Task: "Create a product card component"
263
- - Complexity: simple
264
- - Keywords: card, component, display
265
-
266
- **Output:**
267
- - TDD Required: NO
268
- - Reason: "Presentational component - test-alongside OK"
269
- - Workflow: test-alongside
270
- - Confidence: high
271
-
272
- ### Example 5: Database Schema
273
-
274
- **Input:**
275
- - Phase: database
276
- - Task: "Create User table with email, password fields"
277
- - Complexity: simple
278
- - Keywords: schema, table, migration
279
-
280
- **Output:**
281
- - TDD Required: NO
282
- - Reason: "Schema design is declarative - no TDD needed"
283
- - Workflow: none
284
- - Confidence: high
285
-
286
- ---
287
-
288
- ## 🔄 Integration Points
289
-
290
- ### 1. In /csetup Command
291
-
292
- **Step 5: Generate phases.md with TDD metadata**
293
-
294
- For each phase in template:
295
- 1. Get phase info (agent, estimated time)
296
- 2. Extract task description from tasks.md
297
- 3. Extract keywords from description
298
- 4. Estimate complexity using scoring system
299
- 5. Classify TDD using rules above
300
- 6. Write phase with TDD metadata to phases.md
301
-
302
- ### 2. In /cdev Command
303
-
304
- **Step 3: Build agent prompt with TDD requirement**
305
-
306
- Read current phase from phases.md:
307
- - If `TDD | YES` found in phase metadata:
308
- - Add TDD requirement to agent prompt:
309
- ```
310
- ⚠️ TDD REQUIRED FOR THIS PHASE
311
-
312
- Workflow: {tdd_workflow}
313
- Reason: {tdd_reason}
314
-
315
- You MUST follow RED-GREEN-REFACTOR:
316
- 1. Write tests FIRST (they should fail)
317
- 2. Write minimal implementation
318
- 3. Refactor while keeping tests green
319
-
320
- Your first response MUST show RED phase (failing tests).
321
- ```
322
-
323
- ### 3. In Validation
324
-
325
- **Check TDD compliance in pre-work validation**
326
-
327
- If phase has `TDD | YES`:
328
- - Required items:
329
- - "TDD Workflow"
330
- - "RED-GREEN-REFACTOR"
331
- - "RED Phase: Tests written and failing" (for backend)
332
-
333
- ---
334
-
335
- ## 🎯 Benefits
336
-
337
- ✅ **Consistent TDD decisions** - No guessing, automated
338
- ✅ **Clear guidance for agents** - TDD metadata in phases.md
339
- ✅ **Enforced by validation** - Agents can't skip TDD when required
340
- ✅ **Flexible** - Test-alongside still allowed for simple tasks
341
- ✅ **Auditable** - TDD reason documented in phases.md
342
-
343
- ---
344
-
345
- **This classification ensures TDD is used WHERE it matters, not EVERYWHERE!** 🎯
1
+ # TDD Classification Logic
2
+
3
+ > **Automatically determines which phases require TDD workflow**
4
+
5
+ ---
6
+
7
+ ## 🎯 Purpose
8
+
9
+ Provides logic to classify tasks and determine whether they require TDD (Test-Driven Development) workflow. Ensures consistent TDD decisions across all changes.
10
+
11
+ **Result Format:**
12
+ ```
13
+ TDD Decision:
14
+ required: true/false
15
+ reason: "Why TDD is/isn't required"
16
+ workflow: "red-green-refactor" | "test-alongside" | "none"
17
+ confidence: "high" | "medium" | "low"
18
+ ```
19
+
20
+ ---
21
+
22
+ ## 🔍 Classification Rules
23
+
24
+ ### Rule 1: Backend API Endpoints
25
+
26
+ **Always TDD:**
27
+ - Authentication logic (login, register, password, JWT)
28
+ - Authorization logic (permissions, roles, access)
29
+ - Payment processing (Stripe, charges, refunds)
30
+ - Financial calculations
31
+ - Data validation with business rules
32
+ - External API integrations (SendGrid, webhooks)
33
+
34
+ **Test-Alongside OK:**
35
+ - Simple CRUD operations (basic findOne, findMany, create, update, delete)
36
+ - Read-only endpoints with no business logic
37
+ - Health check endpoints
38
+
39
+ ### Rule 2: Frontend UI
40
+
41
+ **TDD Required:**
42
+ - Multi-step forms with complex validation
43
+ - State machines (wizards, checkout flows, onboarding)
44
+ - Complex client-side calculations
45
+
46
+ **Test-Alongside OK:**
47
+ - Presentational components
48
+ - Simple forms
49
+ - Static pages
50
+
51
+ ### Rule 3: Database
52
+
53
+ **Never TDD:**
54
+ - Schema design
55
+ - Migration files
56
+ - Database setup scripts
57
+
58
+ **Reason:** Schemas are declarative, not imperative logic
59
+
60
+ ### Rule 4: Integration
61
+
62
+ **Never TDD:**
63
+ - Contract validation (validation itself, not implementation)
64
+ - Report generation
65
+ - Documentation
66
+
67
+ ### Rule 5: Test-Debug
68
+
69
+ **Never TDD:**
70
+ - Test-debug agent writes tests - no TDD needed
71
+
72
+ ---
73
+
74
+ ## 🤖 Classification Logic
75
+
76
+ **Main Claude should follow this logic in `/csetup` when generating phases.md:**
77
+
78
+ ### Step 1: Determine Phase Type
79
+
80
+ Identify agent type from phase:
81
+ - backend, api, endpoint → Backend rules
82
+ - frontend, ui, uxui-frontend → Frontend rules
83
+ - database, schema, migration → Database rules
84
+ - integration, contract, validation → Integration rules
85
+ - test, test-debug → Test rules
86
+
87
+ ### Step 2: Check Critical Keywords (Backend Only)
88
+
89
+ **Critical keywords** (always TDD):
90
+ - auth, login, register, password, token, jwt
91
+ - payment, stripe, charge, refund, transaction
92
+ - permission, role, access, authorization
93
+ - email, notification, sendgrid, sms
94
+ - webhook, callback, integration
95
+ - calculation, formula, compute
96
+ - validation, business rule, constraint
97
+
98
+ **If found:**
99
+ - TDD Required: YES
100
+ - Reason: "Critical backend logic requires TDD for correctness"
101
+ - Workflow: red-green-refactor
102
+ - Confidence: high
103
+
104
+ ### Step 3: Check CRUD Pattern (Backend Only)
105
+
106
+ **CRUD keywords:**
107
+ - list, get, fetch, read, retrieve, view
108
+
109
+ **If simple CRUD:**
110
+ - TDD Required: NO
111
+ - Reason: "Simple CRUD read operation - test-alongside OK"
112
+ - Workflow: test-alongside
113
+ - Confidence: high
114
+
115
+ ### Step 4: Check Complexity
116
+
117
+ **Backend:**
118
+ - Complex → TDD required (red-green-refactor, medium confidence)
119
+ - Medium/Simple → test-alongside OK
120
+
121
+ **Frontend:**
122
+ - Check for complex UI keywords:
123
+ - multi-step, wizard, stepper
124
+ - state machine, workflow
125
+ - validation, form validation
126
+ - calculation, formula
127
+ - checkout, payment form, onboarding
128
+ - If found → TDD required (red-green-refactor, high confidence)
129
+ - Otherwise → test-alongside OK
130
+
131
+ **Database/Integration/Test:**
132
+ - Always NO TDD (workflow: none, high confidence)
133
+
134
+ ---
135
+
136
+ ## 🔧 Complexity Estimation
137
+
138
+ **How to estimate complexity:**
139
+
140
+ 1. **Time-based scoring:**
141
+ - < 30 minutes → +0 points
142
+ - 30-90 minutes → +1 point
143
+ - > 90 minutes → +2 points
144
+
145
+ 2. **Keyword-based scoring:**
146
+ - Contains: multiple, complex, advanced, sophisticated → +1 point
147
+ - Contains: integration, calculation, validation → +1 point
148
+ - Contains: business logic, algorithm, optimization → +1 point
149
+
150
+ 3. **Length-based scoring:**
151
+ - Description > 500 chars → +1 point
152
+ - Description > 10 lines → +1 point
153
+ - Keywords > 5 → +1 point
154
+
155
+ 4. **Classification:**
156
+ - Score ≤ 2 → simple
157
+ - Score 3-5 → medium
158
+ - Score > 5 → complex
159
+
160
+ ---
161
+
162
+ ## 📊 Usage in /csetup
163
+
164
+ **When generating phases.md:**
165
+
166
+ For each phase:
167
+ 1. Extract task description from tasks.md
168
+ 2. Extract keywords from description
169
+ 3. Estimate complexity (time + keywords + length)
170
+ 4. Classify TDD (phase type + keywords + complexity)
171
+ 5. Add TDD metadata to phases.md
172
+
173
+ **Phase metadata includes:**
174
+ ```markdown
175
+ | TDD | YES/NO |
176
+ | TDD Reason | {reason} |
177
+ | TDD Workflow | red-green-refactor / test-alongside / none |
178
+ | Complexity | simple / medium / complex |
179
+ ```
180
+
181
+ ---
182
+
183
+ ## 📝 Phase Metadata Format
184
+
185
+ **Example output in phases.md:**
186
+
187
+ ```markdown
188
+ ## Phase 7: Backend Implementation
189
+
190
+ | Metadata | Value |
191
+ |----------|-------|
192
+ | Phase | Backend Implementation |
193
+ | Agent | backend |
194
+ | TDD | YES |
195
+ | TDD Reason | Critical backend logic requires TDD for correctness |
196
+ | TDD Workflow | red-green-refactor |
197
+ | Complexity | complex |
198
+ | Estimated | 120 minutes |
199
+
200
+ **TDD Required:** ✅ This phase MUST follow RED-GREEN-REFACTOR workflow.
201
+
202
+ **Why TDD:**
203
+ Critical backend logic requires TDD for correctness.
204
+ Detected keywords: auth, login, jwt, validation
205
+
206
+ **Workflow:**
207
+ 1. 🔴 RED: Write tests FIRST (they should fail)
208
+ 2. ✅ GREEN: Write minimal implementation to pass tests
209
+ 3. 🔧 REFACTOR: Improve code quality while keeping tests green
210
+ ```
211
+
212
+ ---
213
+
214
+ ## 🎯 Example Classifications
215
+
216
+ ### Example 1: Authentication Endpoint
217
+
218
+ **Input:**
219
+ - Phase: backend
220
+ - Task: "Implement POST /api/auth/login with JWT token generation"
221
+ - Complexity: complex
222
+ - Keywords: auth, login, jwt, password, validation
223
+
224
+ **Output:**
225
+ - TDD Required: YES
226
+ - Reason: "Critical backend logic requires TDD for correctness"
227
+ - Workflow: red-green-refactor
228
+ - Confidence: high
229
+
230
+ ### Example 2: Simple List Endpoint
231
+
232
+ **Input:**
233
+ - Phase: backend
234
+ - Task: "Implement GET /api/posts to list all posts"
235
+ - Complexity: simple
236
+ - Keywords: get, list, read
237
+
238
+ **Output:**
239
+ - TDD Required: NO
240
+ - Reason: "Simple CRUD read operation - test-alongside OK"
241
+ - Workflow: test-alongside
242
+ - Confidence: high
243
+
244
+ ### Example 3: Multi-Step Form
245
+
246
+ **Input:**
247
+ - Phase: uxui-frontend
248
+ - Task: "Create multi-step checkout wizard with validation"
249
+ - Complexity: complex
250
+ - Keywords: multi-step, wizard, checkout, validation
251
+
252
+ **Output:**
253
+ - TDD Required: YES
254
+ - Reason: "Complex UI state machine requires TDD"
255
+ - Workflow: red-green-refactor
256
+ - Confidence: high
257
+
258
+ ### Example 4: Simple UI Component
259
+
260
+ **Input:**
261
+ - Phase: uxui-frontend
262
+ - Task: "Create a product card component"
263
+ - Complexity: simple
264
+ - Keywords: card, component, display
265
+
266
+ **Output:**
267
+ - TDD Required: NO
268
+ - Reason: "Presentational component - test-alongside OK"
269
+ - Workflow: test-alongside
270
+ - Confidence: high
271
+
272
+ ### Example 5: Database Schema
273
+
274
+ **Input:**
275
+ - Phase: database
276
+ - Task: "Create User table with email, password fields"
277
+ - Complexity: simple
278
+ - Keywords: schema, table, migration
279
+
280
+ **Output:**
281
+ - TDD Required: NO
282
+ - Reason: "Schema design is declarative - no TDD needed"
283
+ - Workflow: none
284
+ - Confidence: high
285
+
286
+ ---
287
+
288
+ ## 🔄 Integration Points
289
+
290
+ ### 1. In /csetup Command
291
+
292
+ **Step 5: Generate phases.md with TDD metadata**
293
+
294
+ For each phase in template:
295
+ 1. Get phase info (agent, estimated time)
296
+ 2. Extract task description from tasks.md
297
+ 3. Extract keywords from description
298
+ 4. Estimate complexity using scoring system
299
+ 5. Classify TDD using rules above
300
+ 6. Write phase with TDD metadata to phases.md
301
+
302
+ ### 2. In /cdev Command
303
+
304
+ **Step 3: Build agent prompt with TDD requirement**
305
+
306
+ Read current phase from phases.md:
307
+ - If `TDD | YES` found in phase metadata:
308
+ - Add TDD requirement to agent prompt:
309
+ ```
310
+ ⚠️ TDD REQUIRED FOR THIS PHASE
311
+
312
+ Workflow: {tdd_workflow}
313
+ Reason: {tdd_reason}
314
+
315
+ You MUST follow RED-GREEN-REFACTOR:
316
+ 1. Write tests FIRST (they should fail)
317
+ 2. Write minimal implementation
318
+ 3. Refactor while keeping tests green
319
+
320
+ Your first response MUST show RED phase (failing tests).
321
+ ```
322
+
323
+ ### 3. In Validation
324
+
325
+ **Check TDD compliance in pre-work validation**
326
+
327
+ If phase has `TDD | YES`:
328
+ - Required items:
329
+ - "TDD Workflow"
330
+ - "RED-GREEN-REFACTOR"
331
+ - "RED Phase: Tests written and failing" (for backend)
332
+
333
+ ---
334
+
335
+ ## 🎯 Benefits
336
+
337
+ ✅ **Consistent TDD decisions** - No guessing, automated
338
+ ✅ **Clear guidance for agents** - TDD metadata in phases.md
339
+ ✅ **Enforced by validation** - Agents can't skip TDD when required
340
+ ✅ **Flexible** - Test-alongside still allowed for simple tasks
341
+ ✅ **Auditable** - TDD reason documented in phases.md
342
+
343
+ ---
344
+
345
+ **This classification ensures TDD is used WHERE it matters, not EVERYWHERE!** 🎯