@champpaba/claude-agent-kit 3.0.3 → 3.3.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/.claude/CHANGELOG.md +242 -0
- package/.claude/CLAUDE.md +84 -27
- package/.claude/agents/02-uxui-frontend.md +99 -16
- package/.claude/agents/07-ux-tester.md +307 -108
- package/.claude/agents/_shared/pre-work-checklist.md +57 -9
- package/.claude/commands/cdev.md +466 -457
- package/.claude/commands/csetup.md +227 -1791
- package/.claude/contexts/patterns/tdd-classification.md +1 -1
- package/.claude/lib/README.md +11 -3
- package/.claude/lib/design-validator.md +330 -0
- package/.claude/lib/detailed-guides/taskmaster-analysis.md +1 -1
- package/.claude/lib/task-analyzer.md +144 -0
- package/.claude/lib/tdd-workflow.md +2 -1
- package/package.json +1 -1
- package/.claude/lib/tdd-classifier.md +0 -345
|
@@ -104,7 +104,7 @@ Classify tasks to determine if Test-Driven Development (TDD) is required, regard
|
|
|
104
104
|
- Transactions, financial operations
|
|
105
105
|
- Audit logging
|
|
106
106
|
|
|
107
|
-
**Keywords:** auth, authenticate, authorize, JWT, OAuth, encrypt, decrypt, hash, sign, permission, access control, transaction, rollback, commit, audit
|
|
107
|
+
**Keywords:** auth, authenticate, authorize, JWT, OAuth, session, encrypt, decrypt, hash, sign, permission, access control, transaction, rollback, commit, audit
|
|
108
108
|
|
|
109
109
|
**Examples:**
|
|
110
110
|
```
|
package/.claude/lib/README.md
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
**`agent-executor.md`** - Agent retry & escalation logic
|
|
11
11
|
Used by `/cdev` to execute agents with automatic retry, validation, and user escalation
|
|
12
12
|
|
|
13
|
-
**`
|
|
14
|
-
Used by `/csetup` to
|
|
13
|
+
**`task-analyzer.md`** - Task analysis with TDD classification (v3.1.0)
|
|
14
|
+
Used by `/csetup` to analyze tasks and determine TDD requirements. Step 2.6 contains TDD classification logic.
|
|
15
15
|
|
|
16
16
|
**`flags-updater.md`** - Progress tracking protocol
|
|
17
17
|
Ensures Main Claude updates flags.json after EVERY phase completion. Provides helper functions for extracting files, tasks, and calculating duration.
|
|
@@ -19,6 +19,14 @@ Ensures Main Claude updates flags.json after EVERY phase completion. Provides he
|
|
|
19
19
|
**`agent-router.md`** - Agent routing rules
|
|
20
20
|
Defines agent boundaries. Main Claude delegates implementation work to specialized agents. Includes work type detection patterns and self-check protocol.
|
|
21
21
|
|
|
22
|
+
**`design-validator.md`** - Design system validation (v3.3.0 NEW!)
|
|
23
|
+
Single Source of Truth for design compliance. Contains:
|
|
24
|
+
- Part 1: Design token loading protocol
|
|
25
|
+
- Part 2: Pre-work validation (uxui-frontend)
|
|
26
|
+
- Part 3: Post-work validation (ux-tester with Chrome DevTools)
|
|
27
|
+
- Part 4: Main Claude pre-flight checklist
|
|
28
|
+
Used by: Main Claude (/cdev), uxui-frontend agent, ux-tester agent
|
|
29
|
+
|
|
22
30
|
**`validation-gates.md`** - Validation checkpoints
|
|
23
31
|
Four validation gates that Main Claude passes: before work, after agent responds, before reporting, and before phase start. Ensures quality and correctness at each step.
|
|
24
32
|
|
|
@@ -78,4 +86,4 @@ These are **logic specifications** (not executable code). Main Claude reads thes
|
|
|
78
86
|
- `.claude/contexts/patterns/validation-framework.md` - Agent validation checklists
|
|
79
87
|
- `.claude/contexts/patterns/agent-discovery.md` - Agent discovery flow
|
|
80
88
|
- `.claude/commands/cdev.md` - How /cdev uses agent-executor.md
|
|
81
|
-
- `.claude/commands/csetup.md` - How /csetup uses
|
|
89
|
+
- `.claude/commands/csetup.md` - How /csetup uses task-analyzer.md
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# Design Validator
|
|
2
|
+
|
|
3
|
+
> **Version:** 1.1.0 - Imperative Instructions (No Pseudocode)
|
|
4
|
+
> **Purpose:** Single Source of Truth for Design System Validation
|
|
5
|
+
> **Used by:** Main Claude, uxui-frontend, ux-tester
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
This file defines **mandatory steps** for design system compliance.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
PREVENTION (Before Implementation)
|
|
15
|
+
├── Main Claude: Pre-Flight Check before invoking uxui-frontend
|
|
16
|
+
└── uxui-frontend: STEP 0.5 - Read data.yaml, report tokens
|
|
17
|
+
|
|
18
|
+
DETECTION (After Implementation)
|
|
19
|
+
└── ux-tester: Step 5.5 - Chrome DevTools style comparison
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Part 1: Design Token Locations
|
|
25
|
+
|
|
26
|
+
**Primary source (project-specific):**
|
|
27
|
+
```
|
|
28
|
+
design-system/data.yaml
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Fallback (universal principles):**
|
|
32
|
+
```
|
|
33
|
+
.claude/contexts/design/*.md
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Page-specific plan:**
|
|
37
|
+
```
|
|
38
|
+
openspec/changes/{changeId}/page-plan.md
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Part 2: Main Claude Pre-Flight Check
|
|
44
|
+
|
|
45
|
+
**เมื่อไหร่ต้องทำ:** ก่อน invoke uxui-frontend หรือ frontend agent ทุกครั้ง
|
|
46
|
+
|
|
47
|
+
**ขั้นตอนที่ต้องทำ:**
|
|
48
|
+
|
|
49
|
+
### 2.1 ตรวจสอบว่ามี design system หรือไม่
|
|
50
|
+
|
|
51
|
+
อ่านไฟล์ `design-system/data.yaml`
|
|
52
|
+
|
|
53
|
+
**ถ้ามีไฟล์:**
|
|
54
|
+
```
|
|
55
|
+
✅ Design system found: design-system/data.yaml
|
|
56
|
+
```
|
|
57
|
+
→ ไปขั้นตอน 2.2
|
|
58
|
+
|
|
59
|
+
**ถ้าไม่มีไฟล์:**
|
|
60
|
+
```
|
|
61
|
+
⚠️ WARNING: No design system found!
|
|
62
|
+
Path: design-system/data.yaml (not found)
|
|
63
|
+
|
|
64
|
+
Options:
|
|
65
|
+
1. Run /designsetup first (recommended)
|
|
66
|
+
2. Continue with fallback design principles
|
|
67
|
+
|
|
68
|
+
Proceeding with fallback...
|
|
69
|
+
```
|
|
70
|
+
→ ไปขั้นตอน 2.3 แต่ใช้ fallback
|
|
71
|
+
|
|
72
|
+
### 2.2 บอก agent ให้อ่าน design system
|
|
73
|
+
|
|
74
|
+
เมื่อ invoke agent ต้องบอกในส่วน prompt ว่า:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
MANDATORY: Read design-system/data.yaml before writing any CSS/Tailwind.
|
|
78
|
+
Report the tokens you loaded before starting implementation.
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 2.3 Verify agent compliance
|
|
82
|
+
|
|
83
|
+
หลัง agent ตอบกลับ ตรวจสอบว่ามี report นี้หรือไม่:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
✅ Design System Loaded
|
|
87
|
+
- Source: design-system/data.yaml
|
|
88
|
+
- Colors: [list]
|
|
89
|
+
- Spacing: [list]
|
|
90
|
+
- Animation: [list]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**ถ้าไม่มี report:** ถาม agent ว่าอ่าน design system หรือยัง
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Part 3: uxui-frontend STEP 0.5 (MANDATORY)
|
|
98
|
+
|
|
99
|
+
**ขั้นตอนที่ agent ต้องทำก่อนเขียน code:**
|
|
100
|
+
|
|
101
|
+
### 3.1 อ่าน design-system/data.yaml
|
|
102
|
+
|
|
103
|
+
อ่านไฟล์ `design-system/data.yaml`
|
|
104
|
+
|
|
105
|
+
**ถ้ามีไฟล์:** จด tokens ต่อไปนี้:
|
|
106
|
+
- colors (primary, secondary, background, foreground, muted, accent)
|
|
107
|
+
- spacing scale (4, 8, 12, 16, 24, 32, 48, 64)
|
|
108
|
+
- animation durations (150ms, 300ms, 500ms เท่านั้น!)
|
|
109
|
+
- shadows (sm, md, lg, xl)
|
|
110
|
+
- borderRadius scale
|
|
111
|
+
|
|
112
|
+
**ถ้าไม่มีไฟล์:**
|
|
113
|
+
```
|
|
114
|
+
⚠️ Design System NOT FOUND
|
|
115
|
+
- Path: design-system/data.yaml (missing)
|
|
116
|
+
- Fallback: Using .claude/contexts/design/*.md
|
|
117
|
+
- Recommendation: Run /designsetup to generate design system
|
|
118
|
+
```
|
|
119
|
+
→ อ่าน `.claude/contexts/design/*.md` แทน
|
|
120
|
+
|
|
121
|
+
### 3.2 Report ก่อนเริ่มเขียน code
|
|
122
|
+
|
|
123
|
+
**ต้อง report นี้ก่อนเขียน CSS/Tailwind ใดๆ:**
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
✅ Design System Loaded (STEP 0.5)
|
|
127
|
+
- Source: design-system/data.yaml
|
|
128
|
+
- Colors: primary=#xxx, secondary=#xxx, background=#xxx, foreground=#xxx
|
|
129
|
+
- Spacing scale: 4, 8, 12, 16, 24, 32, 48, 64
|
|
130
|
+
- Animation durations: 150ms, 300ms, 500ms
|
|
131
|
+
- Shadows: sm, md, lg, xl
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 3.3 กฎการใช้ tokens
|
|
135
|
+
|
|
136
|
+
**ห้ามใช้ (NEVER):**
|
|
137
|
+
|
|
138
|
+
| ห้าม | ตัวอย่าง |
|
|
139
|
+
|------|---------|
|
|
140
|
+
| Hardcoded colors | `#3b82f6`, `rgb(59,130,246)`, `text-blue-500` |
|
|
141
|
+
| Arbitrary spacing | `p-5`, `gap-7`, `m-[13px]`, `p-[22px]` |
|
|
142
|
+
| Random duration | `duration-200`, `duration-250`, `duration-400` |
|
|
143
|
+
| Mixed shadow levels | ใช้ `shadow-sm` ที่หนึ่ง `shadow-xl` ที่อื่น |
|
|
144
|
+
|
|
145
|
+
**ต้องใช้ (ALWAYS):**
|
|
146
|
+
|
|
147
|
+
| ใช้ | ตัวอย่าง |
|
|
148
|
+
|-----|---------|
|
|
149
|
+
| Theme colors | `bg-primary`, `text-foreground`, `bg-muted` |
|
|
150
|
+
| Spacing scale | `p-4`, `p-6`, `gap-8`, `m-16` |
|
|
151
|
+
| Standard durations | `duration-150`, `duration-300`, `duration-500` |
|
|
152
|
+
| Consistent shadows | เลือก level เดียวสำหรับ cards ทั้งหมด |
|
|
153
|
+
|
|
154
|
+
### 3.4 Report หลังเขียน code เสร็จ
|
|
155
|
+
|
|
156
|
+
**ต้อง report การใช้ tokens:**
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
📊 Design Token Usage Report
|
|
160
|
+
Colors used: text-foreground, bg-primary, bg-muted, border-border
|
|
161
|
+
Spacing used: p-4, p-6, p-8, gap-4, gap-8
|
|
162
|
+
Animations: duration-150, duration-300
|
|
163
|
+
Shadows: shadow-md (consistent)
|
|
164
|
+
|
|
165
|
+
✅ All tokens from data.yaml
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**ถ้ามี non-standard values:**
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
📊 Design Token Usage Report
|
|
172
|
+
...
|
|
173
|
+
⚠️ Non-standard values used:
|
|
174
|
+
- p-5 (reason: needed odd spacing for alignment)
|
|
175
|
+
- #custom-color (reason: brand requirement not in data.yaml)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Part 4: ux-tester Step 5.5 Design Compliance Check
|
|
181
|
+
|
|
182
|
+
**เมื่อไหร่ต้องทำ:** หลัง persona testing (Step 5) ก่อน generate final report (Step 6)
|
|
183
|
+
|
|
184
|
+
### 4.1 ตรวจสอบว่ามี data.yaml หรือไม่
|
|
185
|
+
|
|
186
|
+
อ่านไฟล์ `design-system/data.yaml`
|
|
187
|
+
|
|
188
|
+
**ถ้าไม่มี:**
|
|
189
|
+
```
|
|
190
|
+
ℹ️ Skipping design compliance check (no data.yaml)
|
|
191
|
+
```
|
|
192
|
+
→ ข้าม Step 5.5 ไปเลย
|
|
193
|
+
|
|
194
|
+
**ถ้ามี:** ทำขั้นตอนถัดไป
|
|
195
|
+
|
|
196
|
+
### 4.2 Load expected tokens จาก data.yaml
|
|
197
|
+
|
|
198
|
+
จดค่าที่คาดหวัง:
|
|
199
|
+
- Colors ทั้งหมด (พร้อม hex values)
|
|
200
|
+
- Animation durations: 150ms, 300ms, 500ms
|
|
201
|
+
- Spacing scale
|
|
202
|
+
|
|
203
|
+
### 4.3 ใช้ Chrome DevTools ตรวจสอบ
|
|
204
|
+
|
|
205
|
+
**ขั้นตอน:**
|
|
206
|
+
|
|
207
|
+
1. Navigate ไปหน้าที่ต้องการตรวจ:
|
|
208
|
+
```
|
|
209
|
+
mcp__chrome-devtools__navigate_page({ url: "http://localhost:xxxx" })
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
2. Take snapshot เพื่อดู DOM และ styles:
|
|
213
|
+
```
|
|
214
|
+
mcp__chrome-devtools__take_snapshot()
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
3. ดู elements หลักๆ:
|
|
218
|
+
- buttons (สี, padding, transition)
|
|
219
|
+
- headings (font-size, color)
|
|
220
|
+
- cards (shadow, border-radius, padding)
|
|
221
|
+
- links (color, hover states)
|
|
222
|
+
|
|
223
|
+
4. เปรียบเทียบกับ tokens ที่คาดหวัง
|
|
224
|
+
|
|
225
|
+
### 4.4 บันทึก violations ที่พบ
|
|
226
|
+
|
|
227
|
+
**ตัวอย่าง violations:**
|
|
228
|
+
|
|
229
|
+
| Element | Property | Actual | Expected |
|
|
230
|
+
|---------|----------|--------|----------|
|
|
231
|
+
| button.cta | background-color | #3b82f6 | primary: #2563eb |
|
|
232
|
+
| .card | transition-duration | 200ms | 150ms หรือ 300ms หรือ 500ms |
|
|
233
|
+
| h1.hero | font-size | 52px | 48px (max in scale) |
|
|
234
|
+
|
|
235
|
+
### 4.5 เพิ่มใน ux-test-report.md
|
|
236
|
+
|
|
237
|
+
**เพิ่ม section นี้ใน report:**
|
|
238
|
+
|
|
239
|
+
```markdown
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## 📐 Design Compliance Check
|
|
243
|
+
|
|
244
|
+
> Validated against: design-system/data.yaml
|
|
245
|
+
|
|
246
|
+
### Summary
|
|
247
|
+
|
|
248
|
+
| Category | Compliant | Violations | Status |
|
|
249
|
+
|----------|-----------|------------|--------|
|
|
250
|
+
| Colors | 15 | 2 | ⚠️ |
|
|
251
|
+
| Spacing | 20 | 0 | ✅ |
|
|
252
|
+
| Animation | 5 | 3 | ❌ |
|
|
253
|
+
|
|
254
|
+
### Violations Found
|
|
255
|
+
|
|
256
|
+
| Element | Property | Actual | Expected |
|
|
257
|
+
|---------|----------|--------|----------|
|
|
258
|
+
| button.cta | background | #3b82f6 | #2563eb (primary) |
|
|
259
|
+
| .card | duration | 200ms | 150/300/500ms |
|
|
260
|
+
|
|
261
|
+
### Quick Fixes
|
|
262
|
+
|
|
263
|
+
1. **button.cta**
|
|
264
|
+
- เปลี่ยนจาก `bg-blue-500` → `bg-primary`
|
|
265
|
+
|
|
266
|
+
2. **.card transition**
|
|
267
|
+
- เปลี่ยนจาก `duration-200` → `duration-150`
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Part 5: Quick Reference Checklist
|
|
275
|
+
|
|
276
|
+
### For Main Claude
|
|
277
|
+
|
|
278
|
+
Before invoking uxui-frontend or frontend:
|
|
279
|
+
|
|
280
|
+
- [ ] Check if `design-system/data.yaml` exists
|
|
281
|
+
- [ ] If exists: Tell agent to read it and report tokens
|
|
282
|
+
- [ ] If not exists: Warn user, suggest /designsetup
|
|
283
|
+
- [ ] After agent responds: Verify token report exists
|
|
284
|
+
|
|
285
|
+
### For uxui-frontend
|
|
286
|
+
|
|
287
|
+
Before writing any CSS/Tailwind:
|
|
288
|
+
|
|
289
|
+
- [ ] Read `design-system/data.yaml`
|
|
290
|
+
- [ ] Report loaded tokens (colors, spacing, animation, shadows)
|
|
291
|
+
- [ ] Use ONLY tokens from data.yaml
|
|
292
|
+
- [ ] NO hardcoded colors (#xxx)
|
|
293
|
+
- [ ] NO arbitrary spacing (p-5, gap-7)
|
|
294
|
+
- [ ] NO random durations (only 150/300/500ms)
|
|
295
|
+
|
|
296
|
+
After implementation:
|
|
297
|
+
|
|
298
|
+
- [ ] Report token usage
|
|
299
|
+
- [ ] List any non-standard values with reasons
|
|
300
|
+
|
|
301
|
+
### For ux-tester
|
|
302
|
+
|
|
303
|
+
After persona testing:
|
|
304
|
+
|
|
305
|
+
- [ ] Check if `design-system/data.yaml` exists
|
|
306
|
+
- [ ] If exists: Load expected tokens
|
|
307
|
+
- [ ] Use Chrome DevTools to check computed styles
|
|
308
|
+
- [ ] Compare actual vs expected
|
|
309
|
+
- [ ] Add compliance section to ux-test-report.md
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## Common Violations and Fixes
|
|
314
|
+
|
|
315
|
+
| Violation | Bad | Good |
|
|
316
|
+
|-----------|-----|------|
|
|
317
|
+
| Hardcoded color | `bg-blue-500`, `#3b82f6` | `bg-primary` |
|
|
318
|
+
| Arbitrary spacing | `p-5`, `gap-7` | `p-4`, `p-6`, `gap-8` |
|
|
319
|
+
| Wrong duration | `duration-200` | `duration-150` or `duration-300` |
|
|
320
|
+
| Inconsistent shadow | `shadow-sm` here, `shadow-xl` there | `shadow-md` everywhere |
|
|
321
|
+
| Non-scale font | `text-[52px]` | `text-5xl` (48px) |
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## See Also
|
|
326
|
+
|
|
327
|
+
- `.claude/agents/02-uxui-frontend.md` - Agent file (STEP 0.5)
|
|
328
|
+
- `.claude/agents/07-ux-tester.md` - Agent file (Step 5.5)
|
|
329
|
+
- `.claude/commands/cdev.md` - Main Claude workflow
|
|
330
|
+
- `design-system/data.yaml` - Design tokens source
|
|
@@ -260,4 +260,4 @@ User: "Build login system"
|
|
|
260
260
|
|
|
261
261
|
- `../../commands/csetup.md` - /csetup command (uses TaskMaster)
|
|
262
262
|
- `../task-analyzer.md` - Complete analysis logic implementation
|
|
263
|
-
- `../
|
|
263
|
+
- `../task-analyzer.md` Step 2.6 - TDD classification logic (integrated with task analysis)
|
|
@@ -157,6 +157,150 @@ Determine if this task needs milestone-based execution:
|
|
|
157
157
|
- Low risk, low complexity
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
+
### 2.6 TDD Classification (v3.1.0)
|
|
161
|
+
|
|
162
|
+
> **Source:** Uses patterns from `@/.claude/contexts/patterns/tdd-classification.md`
|
|
163
|
+
> **Purpose:** Determine if task requires TDD (Test-Driven Development) workflow
|
|
164
|
+
|
|
165
|
+
**Classification Algorithm:**
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
function classifyTDD(task: AnalyzedTask): TDDClassification {
|
|
169
|
+
const description = task.description.toLowerCase()
|
|
170
|
+
const agent = task.agent
|
|
171
|
+
|
|
172
|
+
// Rule 1: Database/Integration/Test agents → Never TDD
|
|
173
|
+
if (['database', 'integration', 'test-debug'].includes(agent)) {
|
|
174
|
+
return {
|
|
175
|
+
tdd_required: false,
|
|
176
|
+
workflow: 'none',
|
|
177
|
+
reason: 'Schema/validation work is declarative - no TDD needed'
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Rule 2: Critical Backend Patterns → Always TDD
|
|
182
|
+
const CRITICAL_PATTERNS = [
|
|
183
|
+
// Security operations
|
|
184
|
+
/\b(auth|login|register|password|token|jwt|oauth|session)\b/i,
|
|
185
|
+
/\b(encrypt|decrypt|hash|sign|permission|access.*control)\b/i,
|
|
186
|
+
|
|
187
|
+
// Financial operations
|
|
188
|
+
/\b(payment|stripe|paypal|charge|refund|transaction)\b/i,
|
|
189
|
+
/\b(calculate|compute|discount|pricing|tax|fee)\b/i,
|
|
190
|
+
|
|
191
|
+
// External integrations
|
|
192
|
+
/\b(webhook|callback|external.*api|third-party)\b/i,
|
|
193
|
+
/\b(sendgrid|twilio|s3|analytics)\b/i,
|
|
194
|
+
|
|
195
|
+
// Data transformations
|
|
196
|
+
/\b(serialize|deserialize|transform|convert|parse|etl)\b/i,
|
|
197
|
+
/\b(validate|verify|check|business.*rule)\b/i
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
for (const pattern of CRITICAL_PATTERNS) {
|
|
201
|
+
if (pattern.test(description)) {
|
|
202
|
+
return {
|
|
203
|
+
tdd_required: true,
|
|
204
|
+
workflow: 'red-green-refactor',
|
|
205
|
+
reason: `Critical pattern matched: ${pattern.source}`,
|
|
206
|
+
confidence: 'high'
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Rule 3: Complex UI Patterns → TDD Required
|
|
212
|
+
if (agent === 'uxui-frontend' || agent === 'frontend') {
|
|
213
|
+
const COMPLEX_UI_PATTERNS = [
|
|
214
|
+
/\b(multi-step|wizard|stepper|checkout)\b/i,
|
|
215
|
+
/\b(state.*machine|workflow|onboarding)\b/i,
|
|
216
|
+
/\b(keyboard.*navigation|accessibility|aria)\b/i,
|
|
217
|
+
/\b(dynamic.*form|conditional.*field)\b/i
|
|
218
|
+
]
|
|
219
|
+
|
|
220
|
+
for (const pattern of COMPLEX_UI_PATTERNS) {
|
|
221
|
+
if (pattern.test(description)) {
|
|
222
|
+
return {
|
|
223
|
+
tdd_required: true,
|
|
224
|
+
workflow: 'red-green-refactor',
|
|
225
|
+
reason: 'Complex UI logic requires TDD',
|
|
226
|
+
confidence: 'high'
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Simple UI → No TDD
|
|
232
|
+
return {
|
|
233
|
+
tdd_required: false,
|
|
234
|
+
workflow: 'test-alongside',
|
|
235
|
+
reason: 'Presentational component - test-alongside OK'
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Rule 4: Backend with Risk/Complexity threshold
|
|
240
|
+
if (agent === 'backend') {
|
|
241
|
+
// Simple CRUD reads → No TDD
|
|
242
|
+
if (/\b(get|list|fetch|read|retrieve|view)\b/i.test(description) &&
|
|
243
|
+
!CRITICAL_PATTERNS.some(p => p.test(description))) {
|
|
244
|
+
return {
|
|
245
|
+
tdd_required: false,
|
|
246
|
+
workflow: 'test-alongside',
|
|
247
|
+
reason: 'Simple CRUD read operation'
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Complex backend → TDD
|
|
252
|
+
if (task.complexity >= 7 || task.risk === 'HIGH') {
|
|
253
|
+
return {
|
|
254
|
+
tdd_required: true,
|
|
255
|
+
workflow: 'red-green-refactor',
|
|
256
|
+
reason: `High complexity (${task.complexity}) or risk (${task.risk})`,
|
|
257
|
+
confidence: 'medium'
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Default: No TDD required
|
|
263
|
+
return {
|
|
264
|
+
tdd_required: false,
|
|
265
|
+
workflow: 'test-alongside',
|
|
266
|
+
reason: 'Standard task - test-alongside OK',
|
|
267
|
+
confidence: 'low'
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Output Format (added to task analysis):**
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
interface TDDClassification {
|
|
276
|
+
tdd_required: boolean
|
|
277
|
+
workflow: 'red-green-refactor' | 'test-alongside' | 'none'
|
|
278
|
+
reason: string
|
|
279
|
+
confidence?: 'high' | 'medium' | 'low'
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Added to each AnalyzedTask:
|
|
283
|
+
task.tdd = classifyTDD(task)
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**phases.md Output:**
|
|
287
|
+
|
|
288
|
+
When `tdd_required: true`, phases.md includes:
|
|
289
|
+
|
|
290
|
+
```markdown
|
|
291
|
+
## Phase N: Backend Implementation
|
|
292
|
+
|
|
293
|
+
**Agent:** backend
|
|
294
|
+
**TDD Required:** ✅ YES
|
|
295
|
+
**TDD Reason:** Critical pattern matched: auth/login/jwt
|
|
296
|
+
**TDD Workflow:** red-green-refactor
|
|
297
|
+
|
|
298
|
+
⚠️ **TDD WORKFLOW REQUIRED:**
|
|
299
|
+
1. 🔴 RED: Write tests FIRST (they should fail)
|
|
300
|
+
2. ✅ GREEN: Write minimal implementation to pass tests
|
|
301
|
+
3. 🔧 REFACTOR: Improve code quality while keeping tests green
|
|
302
|
+
```
|
|
303
|
+
|
|
160
304
|
---
|
|
161
305
|
|
|
162
306
|
### Step 3: Auto-Add Best Practices
|
|
@@ -885,7 +885,8 @@ Before starting TDD workflow:
|
|
|
885
885
|
|
|
886
886
|
## 🔗 See Also
|
|
887
887
|
|
|
888
|
-
- `
|
|
888
|
+
- `task-analyzer.md` Step 2.6 - TDD classification logic (integrated with task analysis)
|
|
889
|
+
- `@/.claude/contexts/patterns/tdd-classification.md` - Full TDD classification patterns
|
|
889
890
|
- `validation-framework.md` - Agent validation requirements
|
|
890
891
|
- `context-loading-protocol.md` - How agents load testing frameworks
|
|
891
892
|
- `contexts/patterns/testing.md` - General testing patterns
|