@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.
@@ -5,6 +5,248 @@
5
5
 
6
6
  ---
7
7
 
8
+ ## v3.3.0: Design Validation System (No Pseudocode)
9
+
10
+ **Problem Solved:** Design system compliance was not enforced. uxui-frontend agents didn't read `design-system/data.yaml`, resulting in hardcoded colors, arbitrary spacing, and inconsistent animations. The validation logic was written as TypeScript pseudocode that Claude never executed.
11
+
12
+ **Solution:** Created a single source of truth (`design-validator.md`) with imperative Thai/English instructions. Converted all procedural pseudocode to step-by-step commands that Claude follows.
13
+
14
+ ### Key Changes
15
+
16
+ | Component | Before | After |
17
+ |-----------|--------|-------|
18
+ | design-validator.md | Did not exist | NEW - Single source of truth |
19
+ | cdev.md Step 2-5 | TypeScript pseudocode | Imperative instructions |
20
+ | ux-tester.md Steps 2-5 | TypeScript pseudocode | Imperative instructions |
21
+ | uxui-frontend STEP 0.5 | Brief mention | Full step-by-step protocol |
22
+
23
+ ### Design Validation Flow
24
+
25
+ ```
26
+ PREVENTION (Before Implementation)
27
+ ├── Main Claude: Pre-Flight Check before invoking uxui-frontend
28
+ └── uxui-frontend: STEP 0.5 - Read data.yaml, report tokens
29
+
30
+ DETECTION (After Implementation)
31
+ └── ux-tester: Step 5.5 - Chrome DevTools style comparison
32
+ ```
33
+
34
+ ### What Gets Validated
35
+
36
+ | Token Category | Violation Example | Expected |
37
+ |----------------|-------------------|----------|
38
+ | Colors | #3b82f6, text-blue-500 | bg-primary, text-foreground |
39
+ | Spacing | p-5, gap-7 | p-4, p-6, gap-8 (scale) |
40
+ | Animation | duration-200 | duration-150, 300, 500ms |
41
+ | Shadows | mixed sm+xl | consistent level |
42
+
43
+ ### Files Changed
44
+
45
+ | File | Change |
46
+ |------|--------|
47
+ | `.claude/lib/design-validator.md` | NEW - Single source of truth |
48
+ | `.claude/agents/02-uxui-frontend.md` | v2.1.0 - Enhanced STEP 0.5 |
49
+ | `.claude/agents/07-ux-tester.md` | v1.1.0 - Steps 2-5 rewritten |
50
+ | `.claude/commands/cdev.md` | Steps 2-5 rewritten, Step 4.0 added |
51
+ | `.claude/lib/README.md` | Added design-validator.md entry |
52
+ | `.claude/CLAUDE.md` | v3.3.0 + Design Validation section |
53
+
54
+ ### Why This Matters
55
+
56
+ **Before:**
57
+ - Logic scattered across 4 files
58
+ - TypeScript pseudocode that Claude ignored
59
+ - No enforcement of design tokens
60
+ - ux-tester couldn't validate actual CSS
61
+
62
+ **After:**
63
+ - Single source of truth (design-validator.md)
64
+ - Imperative instructions Claude follows
65
+ - Pre-flight check before visual agents
66
+ - Chrome DevTools validation of computed styles
67
+
68
+ ---
69
+
70
+ ## v3.2.0: Consolidated Pre-Work Context
71
+
72
+ **Problem Solved:** `/csetup` generated two separate pseudocode outputs (`research-checklist.md` and `INTEGRATION_RISKS.md`) that were never actually created. Agents had to discover context from multiple scattered sources.
73
+
74
+ **Solution:** Consolidated all agent context into a single `pre-work-context.md` file with direct execution instructions. Merged Step 2.7 (Best Practices) into Step 2.6.
75
+
76
+ ### Key Changes
77
+
78
+ | Component | Before | After |
79
+ |-----------|--------|-------|
80
+ | Step 2.6 | ~1000 lines of pseudocode | ~300 lines of direct instructions |
81
+ | Step 2.7 | Separate best practices step | Merged into Step 2.6 |
82
+ | Output files | research-checklist.md + INTEGRATION_RISKS.md + best-practices/*.md | Single `pre-work-context.md` |
83
+ | Agent discovery | Multiple files to read | One file with all context |
84
+
85
+ ### Step 2.6 Structure (New - v3.2.0)
86
+
87
+ ```
88
+ Step 2.6.1: Analyze Change Characteristics (type, complexity, risk)
89
+ Step 2.6.2: Detect Libraries (from package files + specs)
90
+ Step 2.6.3: Fetch Best Practices via Context7 (direct MCP calls)
91
+ Step 2.6.4: Determine Research Layers (adaptive depth)
92
+ Step 2.6.5: Detect Integration Warnings (cross-library)
93
+ Step 2.6.6: Generate Critical Checklist Items (security/compliance)
94
+ Step 2.6.7: Write pre-work-context.md (single consolidated file)
95
+ Step 2.6.8: Output Summary
96
+ Step 2.6.9: Skip Conditions
97
+ ```
98
+
99
+ ### pre-work-context.md Structure
100
+
101
+ ```markdown
102
+ # Pre-Work Context: {changeId}
103
+
104
+ ## 1. Change Analysis (type, complexity, risk)
105
+ ## 2. Library Best Practices (from Context7)
106
+ ## 3. Research Findings (domain knowledge)
107
+ ## 4. Integration Warnings (cross-library concerns)
108
+ ## 5. Critical Checklist (security/compliance must-haves)
109
+ ## 6. Quick Reference (package manager, commands)
110
+ ```
111
+
112
+ ### Agent Pre-Work Checklist Update
113
+
114
+ **Version:** 3.0.0 (Pre-Work Context Integration)
115
+
116
+ - Step 0: Read pre-work-context.md (NEW - primary source)
117
+ - Step 0.1: Library Requirements Check (fallback)
118
+ - Step 0.2: Library Feasibility Validation (was 0.5)
119
+ - Step 0.3: Memory Context Query (was 0.6)
120
+
121
+ ### Files Changed
122
+
123
+ | File | Change |
124
+ |------|--------|
125
+ | `csetup.md` | Rewrote Step 2.6 with direct execution |
126
+ | `csetup.md` | Removed Step 2.7 (merged into 2.6) |
127
+ | `csetup.md` | Renumbered Step 2.8 → Step 2.7 |
128
+ | `pre-work-checklist.md` | Added Step 0 (read pre-work-context.md) |
129
+ | `pre-work-checklist.md` | Renumbered steps (0.5→0.2, 0.6→0.3) |
130
+ | `CLAUDE.md` | Updated to v3.2.0 |
131
+
132
+ ### Why This Matters
133
+
134
+ **Before:**
135
+ - Agents had to read 5+ files to get context
136
+ - research-checklist.md was pseudocode that never executed
137
+ - INTEGRATION_RISKS.md was pseudocode that never executed
138
+ - Context was scattered and inconsistent
139
+
140
+ **After:**
141
+ - Agents read ONE file (`pre-work-context.md`) in STEP 0
142
+ - All context is consolidated and actually generated
143
+ - Main Claude follows direct instructions (not pseudocode)
144
+ - Integration warnings + checklist items in one place
145
+
146
+ ---
147
+
148
+ ## v3.1.1: Direct Best Practices Execution
149
+
150
+ **Problem Solved:** Step 2.7 (Auto-Setup Best Practices) was written as pseudocode with helper functions (`extractLibrariesSemantically`, `parseContext7Response`, etc.) that Main Claude never actually executed. Best practices files were documented but never created.
151
+
152
+ **Solution:** Rewrote Step 2.7 as direct, executable instructions that Main Claude can follow. No more pseudocode - just clear steps with actual MCP tool names.
153
+
154
+ ### Key Changes
155
+
156
+ | Component | Before | After |
157
+ |-----------|--------|-------|
158
+ | Step 2.7 | ~1000 lines of pseudocode | ~130 lines of direct instructions |
159
+ | Helper functions | 6 fake functions | Removed entirely |
160
+ | MCP tool calls | Written as code syntax | Written as clear instructions |
161
+ | Output format | Complex extraction logic | Simple template |
162
+
163
+ ### Step 2.7 Structure (New)
164
+
165
+ ```
166
+ Step 2.7.1: Detect Libraries (from package.json, requirements.txt, spec files)
167
+ Step 2.7.2: Resolve via Context7 (call MCP tools directly)
168
+ Step 2.7.3: Create Best Practices Files (using template)
169
+ Step 2.7.4: Create index.md (registry)
170
+ Step 2.7.5: Output Summary
171
+ Step 2.7.6: Skip Conditions
172
+ ```
173
+
174
+ ### Files Changed
175
+
176
+ | File | Change |
177
+ |------|--------|
178
+ | `csetup.md` | Rewrote Step 2.7, removed ~1000 lines of pseudocode |
179
+ | `csetup.md` | Removed helper functions (extractLibrariesSemantically, etc.) |
180
+ | `csetup.md` | Updated detectAdditionalTech as REMOVED |
181
+ | `CLAUDE.md` | Updated version to 3.1.1 |
182
+
183
+ ### Why This Matters
184
+
185
+ Before: Main Claude would read Step 2.7 as documentation and skip it.
186
+ After: Main Claude follows clear instructions and actually calls Context7.
187
+
188
+ ---
189
+
190
+ ## v3.1.0: TDD Classification + Development Principles Injection
191
+
192
+ **Problem Solved:** TDD classification was a simple one-liner (`risk=HIGH || complexity>=7`) that missed critical patterns like auth, payment, and external integrations. Development principles (SOLID, DRY, KISS) were documented but never injected to agents.
193
+
194
+ **Solution:** Comprehensive TDD classification based on `tdd-classification.md` patterns, integrated into `task-analyzer.md` Step 2.6. Development principles injected to ALL agents via `/cdev`.
195
+
196
+ ### Key Changes
197
+
198
+ | Component | Before | After |
199
+ |-----------|--------|-------|
200
+ | TDD classification | 1-line in csetup.md | Full pattern matching in task-analyzer.md |
201
+ | development-principles.md | Listed but not used | Injected to ALL agents via /cdev |
202
+ | tdd-classifier.md | Duplicate file | Deleted (merged into tdd-classification.md) |
203
+
204
+ ### TDD Classification (Step 2.6)
205
+
206
+ Now classifies based on:
207
+
208
+ | Pattern | Examples | TDD Required |
209
+ |---------|----------|--------------|
210
+ | Security operations | auth, jwt, encrypt, permission | ✅ Always |
211
+ | Financial operations | payment, stripe, calculate, tax | ✅ Always |
212
+ | External integrations | webhook, sendgrid, twilio | ✅ Always |
213
+ | Data transformations | serialize, parse, etl | ✅ Always |
214
+ | Complex UI | multi-step, wizard, keyboard-nav | ✅ Always |
215
+ | Simple CRUD reads | get, list, fetch | ❌ Test-alongside OK |
216
+ | Presentational UI | button, card, modal | ❌ No TDD |
217
+ | Database/Integration | schema, migration, validation | ❌ No TDD |
218
+
219
+ ### Development Principles Injection
220
+
221
+ `/cdev` now injects to ALL agent prompts:
222
+
223
+ ```markdown
224
+ ## 🏛️ Development Principles (Level 1 - ALL Agents)
225
+
226
+ **REQUIRED READING:** @.claude/contexts/patterns/development-principles.md
227
+
228
+ | Principle | Summary |
229
+ |-----------|---------|
230
+ | **KISS** | Choose simple solutions over complex ones |
231
+ | **YAGNI** | Build only what you need now |
232
+ | **SRP** | One responsibility per module |
233
+ | **DRY** | Single source of truth for all knowledge |
234
+ | **Fail Fast** | Detect and raise errors immediately |
235
+ | **Observability** | Log everything that matters |
236
+ ```
237
+
238
+ ### Files Changed
239
+
240
+ | File | Change |
241
+ |------|--------|
242
+ | `task-analyzer.md` | Added Step 2.6 TDD Classification |
243
+ | `csetup.md` | Updated phase generation to use TDD from tasks |
244
+ | `cdev.md` | Added development-principles injection |
245
+ | `tdd-classifier.md` | **DELETED** (merged) |
246
+ | `CLAUDE.md` | Updated references and version |
247
+
248
+ ---
249
+
8
250
  ## v3.0.0: Template-Free Architecture (Task Analyzer v2.0)
9
251
 
10
252
  **Problem Solved:** Phase templates (`phase-templates.json`) were limiting and caused task loss. When `tasks.md` had 5 detailed phases but template had only 2, tasks disappeared. Templates overrode the single source of truth.
package/.claude/CLAUDE.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # CLAUDE.md
2
2
 
3
3
  > **Navigation Hub for AI Agents**
4
- > **Template Version:** 3.0.0 - Template-Free Architecture
5
- > **Latest:** Task Analyzer v2.0 - AI-driven analysis, no keyword matching, auto-add best practices
4
+ > **Template Version:** 3.3.0 - Design Validation System
5
+ > **Latest:** Single Source of Truth for design compliance (prevention + detection)
6
6
 
7
7
  ---
8
8
 
@@ -26,6 +26,7 @@
26
26
  | `README.md` | **Visual design summary** (human-readable) | UI/Frontend phases |
27
27
  | `data.yaml` | Design tokens + psychology (~300 lines) | Quick UI reference |
28
28
  | `page-plan.md` | UI component layout + content strategy | uxui-frontend agent |
29
+ | `pre-work-context.md` | **v3.2.0!** All agent context (best practices, warnings, checklist) | All agents - STEP 0 ✨ |
29
30
  | `phases.md` | Execution plan with agent assignments | All phases |
30
31
  | `flags.json` | Progress tracking | All phases |
31
32
 
@@ -75,6 +76,8 @@ Universal, framework-agnostic template for AI-assisted development.
75
76
  - `@/.claude/contexts/design/index.md` (General design principles - fallback)
76
77
 
77
78
  **Development:**
79
+ - `@/.claude/contexts/patterns/development-principles.md` - **v3.1.0!** SOLID, DRY, KISS, Fail Fast (Level 1 - ALL agents) ✨
80
+ - `@/.claude/contexts/patterns/tdd-classification.md` - TDD workflow classification patterns
78
81
  - `@/.claude/contexts/patterns/task-classification.md` (Agent selection guide)
79
82
  - `@/.claude/contexts/patterns/agent-coordination.md` (When to run agents parallel/sequential)
80
83
  - `@/.claude/contexts/patterns/error-recovery.md` (How agents handle errors & escalate)
@@ -86,7 +89,7 @@ Universal, framework-agnostic template for AI-assisted development.
86
89
  **Project Setup:**
87
90
  - `/extract https://site.com` - Extract design from reference sites
88
91
  - `/designsetup @prd.md` - Interactive design system setup
89
- - `/csetup` - **v3.0.0:** Template-free! AI-driven task analysis, auto-add best practices, incremental milestones
92
+ - `/csetup` - **v3.2.0:** Generates `pre-work-context.md` with best practices, research, warnings, checklists
90
93
 
91
94
  **Page Planning (UI Tasks) - v2.0.0:**
92
95
  - `/pageplan @prd.md @brief.md` - Generate page structure with auto page type detection
@@ -122,30 +125,29 @@ Universal, framework-agnostic template for AI-assisted development.
122
125
  **Implementation Logic:**
123
126
  - `@/.claude/lib/README.md` - Implementation logic overview
124
127
  - `@/.claude/lib/agent-executor.md` - Agent retry & escalation logic (used by /cdev) + Incremental testing execution
125
- - `@/.claude/lib/tdd-classifier.md` - TDD classification logic (used by /csetup)
126
- - `@/.claude/lib/task-analyzer.md` - **v2.0!** Template-free AI-driven task analysis ✨
128
+ - `@/.claude/lib/task-analyzer.md` - **v3.1.0!** Template-free task analysis with TDD classification (Step 2.6)
127
129
  - `@/.claude/lib/flags-updater.md` - Progress tracking protocol (Main Claude updates flags.json)
128
130
  - `@/.claude/lib/agent-router.md` - Mandatory agent routing rules (enforce delegation)
131
+ - `@/.claude/lib/design-validator.md` - **v3.3.0!** Design system validation (prevention + detection) ✨
129
132
  - `@/.claude/contexts/patterns/agent-discovery.md` - Shared agent discovery flow
130
133
 
131
134
  ---
132
135
 
133
- ## 📚 Best Practices System (v2.5.0 - Smart Topic Query)
136
+ ## 📚 Best Practices System (v3.2.0 - Consolidated Pre-Work Context)
134
137
 
135
138
  **Quick Summary:**
136
- - `/csetup` **dynamically detects any library** from spec text + package files (no hardcoded mappings)
137
- - **Works with any language:** JavaScript, Python, Rust, Go, PHP, Ruby - automatically
138
- - **Context7 validates** each potential library name and resolves to official docs
139
- - **v2.5.0:** Smart Topic Query includes other library names for cross-library integration docs
140
- - **v2.5.0:** Auto-generates `INTEGRATION_RISKS.md` with detected concerns
141
- - Files created in `.claude/contexts/domain/project/best-practices/`
142
- - **Agents read** best practices + integration risks before coding
139
+ - `/csetup` generates **single `pre-work-context.md`** with ALL agent context
140
+ - **Consolidates:** Best practices, research findings, integration warnings, critical checklists
141
+ - **Context7 validates** each library and fetches best practices
142
+ - **Agents read ONE file** instead of multiple scattered files
143
+ - **File location:** `openspec/changes/{changeId}/pre-work-context.md`
143
144
 
144
145
  **Key Changes:**
145
146
  | Version | Change |
146
147
  |---------|--------|
147
148
  | v2.3.0 | NLP extraction + Context7 resolution (zero maintenance) |
148
149
  | v2.5.0 | Smart Topic Query + Integration Risk Detection |
150
+ | v3.2.0 | **Consolidated `pre-work-context.md`** (single file for all agent context) |
149
151
 
150
152
  **Detection Sources:**
151
153
  | Source | Examples |
@@ -158,23 +160,22 @@ Universal, framework-agnostic template for AI-assisted development.
158
160
  | PHP | composer.json |
159
161
  | Ruby | Gemfile |
160
162
 
161
- **Flow (v2.5.0):**
163
+ **Flow (v3.2.0):**
162
164
  ```
163
- /csetup → extract potential library names from ALL text sources
164
- Context7 resolve-library-id (validates if real library)
165
- → Context7 get-library-docs (Smart Topic Query with other lib names)
166
- detect integration risks from docs content
167
- generate .md files for each verified library
168
- → generate INTEGRATION_RISKS.md if risks detected
169
- /cdev inject paths into prompt → agent reads → validation checks
165
+ /csetup → analyze change (type, complexity, risk)
166
+ detect libraries from spec + package files
167
+ → Context7 resolve + fetch best practices
168
+ determine research layers
169
+ detect integration warnings
170
+ → generate critical checklist items
171
+ write pre-work-context.md (single file)
172
+ /cdev → agents read pre-work-context.md in STEP 0
170
173
  ```
171
174
 
172
- **Output Files:**
173
- | File | Content |
174
- |------|---------|
175
- | `{lib}.md` | Library best practices with integration info |
176
- | `INTEGRATION_RISKS.md` | Cross-library risks + checklist (if any detected) |
177
- | `index.md` | Registry of all best practices files |
175
+ **Output File:**
176
+ | File | Sections |
177
+ |------|----------|
178
+ | `pre-work-context.md` | 1. Change Analysis, 2. Library Best Practices, 3. Research Findings, 4. Integration Warnings, 5. Critical Checklist, 6. Quick Reference |
178
179
 
179
180
  ---
180
181
 
@@ -212,6 +213,58 @@ Universal, framework-agnostic template for AI-assisted development.
212
213
 
213
214
  ---
214
215
 
216
+ ## 🎯 Design Validation System (v3.3.0 - NEW!)
217
+
218
+ **→ See:** `@/.claude/lib/design-validator.md` for full specification
219
+
220
+ **Problem Solved:**
221
+ - uxui-frontend agent ไม่อ่าน design-system/data.yaml → CSS ไม่ตรง design
222
+ - ux-tester อ่านแค่ code ไม่ได้เห็น actual rendered output
223
+ - Logic กระจายหลายไฟล์ → ไม่มี enforcement
224
+
225
+ **Solution: Single Source of Truth**
226
+
227
+ ```
228
+ ┌─────────────────────────────────────────────────────────────┐
229
+ │ PREVENTION (Pre-Work) │
230
+ ├─────────────────────────────────────────────────────────────┤
231
+ │ Main Claude → Pre-Flight Design Check (before /cdev) │
232
+ │ uxui-frontend → STEP 0.5: Read data.yaml (MANDATORY) │
233
+ └─────────────────────────────────────────────────────────────┘
234
+
235
+ ┌─────────────────────────────────────────────────────────────┐
236
+ │ DETECTION (Post-Work) │
237
+ ├─────────────────────────────────────────────────────────────┤
238
+ │ ux-tester → Chrome DevTools Style Comparison │
239
+ │ Compare computed styles vs data.yaml tokens │
240
+ └─────────────────────────────────────────────────────────────┘
241
+ ```
242
+
243
+ **What Gets Validated:**
244
+
245
+ | Token Category | Example Violation | Expected |
246
+ |----------------|-------------------|----------|
247
+ | Colors | #3b82f6 | bg-primary (from data.yaml) |
248
+ | Spacing | p-5, gap-7 | p-4, p-6, gap-8 (scale) |
249
+ | Animation | duration-200 | duration-150, 300, 500ms |
250
+ | Shadows | mixed sm+xl | consistent level |
251
+
252
+ **Agent Responsibilities:**
253
+
254
+ | Agent | What to Do |
255
+ |-------|------------|
256
+ | Main Claude | Pre-flight check before invoking uxui-frontend |
257
+ | uxui-frontend | STEP 0.5: Read data.yaml, report loaded tokens |
258
+ | ux-tester | Step 5.5: Chrome DevTools validation |
259
+
260
+ **Files Updated:**
261
+ - `.claude/lib/design-validator.md` (NEW - Single Source of Truth)
262
+ - `.claude/agents/02-uxui-frontend.md` (v2.1.0 - references design-validator)
263
+ - `.claude/agents/07-ux-tester.md` (v1.1.0 - Design Compliance Check)
264
+ - `.claude/commands/cdev.md` (Step 4.0 - Pre-Flight Check)
265
+
266
+ ---
267
+
215
268
  ## ⚡ Context Optimization (v2.1.0)
216
269
 
217
270
  **→ See:** `@/.claude/lib/detailed-guides/context-optimization.md` for complete guide
@@ -310,6 +363,10 @@ User: "Build login system"
310
363
  **Recent versions:**
311
364
  | Version | Key Feature |
312
365
  |---------|-------------|
366
+ | v3.3.0 | **Design Validation System** (prevention + detection, single source of truth) |
367
+ | v3.2.0 | Consolidated Pre-Work Context (single `pre-work-context.md` for agents) |
368
+ | v3.1.1 | Direct Best Practices Execution (Step 2.7 rewritten, no pseudocode) |
369
+ | v3.1.0 | TDD Classification + Development Principles Injection |
313
370
  | v3.0.0 | Template-Free Architecture (AI-driven Task Analyzer v2.0) |
314
371
  | v2.8.0 | Critical Flow Injection (auto-inject security/compliance items) |
315
372
  | v2.7.0 | UX Testing Agent (persona-based, approval gate) |
@@ -7,8 +7,9 @@ color: blue
7
7
 
8
8
  # UX-UI Frontend Agent
9
9
 
10
- > **Version:** 2.0.0 (Claude 4.5 Optimized)
10
+ > **Version:** 2.1.0 (Design Validator Integration)
11
11
  > **Role:** Build UI components with mock data. Focus on design quality and accessibility.
12
+ > **Design Validation:** `.claude/lib/design-validator.md` (Part 2)
12
13
 
13
14
  ---
14
15
 
@@ -68,27 +69,97 @@ WHY: UI development shouldn't be blocked by backend availability. Mock data enab
68
69
 
69
70
  → See `.claude/contexts/patterns/agent-discovery.md`
70
71
 
71
- **STEP 0.5: Load Design & Content (uxui-frontend specific)**
72
+ ---
72
73
 
73
- ```bash
74
- # Check for project-specific design tokens
75
- Read: design-system/data.yaml
74
+ ## STEP 0.5: Load Design System (MANDATORY)
75
+
76
+ **Full Protocol:** `.claude/lib/design-validator.md` (Part 3)
77
+
78
+ **ก่อนเขียน CSS/Tailwind ใดๆ ต้องทำขั้นตอนนี้ก่อน:**
79
+
80
+ ### ขั้นตอนที่ 1: อ่าน design-system/data.yaml
81
+
82
+ อ่านไฟล์ `design-system/data.yaml`
83
+
84
+ **ถ้ามีไฟล์:** จดค่าต่อไปนี้:
85
+ - colors: primary, secondary, background, foreground, muted, accent (พร้อม hex values)
86
+ - spacing scale: 4, 8, 12, 16, 24, 32, 48, 64
87
+ - animation durations: **150ms, 300ms, 500ms เท่านั้น!**
88
+ - shadows: sm, md, lg, xl
89
+ - typography: font family, sizes
90
+
91
+ **ถ้าไม่มีไฟล์:**
92
+ ```
93
+ ⚠️ Design System NOT FOUND
94
+ - Path: design-system/data.yaml (missing)
95
+ - Fallback: Using .claude/contexts/design/*.md
96
+ - Recommendation: Run /designsetup to generate design system
97
+ ```
98
+ → อ่าน `.claude/contexts/design/*.md` แทน
99
+
100
+ ### ขั้นตอนที่ 2: อ่าน page-plan.md (ถ้ามี)
101
+
102
+ อ่านไฟล์ `openspec/changes/{change-id}/page-plan.md`
76
103
 
77
- # Check for page plan (from /pageplan command)
78
- Read: openspec/changes/{change-id}/page-plan.md
104
+ **ถ้ามี:**
105
+ - ดู Component reuse list, new components, animation blueprint
106
+ - ข้าม STEP 3 (component search) ไปเลย เพราะ page-plan ทำไว้แล้ว
107
+ - Implement ทุก section ใน Section 2 (Page Structure)
108
+
109
+ ### ขั้นตอนที่ 3: Report ก่อนเริ่มเขียน code
110
+
111
+ **ต้อง report นี้ก่อนเขียน CSS/Tailwind:**
112
+
113
+ ```
114
+ ✅ Design System Loaded (STEP 0.5)
115
+ - Source: design-system/data.yaml
116
+ - Colors: primary=#xxx, secondary=#xxx, background=#xxx, foreground=#xxx
117
+ - Spacing scale: 4, 8, 12, 16, 24, 32, 48, 64
118
+ - Animation durations: 150ms, 300ms, 500ms
119
+ - Shadows: sm, md, lg, xl
79
120
  ```
80
121
 
81
- **Priority order:**
82
- 1. **data.yaml** (project-specific) → Use all tokens, colors, spacing, psychology
83
- 2. **page-plan.md** (if exists) → Use component plan, content draft, animation blueprint
84
- 3. **design/*.md** (fallback) → General design principles
122
+ ### กฎการใช้ Design Tokens
85
123
 
86
- **If page-plan.md exists:**
87
- - Extract: Component reuse list, new components, content draft, animation blueprint (Section 2.6)
88
- - Skip STEP 3 (component search already done)
89
- - Implement ALL sections from Section 2 (Page Structure)
124
+ **ห้ามใช้ (NEVER):**
90
125
 
91
- WHY: page-plan.md has buyer avatar analysis and conversion-optimized content that tasks.md doesn't provide.
126
+ | ห้าม | ตัวอย่าง |
127
+ |------|---------|
128
+ | Hardcoded colors | `#3b82f6`, `rgb(59,130,246)`, `text-blue-500` |
129
+ | Arbitrary spacing | `p-5`, `gap-7`, `m-[13px]`, `p-[22px]` |
130
+ | Random duration | `duration-200`, `duration-250`, `duration-400` |
131
+ | Mixed shadow levels | ใช้ `shadow-sm` ที่หนึ่ง `shadow-xl` ที่อื่น |
132
+
133
+ **ต้องใช้ (ALWAYS):**
134
+
135
+ | ใช้ | ตัวอย่าง |
136
+ |-----|---------|
137
+ | Theme colors | `bg-primary`, `text-foreground`, `bg-muted` |
138
+ | Spacing scale | `p-4`, `p-6`, `gap-8`, `m-16` |
139
+ | Standard durations | `duration-150`, `duration-300`, `duration-500` |
140
+ | Consistent shadows | เลือก level เดียวสำหรับ cards ทั้งหมด |
141
+
142
+ ### ขั้นตอนที่ 4: Report หลังเขียน code เสร็จ
143
+
144
+ **ต้อง report การใช้ tokens ใน output:**
145
+
146
+ ```
147
+ 📊 Design Token Usage Report
148
+ Colors used: text-foreground, bg-primary, bg-muted, border-border
149
+ Spacing used: p-4, p-6, p-8, gap-4, gap-8
150
+ Animations: duration-150, duration-300
151
+ Shadows: shadow-md (consistent)
152
+
153
+ ✅ All tokens from data.yaml
154
+ ```
155
+
156
+ **ถ้ามี non-standard values ต้องบอกเหตุผล:**
157
+
158
+ ```
159
+ ⚠️ Non-standard values used:
160
+ - p-5 (reason: needed odd spacing for alignment)
161
+ - #custom-color (reason: brand requirement not in data.yaml)
162
+ ```
92
163
 
93
164
  ---
94
165
 
@@ -311,9 +382,21 @@ Design:
311
382
  - Shadows: {level}
312
383
  - Accessibility: {features}
313
384
 
385
+ 📊 Design Token Usage Report:
386
+ - Colors used: text-foreground, bg-primary, bg-muted, ...
387
+ - Spacing used: p-4, p-6, gap-8, ...
388
+ - Animations: duration-150, duration-300
389
+ - Shadows: shadow-md
390
+
391
+ ✅ All tokens from data.yaml
392
+ OR
393
+ ⚠️ Non-standard values: {list with reasons}
394
+
314
395
  Next Step: {next task or agent}
315
396
  ```
316
397
 
398
+ **IMPORTANT:** Include token usage report in final output. ux-tester will validate these against data.yaml using Chrome DevTools.
399
+
317
400
  ---
318
401
 
319
402
  ## Handoff to Frontend Agent