claude-code-workflow 6.3.42 → 6.3.44

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 (87) hide show
  1. package/.claude/agents/tdd-developer.md +530 -0
  2. package/.claude/commands/issue/discover-by-prompt.md +5 -1
  3. package/.claude/commands/issue/discover.md +472 -468
  4. package/.claude/commands/issue/execute.md +580 -581
  5. package/.claude/commands/issue/new.md +417 -413
  6. package/.claude/commands/issue/plan.md +11 -13
  7. package/.claude/commands/issue/queue.md +445 -441
  8. package/.claude/commands/task/breakdown.md +207 -203
  9. package/.claude/commands/task/replan.md +440 -436
  10. package/.claude/commands/workflow/action-plan-verify.md +485 -447
  11. package/.claude/commands/workflow/brainstorm/artifacts.md +457 -453
  12. package/.claude/commands/workflow/brainstorm/auto-parallel.md +5 -1
  13. package/.claude/commands/workflow/brainstorm/synthesis.md +402 -398
  14. package/.claude/commands/workflow/clean.md +67 -35
  15. package/.claude/commands/workflow/debug-with-file.md +670 -666
  16. package/.claude/commands/workflow/debug.md +331 -327
  17. package/.claude/commands/workflow/develop-with-file.md +5 -1
  18. package/.claude/commands/workflow/execute.md +546 -498
  19. package/.claude/commands/workflow/lite-execute.md +44 -26
  20. package/.claude/commands/workflow/lite-fix.md +780 -730
  21. package/.claude/commands/workflow/lite-lite-lite.md +5 -1
  22. package/.claude/commands/workflow/lite-plan.md +87 -39
  23. package/.claude/commands/workflow/multi-cli-plan.md +572 -568
  24. package/.claude/commands/workflow/plan-verify.md +527 -0
  25. package/.claude/commands/workflow/plan.md +555 -551
  26. package/.claude/commands/workflow/replan.md +572 -515
  27. package/.claude/commands/workflow/review-fix.md +608 -610
  28. package/.claude/commands/workflow/session/complete.md +37 -14
  29. package/.claude/commands/workflow/session/solidify.md +303 -299
  30. package/.claude/commands/workflow/tdd-plan.md +630 -597
  31. package/.claude/commands/workflow/tdd-verify.md +391 -206
  32. package/.claude/commands/workflow/tools/conflict-resolution.md +24 -12
  33. package/.claude/commands/workflow/tools/task-generate-agent.md +583 -563
  34. package/.claude/commands/workflow/tools/task-generate-tdd.md +749 -517
  35. package/.claude/commands/workflow/ui-design/animation-extract.md +1154 -1150
  36. package/.claude/commands/workflow/ui-design/layout-extract.md +792 -788
  37. package/.claude/commands/workflow/ui-design/style-extract.md +777 -773
  38. package/.claude/skills/ccw/command.json +4 -4
  39. package/.claude/skills/ccw-coordinator/README.md +45 -0
  40. package/.claude/skills/ccw-coordinator/SKILL.md +320 -0
  41. package/.claude/skills/ccw-coordinator/phases/actions/action-abort.md +9 -0
  42. package/.claude/skills/ccw-coordinator/phases/actions/action-command-build.md +40 -0
  43. package/.claude/skills/ccw-coordinator/phases/actions/action-command-execute.md +124 -0
  44. package/.claude/skills/ccw-coordinator/phases/actions/action-command-selection.md +48 -0
  45. package/.claude/skills/ccw-coordinator/phases/actions/action-complete.md +25 -0
  46. package/.claude/skills/ccw-coordinator/phases/actions/action-init.md +26 -0
  47. package/.claude/skills/ccw-coordinator/phases/orchestrator.md +59 -0
  48. package/.claude/skills/ccw-coordinator/phases/state-schema.md +66 -0
  49. package/.claude/skills/ccw-coordinator/skill-config.json +66 -0
  50. package/.claude/skills/ccw-coordinator/specs/command-library.md +169 -0
  51. package/.claude/skills/ccw-coordinator/specs/specs.md +362 -0
  52. package/.claude/skills/ccw-coordinator/tools/README.md +95 -0
  53. package/.claude/skills/ccw-coordinator/tools/chain-validate.cjs +320 -0
  54. package/.claude/skills/ccw-coordinator/tools/command-registry.cjs +255 -0
  55. package/.claude/skills/ccw-help/command.json +5 -5
  56. package/.claude/skills/ccw-help/scripts/analyze_commands.py +337 -337
  57. package/.claude/workflows/cli-templates/prompts/workflow-impl-plan-template.txt +1 -1
  58. package/.codex/skills/parallel-dev-cycle/README.md +19 -16
  59. package/.codex/skills/parallel-dev-cycle/phases/agents/code-developer.md +90 -5
  60. package/.codex/skills/parallel-dev-cycle/phases/agents/requirements-analyst.md +89 -4
  61. package/.codex/skills/parallel-dev-cycle/phases/orchestrator.md +696 -696
  62. package/.codex/skills/parallel-dev-cycle/phases/state-schema.md +436 -436
  63. package/.codex/skills/parallel-dev-cycle/skill.md +194 -0
  64. package/.codex/skills/parallel-dev-cycle/specs/communication-optimization.md +423 -423
  65. package/.codex/skills/parallel-dev-cycle/specs/coordination-protocol.md +31 -16
  66. package/.codex/skills/parallel-dev-cycle/specs/versioning-strategy.md +74 -73
  67. package/ccw/dist/commands/issue.d.ts +4 -0
  68. package/ccw/dist/commands/issue.d.ts.map +1 -1
  69. package/ccw/dist/commands/issue.js +73 -6
  70. package/ccw/dist/commands/issue.js.map +1 -1
  71. package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
  72. package/ccw/dist/core/routes/cli-routes.js +32 -28
  73. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  74. package/ccw/dist/tools/claude-cli-tools.d.ts +10 -0
  75. package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
  76. package/ccw/dist/tools/claude-cli-tools.js +45 -0
  77. package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
  78. package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
  79. package/ccw/dist/tools/codex-lens.js +38 -11
  80. package/ccw/dist/tools/codex-lens.js.map +1 -1
  81. package/ccw/src/commands/issue.ts +84 -6
  82. package/ccw/src/core/routes/cli-routes.ts +30 -25
  83. package/ccw/src/templates/dashboard-js/views/help.js +1 -1
  84. package/ccw/src/tools/claude-cli-tools.ts +50 -0
  85. package/ccw/src/tools/codex-lens.ts +40 -11
  86. package/package.json +1 -1
  87. package/.codex/skills/parallel-dev-cycle/SKILL.md +0 -513
