--- name: batch-generate description: Prompt-driven batch UI generation using target-style-centric parallel execution with design token application argument-hint: [--targets ""] [--target-type "page|component"] [--device-type "desktop|mobile|tablet|responsive"] [--base-path ] [--session ] [--style-variants ] [--layout-variants ] allowed-tools: TodoWrite(*), Read(*), Write(*), Task(ui-design-agent), Bash(*), mcp__exa__web_search_exa(*) --- # Batch Generate UI Prototypes (/workflow:ui-design:batch-generate) ## Overview Prompt-driven UI generation with intelligent target extraction and **target-style-centric batch execution**. Each agent handles all layouts for one target × style combination. **Strategy**: Prompt → Targets → Batched Generation - **Prompt-driven**: Describe what to build, command extracts targets - **Agent scope**: Each of `T × S` agents generates `L` layouts - **Parallel batching**: Max 6 concurrent agents for optimal throughput - **Component isolation**: Complete task independence - **Style-aware**: HTML adapts to design_attributes - **Self-contained CSS**: Direct token values (no var() refs) **Supports**: Pages (full layouts) and components (isolated elements) ## Phase 1: Setup & Validation ### Step 1: Parse Prompt & Resolve Configuration ```bash # Parse required parameters prompt_text = --prompt device_type = --device-type OR "responsive" # Extract targets from prompt IF --targets: target_list = split_and_clean(--targets) ELSE: target_list = extract_targets_from_prompt(prompt_text) # See helpers IF NOT target_list: target_list = ["home"] # Fallback # Detect target type target_type = --target-type OR detect_target_type(target_list) # Resolve base path IF --base-path: base_path = --base-path ELSE IF --session: relative_path=$(find .workflow/WFS-{session} -type d -name "design-run-*" -printf "%T@ %p\n" | sort -nr | head -1 | cut -d' ' -f2) base_path=$(cd "$relative_path" && pwd) ELSE: relative_path=$(find .workflow -type d -name "design-run-*" -printf "%T@ %p\n" | sort -nr | head -1 | cut -d' ' -f2) base_path=$(cd "$relative_path" && pwd) # Verify absolute path bash(test -d "$base_path" && echo "✓ Base path: $base_path" || echo "✗ Path not found") # Get variant counts style_variants = --style-variants OR bash(ls {base_path}/style-extraction/style-* -d | wc -l) layout_variants = --layout-variants OR 3 ``` **Output**: `base_path`, `target_list[]`, `target_type`, `device_type`, `style_variants`, `layout_variants` ### Step 2: Validate Design Tokens ```bash # Check design tokens exist bash(test -f {base_path}/style-extraction/style-1/design-tokens.json && echo "valid") # Load design space analysis (optional, from intermediates) IF exists({base_path}/.intermediates/style-analysis/design-space-analysis.json): design_space_analysis = Read({base_path}/.intermediates/style-analysis/design-space-analysis.json) ``` **Output**: `design_tokens_valid`, `design_space_analysis` ### Step 3: Gather Layout Inspiration (Reuse or Create) ```bash # Check if layout inspirations already exist from layout-extract phase inspiration_source = "{base_path}/.intermediates/layout-analysis/inspirations" FOR target IN target_list: # Priority 1: Reuse existing inspiration from layout-extract IF exists({inspiration_source}/{target}-layout-ideas.txt): # Reuse existing inspiration (no action needed) REPORT: "Using existing layout inspiration for {target}" ELSE: # Priority 2: Generate new inspiration via MCP bash(mkdir -p {inspiration_source}) search_query = "{target} {target_type} layout patterns variations" mcp__exa__web_search_exa(query=search_query, numResults=5) # Extract context from prompt for this target target_requirements = extract_relevant_context_from_prompt(prompt_text, target) # Write inspiration file to centralized location Write({inspiration_source}/{target}-layout-ideas.txt, inspiration_content) REPORT: "Created new layout inspiration for {target}" ``` **Output**: `T` inspiration text files (reused or created in `.intermediates/layout-analysis/inspirations/`) ## Phase 2: Target-Style-Centric Batch Generation (Agent) **Executor**: `Task(ui-design-agent)` × `T × S` tasks in **batched parallel** (max 6 concurrent) ### Step 1: Calculate Batch Execution Plan ```bash bash(mkdir -p {base_path}/prototypes) # Build task list: T × S combinations MAX_PARALLEL = 6 total_tasks = T × S total_batches = ceil(total_tasks / MAX_PARALLEL) # Initialize batch tracking TodoWrite({todos: [ {content: "Batch 1/{batches}: Generate 6 tasks", status: "in_progress"}, {content: "Batch 2/{batches}: Generate 6 tasks", status: "pending"}, ... ]}) ``` ### Step 2: Launch Batched Agent Tasks For each batch (up to 6 parallel tasks): ```javascript Task(ui-design-agent): ` [TARGET_STYLE_UI_GENERATION_FROM_PROMPT] 🎯 ONE component: {target} × Style-{style_id} ({philosophy_name}) Generate: {layout_variants} × 2 files (HTML + CSS per layout) PROMPT CONTEXT: {target_requirements} # Extracted from original prompt TARGET: {target} | TYPE: {target_type} | STYLE: {style_id}/{style_variants} BASE_PATH: {base_path} DEVICE: {device_type} ${design_attributes ? "DESIGN_ATTRIBUTES: " + JSON.stringify(design_attributes) : ""} ## Reference - Layout inspiration: Read("{base_path}/.intermediates/layout-analysis/inspirations/{target}-layout-ideas.txt") - Design tokens: Read("{base_path}/style-extraction/style-{style_id}/design-tokens.json") Parse ALL token values including: * colors, typography (with combinations), spacing, opacity * border_radius, shadows, breakpoints * component_styles (button, card, input variants) ${design_attributes ? "- Adapt DOM to: density, visual_weight, formality, organic_vs_geometric" : ""} ## Generation For EACH layout (1 to {layout_variants}): 1. HTML: {base_path}/prototypes/{target}-style-{style_id}-layout-N.html - Complete HTML5: , , - CSS ref: - Semantic:
,