@@ -1,773 +1,777 @@
1
- ---
2
- name: style-extract
3
- description: Extract design style from reference images or text prompts using Claude analysis with variant generation or refinement mode
4
- argument-hint: "[--design-id <id>] [--session <id>] [--images "<glob>"] [--prompt "<desc>"] [--variants <count>] [--interactive] [--refine]"
5
- allowed-tools: TodoWrite(*), Read(*), Write(*), Glob(*), AskUserQuestion(*)
6
- ---
7
-
8
- # Style Extraction Command
9
-
10
- ## Overview
11
- Extract design style from reference images or text prompts using Claude's built-in analysis. Supports two modes:
12
- 1. **Exploration Mode** (default): Generate multiple contrasting design variants
13
- 2. **Refinement Mode** (`--refine`): Refine a single existing design through detailed adjustments
14
-
15
- **Strategy**: AI-Driven Design Space Exploration
16
- - **Claude-Native**: 100% Claude analysis, no external tools
17
- - **Direct Output**: Complete design systems (design-tokens.json)
18
- - **Flexible Input**: Images, text prompts, or both (hybrid mode)
19
- - **Dual Mode**: Exploration (multiple contrasting variants) or Refinement (single design fine-tuning)
20
- - **Production-Ready**: WCAG AA compliant, OKLCH colors, semantic naming
21
-
22
- ## Execution Process
23
-
24
- ```
25
- Input Parsing:
26
- ├─ Parse flags: --design-id, --session, --images, --prompt, --variants, --interactive, --refine
27
- └─ Decision (mode detection):
28
- ├─ --refine flag → Refinement Mode (variants_count = 1)
29
- └─ No --refine → Exploration Mode (variants_count = --variants OR 3)
30
-
31
- Phase 0: Setup & Input Validation
32
- ├─ Step 1: Detect input mode, extraction mode & base path
33
- ├─ Step 2: Load inputs
34
- └─ Step 3: Memory check (skip if exists)
35
-
36
- Phase 1: Design Direction/Refinement Options Generation
37
- ├─ Step 1: Load project context
38
- ├─ Step 2: Generate options (Agent Task 1)
39
- │ └─ Decision:
40
- │ ├─ Exploration Mode Generate contrasting design directions
41
- │ └─ Refinement Mode Generate refinement options
42
- └─ Step 3: Verify options file created
43
-
44
- Phase 1.5: User Confirmation (Optional)
45
- └─ Decision (--interactive flag):
46
- ├─ --interactive present Present options, capture selection
47
- └─ No --interactive → Skip to Phase 2
48
-
49
- Phase 2: Design System Generation
50
- ├─ Step 1: Load user selection or default to all
51
- ├─ Step 2: Create output directories
52
- └─ Step 3: Launch agent tasks (parallel)
53
-
54
- Phase 3: Verify Output
55
- ├─ Step 1: Check files created
56
- └─ Step 2: Verify file sizes
57
- ```
58
-
59
- ## Phase 0: Setup & Input Validation
60
-
61
- ### Step 1: Detect Input Mode, Extraction Mode & Base Path
62
- ```bash
63
- # Detect input source
64
- # Priority: --images + --prompt → hybrid | --images → image | --prompt → text
65
-
66
- # Detect refinement mode
67
- refine_mode = --refine OR false
68
-
69
- # Set variants count
70
- # Refinement mode: Force variants_count = 1 (ignore user-provided --variants)
71
- # Exploration mode: Use --variants or default to 3 (range: 1-5)
72
- IF refine_mode:
73
- variants_count = 1
74
- REPORT: "🔧 Refinement mode enabled: Will generate 1 refined design system"
75
- ELSE:
76
- variants_count = --variants OR 3
77
- VALIDATE: 1 <= variants_count <= 5
78
- REPORT: "🔍 Exploration mode: Will generate {variants_count} contrasting design directions"
79
-
80
- # Determine base path with priority: --design-id > --session > auto-detect
81
- if [ -n "$DESIGN_ID" ]; then
82
- # Exact match by design ID
83
- relative_path=$(find .workflow -name "${DESIGN_ID}" -type d -print -quit)
84
- elif [ -n "$SESSION_ID" ]; then
85
- # Latest in session
86
- relative_path=$(find .workflow/active/WFS-$SESSION_ID -name "design-run-*" -type d -printf "%T@ %p\n" 2>/dev/null | sort -nr | head -1 | cut -d' ' -f2)
87
- else
88
- # Latest globally
89
- relative_path=$(find .workflow -name "design-run-*" -type d -printf "%T@ %p\n" 2>/dev/null | sort -nr | head -1 | cut -d' ' -f2)
90
- fi
91
-
92
- # Validate and convert to absolute path
93
- if [ -z "$relative_path" ] || [ ! -d "$relative_path" ]; then
94
- echo "❌ ERROR: Design run not found"
95
- echo "💡 HINT: Run '/workflow:ui-design:list' to see available design runs"
96
- exit 1
97
- fi
98
-
99
- base_path=$(cd "$relative_path" && pwd)
100
- bash(echo "✓ Base path: $base_path")
101
- ```
102
-
103
- ### Step 2: Load Inputs
104
- ```bash
105
- # For image mode
106
- bash(ls {images_pattern}) # Expand glob pattern
107
- Read({image_path}) # Load each image
108
-
109
- # For text mode
110
- # Validate --prompt is non-empty
111
-
112
- # Create output directory
113
- bash(mkdir -p {base_path}/style-extraction/)
114
- ```
115
-
116
- ### Step 3: Memory Check
117
- ```bash
118
- # 1. Check if inputs cached in session memory
119
- IF session_has_inputs: SKIP Step 2 file reading
120
-
121
- # 2. Check if output already exists
122
- bash(test -f {base_path}/style-extraction/style-1/design-tokens.json && echo "exists")
123
- IF exists: SKIP to completion
124
- ```
125
-
126
- ---
127
-
128
- **Phase 0 Output**: `input_mode`, `base_path`, `extraction_mode`, `variants_count`, `loaded_images[]` or `prompt_guidance`
129
-
130
- ## Phase 1: Design Direction or Refinement Options Generation
131
-
132
- ### Step 1: Load Project Context
133
- ```bash
134
- # Load brainstorming context if available
135
- bash(test -f {base_path}/.brainstorming/role analysis documents && cat it)
136
-
137
- # Load existing design system if refinement mode
138
- IF refine_mode:
139
- existing_tokens = Read({base_path}/style-extraction/style-1/design-tokens.json)
140
- ```
141
-
142
- ### Step 2: Generate Options (Agent Task 1 - Mode-Specific)
143
- **Executor**: `Task(ui-design-agent)`
144
-
145
- **Exploration Mode** (default): Generate contrasting design directions
146
- **Refinement Mode** (`--refine`): Generate refinement options for existing design
147
-
148
- ```javascript
149
- // Conditional agent task based on refine_mode
150
- IF NOT refine_mode:
151
- // EXPLORATION MODE
152
- Task(ui-design-agent): `
153
- [DESIGN_DIRECTION_GENERATION_TASK]
154
- Generate {variants_count} maximally contrasting design directions with visual previews
155
-
156
- SESSION: {session_id} | MODE: explore | BASE_PATH: {base_path}
157
-
158
- ## Input Analysis
159
- - User prompt: {prompt_guidance}
160
- - Visual references: {loaded_images if available}
161
- - Project context: {brainstorming_context if available}
162
-
163
- ## Analysis Rules
164
- - Analyze 6D attribute space: color saturation, visual weight, formality, organic/geometric, innovation, density
165
- - Generate {variants_count} directions with MAXIMUM contrast
166
- - Each direction must be distinctly different (min distance score: 0.7)
167
-
168
- ## Generate for EACH Direction
169
- 1. **Core Philosophy**:
170
- - philosophy_name (2-3 words, e.g., "Minimalist & Airy")
171
- - design_attributes (6D scores 0-1)
172
- - search_keywords (3-5 keywords)
173
- - anti_keywords (2-3 keywords to avoid)
174
- - rationale (why this is distinct from others)
175
-
176
- 2. **Visual Preview Elements**:
177
- - primary_color (OKLCH format)
178
- - secondary_color (OKLCH format)
179
- - accent_color (OKLCH format)
180
- - font_family_heading (specific font name)
181
- - font_family_body (specific font name)
182
- - border_radius_base (e.g., "0.5rem")
183
- - mood_description (1-2 sentences describing the feel)
184
-
185
- ## Output
186
- Write single JSON file: {base_path}/.intermediates/style-analysis/analysis-options.json
187
-
188
- Use schema from INTERACTIVE-DATA-SPEC.md (Style Extract: analysis-options.json)
189
-
190
- CRITICAL: Use Write() tool immediately after generating complete JSON
191
- `
192
- ELSE:
193
- // REFINEMENT MODE
194
- Task(ui-design-agent): `
195
- [DESIGN_REFINEMENT_OPTIONS_TASK]
196
- Generate refinement options for existing design system
197
-
198
- SESSION: {session_id} | MODE: refine | BASE_PATH: {base_path}
199
-
200
- ## Existing Design System
201
- - design-tokens.json: {existing_tokens}
202
-
203
- ## Input Guidance
204
- - User prompt: {prompt_guidance}
205
- - Visual references: {loaded_images if available}
206
-
207
- ## Refinement Categories
208
- Generate 8-12 refinement options across these categories:
209
-
210
- 1. **Intensity/Degree Adjustments** (2-3 options):
211
- - Color intensity: more vibrant ↔ more muted
212
- - Visual weight: bolder lighter
213
- - Density: more compact ↔ more spacious
214
-
215
- 2. **Specific Attribute Tuning** (3-4 options):
216
- - Border radius: sharper corners rounder edges
217
- - Shadow depth: subtler shadowsdeeper elevation
218
- - Typography scale: tighter scale ↔ more contrast
219
- - Spacing scale: tighter rhythm ↔ more breathing room
220
-
221
- 3. **Context-Specific Variations** (2-3 options):
222
- - Dark mode optimization
223
- - Mobile-specific adjustments
224
- - High-contrast accessibility mode
225
-
226
- 4. **Component-Level Customization** (1-2 options):
227
- - Button styling emphasis
228
- - Card/container treatment
229
- - Form input refinements
230
-
231
- ## Output Format
232
- Each option:
233
- - category: "intensity|attribute|context|component"
234
- - option_id: unique identifier
235
- - label: Short descriptive name (e.g., "More Vibrant Colors")
236
- - description: What changes (2-3 sentences)
237
- - preview_changes: Key token adjustments preview
238
- - impact_scope: Which tokens affected
239
-
240
- ## Output
241
- Write single JSON file: {base_path}/.intermediates/style-analysis/analysis-options.json
242
-
243
- Use refinement schema:
244
- {
245
- "mode": "refinement",
246
- "base_design": "style-1",
247
- "refinement_options": [array of refinement options]
248
- }
249
-
250
- CRITICAL: Use Write() tool immediately after generating complete JSON
251
- `
252
- ```
253
-
254
- ### Step 3: Verify Options File Created
255
- ```bash
256
- bash(test -f {base_path}/.intermediates/style-analysis/analysis-options.json && echo "created")
257
-
258
- # Quick validation
259
- bash(cat {base_path}/.intermediates/style-analysis/analysis-options.json | grep -q "design_directions" && echo "valid")
260
- ```
261
-
262
- **Output**: `analysis-options.json` with design direction options
263
-
264
- ---
265
-
266
- ## Phase 1.5: User Confirmation (Optional - Triggered by --interactive)
267
-
268
- **Purpose**:
269
- - **Exploration Mode**: Allow user to select preferred design direction(s)
270
- - **Refinement Mode**: Allow user to select refinement options to apply
271
-
272
- **Trigger Condition**: Execute this phase ONLY if `--interactive` flag is present
273
-
274
- ### Step 1: Check Interactive Flag
275
- ```bash
276
- # Skip this entire phase if --interactive flag is not present
277
- IF NOT --interactive:
278
- SKIP to Phase 2
279
- IF refine_mode:
280
- REPORT: "ℹ️ Non-interactive refinement mode: Will apply all suggested refinements"
281
- ELSE:
282
- REPORT: "ℹ️ Non-interactive mode: Will generate all {variants_count} variants"
283
-
284
- REPORT: "🎯 Interactive mode enabled: User selection required"
285
- ```
286
-
287
- ### Step 2: Load and Present Options (Mode-Specific)
288
- ```bash
289
- # Read options file
290
- options = Read({base_path}/.intermediates/style-analysis/analysis-options.json)
291
-
292
- # Branch based on mode
293
- IF NOT refine_mode:
294
- # EXPLORATION MODE
295
- design_directions = options.design_directions
296
- ELSE:
297
- # REFINEMENT MODE
298
- refinement_options = options.refinement_options
299
- ```
300
-
301
- ### Step 3: Present Options to User (Mode-Specific)
302
-
303
- **Exploration Mode**:
304
- ```
305
- 📋 Design Direction Options
306
-
307
- We've generated {variants_count} contrasting design directions for your review.
308
- Please select the direction(s) you'd like to develop into complete design systems.
309
-
310
- {FOR each direction in design_directions:
311
- ═══════════════════════════════════════════════════
312
- Option {direction.index}: {direction.philosophy_name}
313
- ═══════════════════════════════════════════════════
314
-
315
- Philosophy: {direction.rationale}
316
-
317
- Visual Preview:
318
- • Colors: {direction.preview.primary_color} (primary), {direction.preview.accent_color} (accent)
319
- • Typography: {direction.preview.font_family_heading} (headings), {direction.preview.font_family_body} (body)
320
- • Border Radius: {direction.preview.border_radius_base}
321
- Mood: {direction.preview.mood_description}
322
-
323
- Design Attributes:
324
- Color Saturation: {direction.design_attributes.color_saturation * 100}%
325
- Visual Weight: {direction.design_attributes.visual_weight * 100}%
326
- • Formality: {direction.design_attributes.formality * 100}%
327
- Innovation: {direction.design_attributes.innovation * 100}%
328
-
329
- Keywords: {join(direction.search_keywords, ", ")}
330
- Avoiding: {join(direction.anti_keywords, ", ")}
331
- }
332
-
333
- ═══════════════════════════════════════════════════
334
- ```
335
-
336
- **Refinement Mode**:
337
- ```
338
- 📋 Design Refinement Options
339
-
340
- We've analyzed your existing design system and generated refinement options.
341
- Please select the refinement(s) you'd like to apply.
342
-
343
- Base Design: style-1
344
-
345
- {FOR each option in refinement_options grouped by category:
346
- ━━━ {category_name} ━━━
347
-
348
- {FOR each refinement in category_options:
349
- [{refinement.option_id}] {refinement.label}
350
- {refinement.description}
351
- Preview: {refinement.preview_changes}
352
- Affects: {refinement.impact_scope}
353
- }
354
- }
355
-
356
- ═══════════════════════════════════════════════════
357
- ```
358
-
359
- ### Step 4: Capture User Selection and Update Analysis JSON
360
-
361
- **Exploration Mode Interaction**:
362
- ```javascript
363
- // Use AskUserQuestion tool for multi-selection
364
- AskUserQuestion({
365
- questions: [{
366
- question: "Which design direction(s) would you like to develop into complete design systems?",
367
- header: "Style Choice",
368
- multiSelect: true, // Multi-selection enabled
369
- options: [
370
- {FOR each direction:
371
- label: "Option {direction.index}: {direction.philosophy_name}",
372
- description: "{direction.mood_description}"
373
- }
374
- ]
375
- }]
376
- })
377
-
378
- // Parse user response (array of selections)
379
- selected_options = user_answer
380
-
381
- // Check for user cancellation
382
- IF selected_options == null OR selected_options.length == 0:
383
- REPORT: "⚠️ User canceled selection. Workflow terminated."
384
- EXIT workflow
385
-
386
- // Extract option indices
387
- selected_indices = []
388
- FOR each selected_option_text IN selected_options:
389
- match = selected_option_text.match(/Option (\d+):/)
390
- IF match:
391
- selected_indices.push(parseInt(match[1]))
392
-
393
- REPORT: "✅ Selected {selected_indices.length} design direction(s)"
394
-
395
- // Update analysis-options.json
396
- options_file = Read({base_path}/.intermediates/style-analysis/analysis-options.json)
397
- options_file.user_selection = {
398
- "selected_at": NOW(),
399
- "selected_indices": selected_indices,
400
- "selection_count": selected_indices.length
401
- }
402
- Write({base_path}/.intermediates/style-analysis/analysis-options.json, JSON.stringify(options_file, indent=2))
403
- ```
404
-
405
- **Refinement Mode Interaction**:
406
- ```javascript
407
- // Use AskUserQuestion tool for multi-selection of refinements
408
- AskUserQuestion({
409
- questions: [{
410
- question: "Which refinement(s) would you like to apply to your design system?",
411
- header: "Refinements",
412
- multiSelect: true, // Multi-selection enabled
413
- options: [
414
- {FOR each refinement:
415
- label: "{refinement.label}",
416
- description: "{refinement.description} (Affects: {refinement.impact_scope})"
417
- }
418
- ]
419
- }]
420
- })
421
-
422
- // Parse user response
423
- selected_refinements = user_answer
424
-
425
- // Check for user cancellation
426
- IF selected_refinements == null OR selected_refinements.length == 0:
427
- REPORT: "⚠️ User canceled selection. Workflow terminated."
428
- EXIT workflow
429
-
430
- // Extract refinement option_ids
431
- selected_option_ids = []
432
- FOR each selected_text IN selected_refinements:
433
- # Match against refinement labels to find option_ids
434
- FOR each refinement IN refinement_options:
435
- IF refinement.label IN selected_text:
436
- selected_option_ids.push(refinement.option_id)
437
-
438
- REPORT: "✅ Selected {selected_option_ids.length} refinement(s)"
439
-
440
- // Update analysis-options.json
441
- options_file = Read({base_path}/.intermediates/style-analysis/analysis-options.json)
442
- options_file.user_selection = {
443
- "selected_at": NOW(),
444
- "selected_option_ids": selected_option_ids,
445
- "selection_count": selected_option_ids.length
446
- }
447
- Write({base_path}/.intermediates/style-analysis/analysis-options.json, JSON.stringify(options_file, indent=2))
448
- ```
449
-
450
- ### Step 5: Confirmation Message (Mode-Specific)
451
-
452
- **Exploration Mode**:
453
- ```
454
- Selection recorded!
455
-
456
- You selected {selected_indices.length} design direction(s):
457
- {FOR each index IN selected_indices:
458
- Option {index} - {design_directions[index-1].philosophy_name}
459
- }
460
-
461
- Proceeding to generate {selected_indices.length} complete design system(s)...
462
- ```
463
-
464
- **Refinement Mode**:
465
- ```
466
- ✅ Selection recorded!
467
-
468
- You selected {selected_option_ids.length} refinement(s):
469
- {FOR each id IN selected_option_ids:
470
- {refinement_by_id[id].label} ({refinement_by_id[id].category})
471
- }
472
-
473
- Proceeding to apply refinements and generate updated design system...
474
- ```
475
-
476
- **Output**: Updated `analysis-options.json` with user's selection embedded
477
-
478
- ## Phase 2: Design System Generation (Agent Task 2)
479
-
480
- **Executor**: `Task(ui-design-agent)` for selected variant(s)
481
-
482
- ### Step 1: Load User Selection or Default to All
483
- ```bash
484
- # Read analysis-options.json which may contain user_selection
485
- options = Read({base_path}/.intermediates/style-analysis/analysis-options.json)
486
-
487
- # Check if user_selection field exists (interactive mode)
488
- IF options.user_selection AND options.user_selection.selected_indices:
489
- # Interactive mode: Use user-selected variants
490
- selected_indices = options.user_selection.selected_indices # Array of selected indices (e.g., [1, 3])
491
-
492
- REPORT: "🎯 Interactive mode: Using {selected_indices.length} user-selected variant(s)"
493
- ELSE:
494
- # Non-interactive mode: Generate ALL variants (default behavior)
495
- selected_indices = [1, 2, ..., variants_count] # All indices from 1 to variants_count
496
-
497
- REPORT: "ℹ️ Non-interactive mode: Generating all {variants_count} variant(s)"
498
-
499
- # Extract the selected direction details from options
500
- selected_directions = [options.design_directions[i-1] for i in selected_indices] # 0-indexed array
501
-
502
- actual_variants_count = selected_indices.length
503
- REPORT: "📦 Generating {actual_variants_count} design system(s)..."
504
- ```
505
-
506
- ### Step 2: Create Output Directories
507
- ```bash
508
- # Create directories for each selected variant
509
- FOR index IN 1..actual_variants_count:
510
- bash(mkdir -p {base_path}/style-extraction/style-{index})
511
- ```
512
-
513
- ### Step 3: Launch Agent Tasks (Parallel)
514
- Generate design systems for ALL selected directions in parallel (max 5 concurrent):
515
-
516
- ```javascript
517
- // Launch parallel tasks, one for each selected direction
518
- FOR variant_index IN 1..actual_variants_count:
519
- selected_direction = selected_directions[variant_index - 1] // 0-indexed
520
-
521
- Task(ui-design-agent): `
522
- [DESIGN_SYSTEM_GENERATION_TASK #{variant_index}/{actual_variants_count}]
523
- Generate production-ready design system based on user-selected direction
524
-
525
- SESSION: {session_id} | VARIANT: {variant_index}/{actual_variants_count} | BASE_PATH: {base_path}
526
-
527
- USER SELECTION:
528
- - Selected Direction: ${selected_direction.philosophy_name}
529
- - Design Attributes: ${JSON.stringify(selected_direction.design_attributes)}
530
- - Search Keywords: ${selected_direction.search_keywords.join(", ")}
531
- - Anti-keywords: ${selected_direction.anti_keywords.join(", ")}
532
- - Rationale: ${selected_direction.rationale}
533
- - Preview Colors: Primary=${selected_direction.preview.primary_color}, Accent=${selected_direction.preview.accent_color}
534
- - Preview Typography: Heading=${selected_direction.preview.font_family_heading}, Body=${selected_direction.preview.font_family_body}
535
- - Preview Border Radius: ${selected_direction.preview.border_radius_base}
536
-
537
- ## Input Analysis
538
- - Input mode: {input_mode} (image/text/hybrid)
539
- - Visual references: {loaded_images OR prompt_guidance}
540
-
541
- ## Generation Rules
542
- - Develop the selected design direction into a complete design system
543
- - Use preview elements as foundation and expand with full token coverage
544
- - Apply design_attributes to all token values:
545
- * color_saturation → OKLCH chroma values
546
- * visual_weight font weights, shadow depths
547
- * density spacing scale compression/expansion
548
- * formality typography choices, border radius
549
- * organic_geometricborder radius, shape patterns
550
- * innovationtoken naming, experimental values
551
- - Honor search_keywords for design inspiration
552
- - Avoid anti_keywords patterns
553
- - All colors in OKLCH format
554
- - WCAG AA compliance: 4.5:1 text contrast, 3:1 UI contrast
555
-
556
- ## Generate
557
- Create complete design system in {base_path}/style-extraction/style-{variant_index}/
558
-
559
- 1. **design-tokens.json**:
560
- - Complete token structure with ALL fields:
561
- * colors (brand, surface, semantic, text, border) - OKLCH format
562
- * typography (families, sizes, weights, line heights, letter spacing, combinations)
563
- * typography.combinations: Predefined typography presets (heading-primary, heading-secondary, body-regular, body-emphasis, caption, label) using var() references
564
- * spacing (0-24 scale)
565
- * opacity (0, 10, 20, 40, 60, 80, 90, 100)
566
- * border_radius (none to full)
567
- * shadows (sm to xl)
568
- * component_styles (button, card, input variants) - component presets using var() references
569
- * breakpoints (sm to 2xl)
570
- - All colors in OKLCH format
571
- ${extraction_mode == "explore" ? "- Start from preview colors and expand to full palette" : ""}
572
- ${extraction_mode == "explore" && refinements.enabled ? "- Apply user refinements where specified" : ""}
573
- - Common Tailwind CSS usage patterns in project (if extracting from existing project)
574
-
575
- ## Critical Requirements
576
- - Use Write() tool immediately for each file
577
- - Write to style-{variant_index}/ directory
578
- - ✅ Can use Exa MCP to research modern design patterns and obtain code examples (Explore/Text mode)
579
- - Maintain consistency with user-selected direction
580
- `
581
- ```
582
-
583
- **Output**: {actual_variants_count} parallel agent tasks generate design-tokens.json for each variant
584
-
585
- ## Phase 3: Verify Output
586
-
587
- ### Step 1: Check Files Created
588
- ```bash
589
- # Verify all design systems created
590
- bash(ls {base_path}/style-extraction/style-*/design-tokens.json | wc -l)
591
-
592
- # Validate structure
593
- bash(cat {base_path}/style-extraction/style-1/design-tokens.json | grep -q "colors" && echo "valid")
594
- ```
595
-
596
- ### Step 2: Verify File Sizes
597
- ```bash
598
- bash(ls -lh {base_path}/style-extraction/style-1/)
599
- ```
600
-
601
- **Output**: `variants_count × 2` files verified
602
-
603
- ## Completion
604
-
605
- ### Todo Update
606
- ```javascript
607
- TodoWrite({todos: [
608
- {content: "Setup and input validation", status: "completed", activeForm: "Validating inputs"},
609
- {content: "Design space analysis (explore mode)", status: "completed", activeForm: "Analyzing design space"},
610
- {content: "Design system generation (agent)", status: "completed", activeForm: "Generating design systems"},
611
- {content: "Verify output files", status: "completed", activeForm: "Verifying files"}
612
- ]});
613
- ```
614
-
615
- ### Output Message
616
- ```
617
- ✅ Style extraction complete!
618
-
619
- Configuration:
620
- - Session: {session_id}
621
- - Extraction Mode: {extraction_mode} (imitate/explore)
622
- - Input Mode: {input_mode} (image/text/hybrid)
623
- - Variants: {variants_count}
624
- - Production-Ready: Complete design systems generated
625
-
626
- {IF extraction_mode == "explore":
627
- Design Direction Selection:
628
- - You selected: Option {selected_index} - {selected_direction.philosophy_name}
629
- - Generated from {variants_count} contrasting design direction options
630
- }
631
-
632
- Generated Files:
633
- {base_path}/style-extraction/
634
- └── style-1/design-tokens.json
635
- {IF extraction_mode == "explore":
636
- {base_path}/.intermediates/style-analysis/analysis-options.json (design direction options + user selection)
637
- }
638
-
639
- Next: /workflow:ui-design:layout-extract --session {session_id} --targets "..."
640
- OR: /workflow:ui-design:generate --session {session_id}
641
- ```
642
-
643
- ## Simple Bash Commands
644
-
645
- ### Path Operations
646
- ```bash
647
- # Find design directory
648
- bash(find .workflow -type d -name "design-run-*" | head -1)
649
-
650
- # Expand image pattern
651
- bash(ls {images_pattern})
652
-
653
- # Create output directory
654
- bash(mkdir -p {base_path}/style-extraction/)
655
- ```
656
-
657
- ### Validation Commands
658
- ```bash
659
- # Check if already extracted
660
- bash(test -f {base_path}/style-extraction/style-1/design-tokens.json && echo "exists")
661
-
662
- # Count variants
663
- bash(ls {base_path}/style-extraction/style-* -d | wc -l)
664
-
665
- # Validate JSON structure
666
- bash(cat {base_path}/style-extraction/style-1/design-tokens.json | grep -q "colors" && echo "valid")
667
- ```
668
-
669
- ### File Operations
670
- ```bash
671
- # Load brainstorming context
672
- bash(test -f .brainstorming/role analysis documents && cat it)
673
-
674
- # Create directories (example for multiple variants)
675
- bash(mkdir -p {base_path}/style-extraction/style-1)
676
- bash(mkdir -p {base_path}/style-extraction/style-2)
677
- bash(mkdir -p {base_path}/style-extraction/style-3)
678
-
679
- # Verify output
680
- bash(ls {base_path}/style-extraction/style-1/)
681
- bash(test -f {base_path}/.intermediates/style-analysis/analysis-options.json && echo "saved")
682
- ```
683
-
684
- ## Output Structure
685
-
686
- ```
687
- {base_path}/
688
- ├── .intermediates/ # Intermediate analysis files
689
- │ └── style-analysis/
690
- │ ├── computed-styles.json # Extracted CSS values from DOM (if URL available)
691
- │ └── analysis-options.json # Design direction options + user selection (explore mode only)
692
- └── style-extraction/ # Final design system
693
- └── style-1/
694
- └── design-tokens.json # Production-ready design tokens
695
- ```
696
-
697
- ## design-tokens.json Format
698
-
699
- ```json
700
- {
701
- "colors": {
702
- "brand": {"primary": "oklch(...)", "secondary": "oklch(...)", "accent": "oklch(...)"},
703
- "surface": {"background": "oklch(...)", "elevated": "oklch(...)", "overlay": "oklch(...)"},
704
- "semantic": {"success": "oklch(...)", "warning": "oklch(...)", "error": "oklch(...)", "info": "oklch(...)"},
705
- "text": {"primary": "oklch(...)", "secondary": "oklch(...)", "tertiary": "oklch(...)", "inverse": "oklch(...)"},
706
- "border": {"default": "oklch(...)", "strong": "oklch(...)", "subtle": "oklch(...)"}
707
- },
708
- "typography": {
709
- "font_family": {...},
710
- "font_size": {...},
711
- "font_weight": {...},
712
- "line_height": {...},
713
- "letter_spacing": {...},
714
- "combinations": {
715
- "heading-primary": {"family": "var(--font-family-heading)", "size": "var(--font-size-3xl)", "weight": "var(--font-weight-bold)", "line_height": "var(--line-height-tight)", "letter_spacing": "var(--letter-spacing-tight)"},
716
- "heading-secondary": {...},
717
- "body-regular": {...},
718
- "body-emphasis": {...},
719
- "caption": {...},
720
- "label": {...}
721
- }
722
- },
723
- "spacing": {"0": "0", "1": "0.25rem", ..., "24": "6rem"},
724
- "opacity": {"0": "0", "10": "0.1", "20": "0.2", "40": "0.4", "60": "0.6", "80": "0.8", "90": "0.9", "100": "1"},
725
- "border_radius": {"none": "0", "sm": "0.25rem", ..., "full": "9999px"},
726
- "shadows": {"sm": "...", "md": "...", "lg": "...", "xl": "..."},
727
- "component_styles": {
728
- "button": {
729
- "primary": {"background": "var(--color-brand-primary)", "color": "var(--color-text-inverse)", "padding": "var(--spacing-3) var(--spacing-6)", "border_radius": "var(--border-radius-md)", "font_weight": "var(--font-weight-semibold)"},
730
- "secondary": {...},
731
- "tertiary": {...}
732
- },
733
- "card": {
734
- "default": {"background": "var(--color-surface-elevated)", "padding": "var(--spacing-6)", "border_radius": "var(--border-radius-lg)", "shadow": "var(--shadow-md)"},
735
- "interactive": {...}
736
- },
737
- "input": {
738
- "default": {"border": "1px solid var(--color-border-default)", "padding": "var(--spacing-3)", "border_radius": "var(--border-radius-md)", "background": "var(--color-surface-background)"},
739
- "focus": {...},
740
- "error": {...}
741
- }
742
- },
743
- "breakpoints": {"sm": "640px", ..., "2xl": "1536px"}
744
- }
745
- ```
746
-
747
- **Requirements**: OKLCH colors, complete coverage, semantic naming, WCAG AA compliance, typography combinations, component style presets, opacity scale
748
-
749
- ## Error Handling
750
-
751
- ### Common Errors
752
- ```
753
- ERROR: No images found
754
- → Check glob pattern
755
-
756
- ERROR: Invalid prompt
757
- Provide non-empty string
758
-
759
- ERROR: Claude JSON parsing error
760
- Retry with stricter format
761
- ```
762
-
763
- ## Key Features
764
-
765
- - **Direct Design System Generation** - Complete design-tokens.json + style-guide.md in one step
766
- - **AI-Driven Design Space Exploration** - 6D attribute space analysis for maximum contrast
767
- - **Variant-Specific Directions** - Each variant has unique philosophy, keywords, anti-patterns
768
- - **Maximum Contrast Guarantee** - Variants maximally distant in attribute space
769
- - **Flexible Input** - Images, text, or hybrid mode
770
- - **Production-Ready** - OKLCH colors, WCAG AA compliance, semantic naming
771
- - **Agent-Driven** - Autonomous multi-file generation with ui-design-agent
772
-
773
-
1
+ ---
2
+ name: style-extract
3
+ description: Extract design style from reference images or text prompts using Claude analysis with variant generation or refinement mode
4
+ argument-hint: "[-y|--yes] [--design-id <id>] [--session <id>] [--images "<glob>"] [--prompt "<desc>"] [--variants <count>] [--interactive] [--refine]"
5
+ allowed-tools: TodoWrite(*), Read(*), Write(*), Glob(*), AskUserQuestion(*)
6
+ ---
7
+
8
+ ## Auto Mode
9
+
10
+ When `--yes` or `-y`: Skip all clarification questions, use AI-inferred design decisions.
11
+
12
+ # Style Extraction Command
13
+
14
+ ## Overview
15
+ Extract design style from reference images or text prompts using Claude's built-in analysis. Supports two modes:
16
+ 1. **Exploration Mode** (default): Generate multiple contrasting design variants
17
+ 2. **Refinement Mode** (`--refine`): Refine a single existing design through detailed adjustments
18
+
19
+ **Strategy**: AI-Driven Design Space Exploration
20
+ - **Claude-Native**: 100% Claude analysis, no external tools
21
+ - **Direct Output**: Complete design systems (design-tokens.json)
22
+ - **Flexible Input**: Images, text prompts, or both (hybrid mode)
23
+ - **Dual Mode**: Exploration (multiple contrasting variants) or Refinement (single design fine-tuning)
24
+ - **Production-Ready**: WCAG AA compliant, OKLCH colors, semantic naming
25
+
26
+ ## Execution Process
27
+
28
+ ```
29
+ Input Parsing:
30
+ ├─ Parse flags: --design-id, --session, --images, --prompt, --variants, --interactive, --refine
31
+ └─ Decision (mode detection):
32
+ ├─ --refine flag Refinement Mode (variants_count = 1)
33
+ └─ No --refine Exploration Mode (variants_count = --variants OR 3)
34
+
35
+ Phase 0: Setup & Input Validation
36
+ ├─ Step 1: Detect input mode, extraction mode & base path
37
+ ├─ Step 2: Load inputs
38
+ └─ Step 3: Memory check (skip if exists)
39
+
40
+ Phase 1: Design Direction/Refinement Options Generation
41
+ ├─ Step 1: Load project context
42
+ ├─ Step 2: Generate options (Agent Task 1)
43
+ │ └─ Decision:
44
+ │ ├─ Exploration Mode Generate contrasting design directions
45
+ └─ Refinement Mode → Generate refinement options
46
+ └─ Step 3: Verify options file created
47
+
48
+ Phase 1.5: User Confirmation (Optional)
49
+ └─ Decision (--interactive flag):
50
+ ├─ --interactive present Present options, capture selection
51
+ └─ No --interactive Skip to Phase 2
52
+
53
+ Phase 2: Design System Generation
54
+ ├─ Step 1: Load user selection or default to all
55
+ ├─ Step 2: Create output directories
56
+ └─ Step 3: Launch agent tasks (parallel)
57
+
58
+ Phase 3: Verify Output
59
+ ├─ Step 1: Check files created
60
+ └─ Step 2: Verify file sizes
61
+ ```
62
+
63
+ ## Phase 0: Setup & Input Validation
64
+
65
+ ### Step 1: Detect Input Mode, Extraction Mode & Base Path
66
+ ```bash
67
+ # Detect input source
68
+ # Priority: --images + --prompt → hybrid | --images → image | --prompt → text
69
+
70
+ # Detect refinement mode
71
+ refine_mode = --refine OR false
72
+
73
+ # Set variants count
74
+ # Refinement mode: Force variants_count = 1 (ignore user-provided --variants)
75
+ # Exploration mode: Use --variants or default to 3 (range: 1-5)
76
+ IF refine_mode:
77
+ variants_count = 1
78
+ REPORT: "🔧 Refinement mode enabled: Will generate 1 refined design system"
79
+ ELSE:
80
+ variants_count = --variants OR 3
81
+ VALIDATE: 1 <= variants_count <= 5
82
+ REPORT: "🔍 Exploration mode: Will generate {variants_count} contrasting design directions"
83
+
84
+ # Determine base path with priority: --design-id > --session > auto-detect
85
+ if [ -n "$DESIGN_ID" ]; then
86
+ # Exact match by design ID
87
+ relative_path=$(find .workflow -name "${DESIGN_ID}" -type d -print -quit)
88
+ elif [ -n "$SESSION_ID" ]; then
89
+ # Latest in session
90
+ relative_path=$(find .workflow/active/WFS-$SESSION_ID -name "design-run-*" -type d -printf "%T@ %p\n" 2>/dev/null | sort -nr | head -1 | cut -d' ' -f2)
91
+ else
92
+ # Latest globally
93
+ relative_path=$(find .workflow -name "design-run-*" -type d -printf "%T@ %p\n" 2>/dev/null | sort -nr | head -1 | cut -d' ' -f2)
94
+ fi
95
+
96
+ # Validate and convert to absolute path
97
+ if [ -z "$relative_path" ] || [ ! -d "$relative_path" ]; then
98
+ echo "❌ ERROR: Design run not found"
99
+ echo "💡 HINT: Run '/workflow:ui-design:list' to see available design runs"
100
+ exit 1
101
+ fi
102
+
103
+ base_path=$(cd "$relative_path" && pwd)
104
+ bash(echo "✓ Base path: $base_path")
105
+ ```
106
+
107
+ ### Step 2: Load Inputs
108
+ ```bash
109
+ # For image mode
110
+ bash(ls {images_pattern}) # Expand glob pattern
111
+ Read({image_path}) # Load each image
112
+
113
+ # For text mode
114
+ # Validate --prompt is non-empty
115
+
116
+ # Create output directory
117
+ bash(mkdir -p {base_path}/style-extraction/)
118
+ ```
119
+
120
+ ### Step 3: Memory Check
121
+ ```bash
122
+ # 1. Check if inputs cached in session memory
123
+ IF session_has_inputs: SKIP Step 2 file reading
124
+
125
+ # 2. Check if output already exists
126
+ bash(test -f {base_path}/style-extraction/style-1/design-tokens.json && echo "exists")
127
+ IF exists: SKIP to completion
128
+ ```
129
+
130
+ ---
131
+
132
+ **Phase 0 Output**: `input_mode`, `base_path`, `extraction_mode`, `variants_count`, `loaded_images[]` or `prompt_guidance`
133
+
134
+ ## Phase 1: Design Direction or Refinement Options Generation
135
+
136
+ ### Step 1: Load Project Context
137
+ ```bash
138
+ # Load brainstorming context if available
139
+ bash(test -f {base_path}/.brainstorming/role analysis documents && cat it)
140
+
141
+ # Load existing design system if refinement mode
142
+ IF refine_mode:
143
+ existing_tokens = Read({base_path}/style-extraction/style-1/design-tokens.json)
144
+ ```
145
+
146
+ ### Step 2: Generate Options (Agent Task 1 - Mode-Specific)
147
+ **Executor**: `Task(ui-design-agent)`
148
+
149
+ **Exploration Mode** (default): Generate contrasting design directions
150
+ **Refinement Mode** (`--refine`): Generate refinement options for existing design
151
+
152
+ ```javascript
153
+ // Conditional agent task based on refine_mode
154
+ IF NOT refine_mode:
155
+ // EXPLORATION MODE
156
+ Task(ui-design-agent): `
157
+ [DESIGN_DIRECTION_GENERATION_TASK]
158
+ Generate {variants_count} maximally contrasting design directions with visual previews
159
+
160
+ SESSION: {session_id} | MODE: explore | BASE_PATH: {base_path}
161
+
162
+ ## Input Analysis
163
+ - User prompt: {prompt_guidance}
164
+ - Visual references: {loaded_images if available}
165
+ - Project context: {brainstorming_context if available}
166
+
167
+ ## Analysis Rules
168
+ - Analyze 6D attribute space: color saturation, visual weight, formality, organic/geometric, innovation, density
169
+ - Generate {variants_count} directions with MAXIMUM contrast
170
+ - Each direction must be distinctly different (min distance score: 0.7)
171
+
172
+ ## Generate for EACH Direction
173
+ 1. **Core Philosophy**:
174
+ - philosophy_name (2-3 words, e.g., "Minimalist & Airy")
175
+ - design_attributes (6D scores 0-1)
176
+ - search_keywords (3-5 keywords)
177
+ - anti_keywords (2-3 keywords to avoid)
178
+ - rationale (why this is distinct from others)
179
+
180
+ 2. **Visual Preview Elements**:
181
+ - primary_color (OKLCH format)
182
+ - secondary_color (OKLCH format)
183
+ - accent_color (OKLCH format)
184
+ - font_family_heading (specific font name)
185
+ - font_family_body (specific font name)
186
+ - border_radius_base (e.g., "0.5rem")
187
+ - mood_description (1-2 sentences describing the feel)
188
+
189
+ ## Output
190
+ Write single JSON file: {base_path}/.intermediates/style-analysis/analysis-options.json
191
+
192
+ Use schema from INTERACTIVE-DATA-SPEC.md (Style Extract: analysis-options.json)
193
+
194
+ CRITICAL: Use Write() tool immediately after generating complete JSON
195
+ `
196
+ ELSE:
197
+ // REFINEMENT MODE
198
+ Task(ui-design-agent): `
199
+ [DESIGN_REFINEMENT_OPTIONS_TASK]
200
+ Generate refinement options for existing design system
201
+
202
+ SESSION: {session_id} | MODE: refine | BASE_PATH: {base_path}
203
+
204
+ ## Existing Design System
205
+ - design-tokens.json: {existing_tokens}
206
+
207
+ ## Input Guidance
208
+ - User prompt: {prompt_guidance}
209
+ - Visual references: {loaded_images if available}
210
+
211
+ ## Refinement Categories
212
+ Generate 8-12 refinement options across these categories:
213
+
214
+ 1. **Intensity/Degree Adjustments** (2-3 options):
215
+ - Color intensity: more vibrant ↔ more muted
216
+ - Visual weight: bolderlighter
217
+ - Density: more compactmore spacious
218
+
219
+ 2. **Specific Attribute Tuning** (3-4 options):
220
+ - Border radius: sharper corners ↔ rounder edges
221
+ - Shadow depth: subtler shadows ↔ deeper elevation
222
+ - Typography scale: tighter scale ↔ more contrast
223
+ - Spacing scale: tighter rhythm ↔ more breathing room
224
+
225
+ 3. **Context-Specific Variations** (2-3 options):
226
+ - Dark mode optimization
227
+ - Mobile-specific adjustments
228
+ - High-contrast accessibility mode
229
+
230
+ 4. **Component-Level Customization** (1-2 options):
231
+ - Button styling emphasis
232
+ - Card/container treatment
233
+ - Form input refinements
234
+
235
+ ## Output Format
236
+ Each option:
237
+ - category: "intensity|attribute|context|component"
238
+ - option_id: unique identifier
239
+ - label: Short descriptive name (e.g., "More Vibrant Colors")
240
+ - description: What changes (2-3 sentences)
241
+ - preview_changes: Key token adjustments preview
242
+ - impact_scope: Which tokens affected
243
+
244
+ ## Output
245
+ Write single JSON file: {base_path}/.intermediates/style-analysis/analysis-options.json
246
+
247
+ Use refinement schema:
248
+ {
249
+ "mode": "refinement",
250
+ "base_design": "style-1",
251
+ "refinement_options": [array of refinement options]
252
+ }
253
+
254
+ CRITICAL: Use Write() tool immediately after generating complete JSON
255
+ `
256
+ ```
257
+
258
+ ### Step 3: Verify Options File Created
259
+ ```bash
260
+ bash(test -f {base_path}/.intermediates/style-analysis/analysis-options.json && echo "created")
261
+
262
+ # Quick validation
263
+ bash(cat {base_path}/.intermediates/style-analysis/analysis-options.json | grep -q "design_directions" && echo "valid")
264
+ ```
265
+
266
+ **Output**: `analysis-options.json` with design direction options
267
+
268
+ ---
269
+
270
+ ## Phase 1.5: User Confirmation (Optional - Triggered by --interactive)
271
+
272
+ **Purpose**:
273
+ - **Exploration Mode**: Allow user to select preferred design direction(s)
274
+ - **Refinement Mode**: Allow user to select refinement options to apply
275
+
276
+ **Trigger Condition**: Execute this phase ONLY if `--interactive` flag is present
277
+
278
+ ### Step 1: Check Interactive Flag
279
+ ```bash
280
+ # Skip this entire phase if --interactive flag is not present
281
+ IF NOT --interactive:
282
+ SKIP to Phase 2
283
+ IF refine_mode:
284
+ REPORT: "ℹ️ Non-interactive refinement mode: Will apply all suggested refinements"
285
+ ELSE:
286
+ REPORT: "ℹ️ Non-interactive mode: Will generate all {variants_count} variants"
287
+
288
+ REPORT: "🎯 Interactive mode enabled: User selection required"
289
+ ```
290
+
291
+ ### Step 2: Load and Present Options (Mode-Specific)
292
+ ```bash
293
+ # Read options file
294
+ options = Read({base_path}/.intermediates/style-analysis/analysis-options.json)
295
+
296
+ # Branch based on mode
297
+ IF NOT refine_mode:
298
+ # EXPLORATION MODE
299
+ design_directions = options.design_directions
300
+ ELSE:
301
+ # REFINEMENT MODE
302
+ refinement_options = options.refinement_options
303
+ ```
304
+
305
+ ### Step 3: Present Options to User (Mode-Specific)
306
+
307
+ **Exploration Mode**:
308
+ ```
309
+ 📋 Design Direction Options
310
+
311
+ We've generated {variants_count} contrasting design directions for your review.
312
+ Please select the direction(s) you'd like to develop into complete design systems.
313
+
314
+ {FOR each direction in design_directions:
315
+ ═══════════════════════════════════════════════════
316
+ Option {direction.index}: {direction.philosophy_name}
317
+ ═══════════════════════════════════════════════════
318
+
319
+ Philosophy: {direction.rationale}
320
+
321
+ Visual Preview:
322
+ • Colors: {direction.preview.primary_color} (primary), {direction.preview.accent_color} (accent)
323
+ Typography: {direction.preview.font_family_heading} (headings), {direction.preview.font_family_body} (body)
324
+ Border Radius: {direction.preview.border_radius_base}
325
+ Mood: {direction.preview.mood_description}
326
+
327
+ Design Attributes:
328
+ • Color Saturation: {direction.design_attributes.color_saturation * 100}%
329
+ • Visual Weight: {direction.design_attributes.visual_weight * 100}%
330
+ • Formality: {direction.design_attributes.formality * 100}%
331
+ • Innovation: {direction.design_attributes.innovation * 100}%
332
+
333
+ Keywords: {join(direction.search_keywords, ", ")}
334
+ Avoiding: {join(direction.anti_keywords, ", ")}
335
+ }
336
+
337
+ ═══════════════════════════════════════════════════
338
+ ```
339
+
340
+ **Refinement Mode**:
341
+ ```
342
+ 📋 Design Refinement Options
343
+
344
+ We've analyzed your existing design system and generated refinement options.
345
+ Please select the refinement(s) you'd like to apply.
346
+
347
+ Base Design: style-1
348
+
349
+ {FOR each option in refinement_options grouped by category:
350
+ ━━━ {category_name} ━━━
351
+
352
+ {FOR each refinement in category_options:
353
+ [{refinement.option_id}] {refinement.label}
354
+ {refinement.description}
355
+ Preview: {refinement.preview_changes}
356
+ Affects: {refinement.impact_scope}
357
+ }
358
+ }
359
+
360
+ ═══════════════════════════════════════════════════
361
+ ```
362
+
363
+ ### Step 4: Capture User Selection and Update Analysis JSON
364
+
365
+ **Exploration Mode Interaction**:
366
+ ```javascript
367
+ // Use AskUserQuestion tool for multi-selection
368
+ AskUserQuestion({
369
+ questions: [{
370
+ question: "Which design direction(s) would you like to develop into complete design systems?",
371
+ header: "Style Choice",
372
+ multiSelect: true, // Multi-selection enabled
373
+ options: [
374
+ {FOR each direction:
375
+ label: "Option {direction.index}: {direction.philosophy_name}",
376
+ description: "{direction.mood_description}"
377
+ }
378
+ ]
379
+ }]
380
+ })
381
+
382
+ // Parse user response (array of selections)
383
+ selected_options = user_answer
384
+
385
+ // Check for user cancellation
386
+ IF selected_options == null OR selected_options.length == 0:
387
+ REPORT: "⚠️ User canceled selection. Workflow terminated."
388
+ EXIT workflow
389
+
390
+ // Extract option indices
391
+ selected_indices = []
392
+ FOR each selected_option_text IN selected_options:
393
+ match = selected_option_text.match(/Option (\d+):/)
394
+ IF match:
395
+ selected_indices.push(parseInt(match[1]))
396
+
397
+ REPORT: "✅ Selected {selected_indices.length} design direction(s)"
398
+
399
+ // Update analysis-options.json
400
+ options_file = Read({base_path}/.intermediates/style-analysis/analysis-options.json)
401
+ options_file.user_selection = {
402
+ "selected_at": NOW(),
403
+ "selected_indices": selected_indices,
404
+ "selection_count": selected_indices.length
405
+ }
406
+ Write({base_path}/.intermediates/style-analysis/analysis-options.json, JSON.stringify(options_file, indent=2))
407
+ ```
408
+
409
+ **Refinement Mode Interaction**:
410
+ ```javascript
411
+ // Use AskUserQuestion tool for multi-selection of refinements
412
+ AskUserQuestion({
413
+ questions: [{
414
+ question: "Which refinement(s) would you like to apply to your design system?",
415
+ header: "Refinements",
416
+ multiSelect: true, // Multi-selection enabled
417
+ options: [
418
+ {FOR each refinement:
419
+ label: "{refinement.label}",
420
+ description: "{refinement.description} (Affects: {refinement.impact_scope})"
421
+ }
422
+ ]
423
+ }]
424
+ })
425
+
426
+ // Parse user response
427
+ selected_refinements = user_answer
428
+
429
+ // Check for user cancellation
430
+ IF selected_refinements == null OR selected_refinements.length == 0:
431
+ REPORT: "⚠️ User canceled selection. Workflow terminated."
432
+ EXIT workflow
433
+
434
+ // Extract refinement option_ids
435
+ selected_option_ids = []
436
+ FOR each selected_text IN selected_refinements:
437
+ # Match against refinement labels to find option_ids
438
+ FOR each refinement IN refinement_options:
439
+ IF refinement.label IN selected_text:
440
+ selected_option_ids.push(refinement.option_id)
441
+
442
+ REPORT: "✅ Selected {selected_option_ids.length} refinement(s)"
443
+
444
+ // Update analysis-options.json
445
+ options_file = Read({base_path}/.intermediates/style-analysis/analysis-options.json)
446
+ options_file.user_selection = {
447
+ "selected_at": NOW(),
448
+ "selected_option_ids": selected_option_ids,
449
+ "selection_count": selected_option_ids.length
450
+ }
451
+ Write({base_path}/.intermediates/style-analysis/analysis-options.json, JSON.stringify(options_file, indent=2))
452
+ ```
453
+
454
+ ### Step 5: Confirmation Message (Mode-Specific)
455
+
456
+ **Exploration Mode**:
457
+ ```
458
+ Selection recorded!
459
+
460
+ You selected {selected_indices.length} design direction(s):
461
+ {FOR each index IN selected_indices:
462
+ • Option {index} - {design_directions[index-1].philosophy_name}
463
+ }
464
+
465
+ Proceeding to generate {selected_indices.length} complete design system(s)...
466
+ ```
467
+
468
+ **Refinement Mode**:
469
+ ```
470
+ Selection recorded!
471
+
472
+ You selected {selected_option_ids.length} refinement(s):
473
+ {FOR each id IN selected_option_ids:
474
+ • {refinement_by_id[id].label} ({refinement_by_id[id].category})
475
+ }
476
+
477
+ Proceeding to apply refinements and generate updated design system...
478
+ ```
479
+
480
+ **Output**: Updated `analysis-options.json` with user's selection embedded
481
+
482
+ ## Phase 2: Design System Generation (Agent Task 2)
483
+
484
+ **Executor**: `Task(ui-design-agent)` for selected variant(s)
485
+
486
+ ### Step 1: Load User Selection or Default to All
487
+ ```bash
488
+ # Read analysis-options.json which may contain user_selection
489
+ options = Read({base_path}/.intermediates/style-analysis/analysis-options.json)
490
+
491
+ # Check if user_selection field exists (interactive mode)
492
+ IF options.user_selection AND options.user_selection.selected_indices:
493
+ # Interactive mode: Use user-selected variants
494
+ selected_indices = options.user_selection.selected_indices # Array of selected indices (e.g., [1, 3])
495
+
496
+ REPORT: "🎯 Interactive mode: Using {selected_indices.length} user-selected variant(s)"
497
+ ELSE:
498
+ # Non-interactive mode: Generate ALL variants (default behavior)
499
+ selected_indices = [1, 2, ..., variants_count] # All indices from 1 to variants_count
500
+
501
+ REPORT: "ℹ️ Non-interactive mode: Generating all {variants_count} variant(s)"
502
+
503
+ # Extract the selected direction details from options
504
+ selected_directions = [options.design_directions[i-1] for i in selected_indices] # 0-indexed array
505
+
506
+ actual_variants_count = selected_indices.length
507
+ REPORT: "📦 Generating {actual_variants_count} design system(s)..."
508
+ ```
509
+
510
+ ### Step 2: Create Output Directories
511
+ ```bash
512
+ # Create directories for each selected variant
513
+ FOR index IN 1..actual_variants_count:
514
+ bash(mkdir -p {base_path}/style-extraction/style-{index})
515
+ ```
516
+
517
+ ### Step 3: Launch Agent Tasks (Parallel)
518
+ Generate design systems for ALL selected directions in parallel (max 5 concurrent):
519
+
520
+ ```javascript
521
+ // Launch parallel tasks, one for each selected direction
522
+ FOR variant_index IN 1..actual_variants_count:
523
+ selected_direction = selected_directions[variant_index - 1] // 0-indexed
524
+
525
+ Task(ui-design-agent): `
526
+ [DESIGN_SYSTEM_GENERATION_TASK #{variant_index}/{actual_variants_count}]
527
+ Generate production-ready design system based on user-selected direction
528
+
529
+ SESSION: {session_id} | VARIANT: {variant_index}/{actual_variants_count} | BASE_PATH: {base_path}
530
+
531
+ USER SELECTION:
532
+ - Selected Direction: ${selected_direction.philosophy_name}
533
+ - Design Attributes: ${JSON.stringify(selected_direction.design_attributes)}
534
+ - Search Keywords: ${selected_direction.search_keywords.join(", ")}
535
+ - Anti-keywords: ${selected_direction.anti_keywords.join(", ")}
536
+ - Rationale: ${selected_direction.rationale}
537
+ - Preview Colors: Primary=${selected_direction.preview.primary_color}, Accent=${selected_direction.preview.accent_color}
538
+ - Preview Typography: Heading=${selected_direction.preview.font_family_heading}, Body=${selected_direction.preview.font_family_body}
539
+ - Preview Border Radius: ${selected_direction.preview.border_radius_base}
540
+
541
+ ## Input Analysis
542
+ - Input mode: {input_mode} (image/text/hybrid)
543
+ - Visual references: {loaded_images OR prompt_guidance}
544
+
545
+ ## Generation Rules
546
+ - Develop the selected design direction into a complete design system
547
+ - Use preview elements as foundation and expand with full token coverage
548
+ - Apply design_attributes to all token values:
549
+ * color_saturationOKLCH chroma values
550
+ * visual_weightfont weights, shadow depths
551
+ * density spacing scale compression/expansion
552
+ * formality typography choices, border radius
553
+ * organic_geometric border radius, shape patterns
554
+ * innovation token naming, experimental values
555
+ - Honor search_keywords for design inspiration
556
+ - Avoid anti_keywords patterns
557
+ - All colors in OKLCH format
558
+ - WCAG AA compliance: 4.5:1 text contrast, 3:1 UI contrast
559
+
560
+ ## Generate
561
+ Create complete design system in {base_path}/style-extraction/style-{variant_index}/
562
+
563
+ 1. **design-tokens.json**:
564
+ - Complete token structure with ALL fields:
565
+ * colors (brand, surface, semantic, text, border) - OKLCH format
566
+ * typography (families, sizes, weights, line heights, letter spacing, combinations)
567
+ * typography.combinations: Predefined typography presets (heading-primary, heading-secondary, body-regular, body-emphasis, caption, label) using var() references
568
+ * spacing (0-24 scale)
569
+ * opacity (0, 10, 20, 40, 60, 80, 90, 100)
570
+ * border_radius (none to full)
571
+ * shadows (sm to xl)
572
+ * component_styles (button, card, input variants) - component presets using var() references
573
+ * breakpoints (sm to 2xl)
574
+ - All colors in OKLCH format
575
+ ${extraction_mode == "explore" ? "- Start from preview colors and expand to full palette" : ""}
576
+ ${extraction_mode == "explore" && refinements.enabled ? "- Apply user refinements where specified" : ""}
577
+ - Common Tailwind CSS usage patterns in project (if extracting from existing project)
578
+
579
+ ## Critical Requirements
580
+ - ✅ Use Write() tool immediately for each file
581
+ - ✅ Write to style-{variant_index}/ directory
582
+ - ✅ Can use Exa MCP to research modern design patterns and obtain code examples (Explore/Text mode)
583
+ - Maintain consistency with user-selected direction
584
+ `
585
+ ```
586
+
587
+ **Output**: {actual_variants_count} parallel agent tasks generate design-tokens.json for each variant
588
+
589
+ ## Phase 3: Verify Output
590
+
591
+ ### Step 1: Check Files Created
592
+ ```bash
593
+ # Verify all design systems created
594
+ bash(ls {base_path}/style-extraction/style-*/design-tokens.json | wc -l)
595
+
596
+ # Validate structure
597
+ bash(cat {base_path}/style-extraction/style-1/design-tokens.json | grep -q "colors" && echo "valid")
598
+ ```
599
+
600
+ ### Step 2: Verify File Sizes
601
+ ```bash
602
+ bash(ls -lh {base_path}/style-extraction/style-1/)
603
+ ```
604
+
605
+ **Output**: `variants_count × 2` files verified
606
+
607
+ ## Completion
608
+
609
+ ### Todo Update
610
+ ```javascript
611
+ TodoWrite({todos: [
612
+ {content: "Setup and input validation", status: "completed", activeForm: "Validating inputs"},
613
+ {content: "Design space analysis (explore mode)", status: "completed", activeForm: "Analyzing design space"},
614
+ {content: "Design system generation (agent)", status: "completed", activeForm: "Generating design systems"},
615
+ {content: "Verify output files", status: "completed", activeForm: "Verifying files"}
616
+ ]});
617
+ ```
618
+
619
+ ### Output Message
620
+ ```
621
+ Style extraction complete!
622
+
623
+ Configuration:
624
+ - Session: {session_id}
625
+ - Extraction Mode: {extraction_mode} (imitate/explore)
626
+ - Input Mode: {input_mode} (image/text/hybrid)
627
+ - Variants: {variants_count}
628
+ - Production-Ready: Complete design systems generated
629
+
630
+ {IF extraction_mode == "explore":
631
+ Design Direction Selection:
632
+ - You selected: Option {selected_index} - {selected_direction.philosophy_name}
633
+ - Generated from {variants_count} contrasting design direction options
634
+ }
635
+
636
+ Generated Files:
637
+ {base_path}/style-extraction/
638
+ └── style-1/design-tokens.json
639
+ {IF extraction_mode == "explore":
640
+ {base_path}/.intermediates/style-analysis/analysis-options.json (design direction options + user selection)
641
+ }
642
+
643
+ Next: /workflow:ui-design:layout-extract --session {session_id} --targets "..."
644
+ OR: /workflow:ui-design:generate --session {session_id}
645
+ ```
646
+
647
+ ## Simple Bash Commands
648
+
649
+ ### Path Operations
650
+ ```bash
651
+ # Find design directory
652
+ bash(find .workflow -type d -name "design-run-*" | head -1)
653
+
654
+ # Expand image pattern
655
+ bash(ls {images_pattern})
656
+
657
+ # Create output directory
658
+ bash(mkdir -p {base_path}/style-extraction/)
659
+ ```
660
+
661
+ ### Validation Commands
662
+ ```bash
663
+ # Check if already extracted
664
+ bash(test -f {base_path}/style-extraction/style-1/design-tokens.json && echo "exists")
665
+
666
+ # Count variants
667
+ bash(ls {base_path}/style-extraction/style-* -d | wc -l)
668
+
669
+ # Validate JSON structure
670
+ bash(cat {base_path}/style-extraction/style-1/design-tokens.json | grep -q "colors" && echo "valid")
671
+ ```
672
+
673
+ ### File Operations
674
+ ```bash
675
+ # Load brainstorming context
676
+ bash(test -f .brainstorming/role analysis documents && cat it)
677
+
678
+ # Create directories (example for multiple variants)
679
+ bash(mkdir -p {base_path}/style-extraction/style-1)
680
+ bash(mkdir -p {base_path}/style-extraction/style-2)
681
+ bash(mkdir -p {base_path}/style-extraction/style-3)
682
+
683
+ # Verify output
684
+ bash(ls {base_path}/style-extraction/style-1/)
685
+ bash(test -f {base_path}/.intermediates/style-analysis/analysis-options.json && echo "saved")
686
+ ```
687
+
688
+ ## Output Structure
689
+
690
+ ```
691
+ {base_path}/
692
+ ├── .intermediates/ # Intermediate analysis files
693
+ └── style-analysis/
694
+ │ ├── computed-styles.json # Extracted CSS values from DOM (if URL available)
695
+ │ └── analysis-options.json # Design direction options + user selection (explore mode only)
696
+ └── style-extraction/ # Final design system
697
+ └── style-1/
698
+ └── design-tokens.json # Production-ready design tokens
699
+ ```
700
+
701
+ ## design-tokens.json Format
702
+
703
+ ```json
704
+ {
705
+ "colors": {
706
+ "brand": {"primary": "oklch(...)", "secondary": "oklch(...)", "accent": "oklch(...)"},
707
+ "surface": {"background": "oklch(...)", "elevated": "oklch(...)", "overlay": "oklch(...)"},
708
+ "semantic": {"success": "oklch(...)", "warning": "oklch(...)", "error": "oklch(...)", "info": "oklch(...)"},
709
+ "text": {"primary": "oklch(...)", "secondary": "oklch(...)", "tertiary": "oklch(...)", "inverse": "oklch(...)"},
710
+ "border": {"default": "oklch(...)", "strong": "oklch(...)", "subtle": "oklch(...)"}
711
+ },
712
+ "typography": {
713
+ "font_family": {...},
714
+ "font_size": {...},
715
+ "font_weight": {...},
716
+ "line_height": {...},
717
+ "letter_spacing": {...},
718
+ "combinations": {
719
+ "heading-primary": {"family": "var(--font-family-heading)", "size": "var(--font-size-3xl)", "weight": "var(--font-weight-bold)", "line_height": "var(--line-height-tight)", "letter_spacing": "var(--letter-spacing-tight)"},
720
+ "heading-secondary": {...},
721
+ "body-regular": {...},
722
+ "body-emphasis": {...},
723
+ "caption": {...},
724
+ "label": {...}
725
+ }
726
+ },
727
+ "spacing": {"0": "0", "1": "0.25rem", ..., "24": "6rem"},
728
+ "opacity": {"0": "0", "10": "0.1", "20": "0.2", "40": "0.4", "60": "0.6", "80": "0.8", "90": "0.9", "100": "1"},
729
+ "border_radius": {"none": "0", "sm": "0.25rem", ..., "full": "9999px"},
730
+ "shadows": {"sm": "...", "md": "...", "lg": "...", "xl": "..."},
731
+ "component_styles": {
732
+ "button": {
733
+ "primary": {"background": "var(--color-brand-primary)", "color": "var(--color-text-inverse)", "padding": "var(--spacing-3) var(--spacing-6)", "border_radius": "var(--border-radius-md)", "font_weight": "var(--font-weight-semibold)"},
734
+ "secondary": {...},
735
+ "tertiary": {...}
736
+ },
737
+ "card": {
738
+ "default": {"background": "var(--color-surface-elevated)", "padding": "var(--spacing-6)", "border_radius": "var(--border-radius-lg)", "shadow": "var(--shadow-md)"},
739
+ "interactive": {...}
740
+ },
741
+ "input": {
742
+ "default": {"border": "1px solid var(--color-border-default)", "padding": "var(--spacing-3)", "border_radius": "var(--border-radius-md)", "background": "var(--color-surface-background)"},
743
+ "focus": {...},
744
+ "error": {...}
745
+ }
746
+ },
747
+ "breakpoints": {"sm": "640px", ..., "2xl": "1536px"}
748
+ }
749
+ ```
750
+
751
+ **Requirements**: OKLCH colors, complete coverage, semantic naming, WCAG AA compliance, typography combinations, component style presets, opacity scale
752
+
753
+ ## Error Handling
754
+
755
+ ### Common Errors
756
+ ```
757
+ ERROR: No images found
758
+ → Check glob pattern
759
+
760
+ ERROR: Invalid prompt
761
+ → Provide non-empty string
762
+
763
+ ERROR: Claude JSON parsing error
764
+ → Retry with stricter format
765
+ ```
766
+
767
+ ## Key Features
768
+
769
+ - **Direct Design System Generation** - Complete design-tokens.json + style-guide.md in one step
770
+ - **AI-Driven Design Space Exploration** - 6D attribute space analysis for maximum contrast
771
+ - **Variant-Specific Directions** - Each variant has unique philosophy, keywords, anti-patterns
772
+ - **Maximum Contrast Guarantee** - Variants maximally distant in attribute space
773
+ - **Flexible Input** - Images, text, or hybrid mode
774
+ - **Production-Ready** - OKLCH colors, WCAG AA compliance, semantic naming
775
+ - **Agent-Driven** - Autonomous multi-file generation with ui-design-agent
776
+
777
+