--- name: generate description: Generate UI prototypes in matrix mode (style × layout combinations) usage: /workflow:ui-design:generate [--pages ""] [--base-path ] [--session ] [--style-variants ] [--layout-variants ] argument-hint: "[--pages \"dashboard,auth\"] [--base-path \".workflow/WFS-xxx/design-run-xxx\"] [--style-variants 3] [--layout-variants 3]" examples: - /workflow:ui-design:generate --base-path ".workflow/WFS-auth/design-run-20250109-143022" --pages "dashboard,settings" --style-variants 3 --layout-variants 3 - /workflow:ui-design:generate --session WFS-auth --pages "home,pricing" --style-variants 2 --layout-variants 2 - /workflow:ui-design:generate --base-path "./.workflow/.design/run-20250109-150533" --style-variants 3 --layout-variants 3 allowed-tools: TodoWrite(*), Read(*), Write(*), Task(conceptual-planning-agent), Bash(*) --- # UI Generation Command (Matrix Mode) ## Overview Generate production-ready UI prototypes (HTML/CSS) in `style × layout` matrix mode, strictly adhering to consolidated design tokens from separate style design systems. ## Core Philosophy - **Matrix-Only**: Single mode generating `style_variants × layout_variants × pages` prototypes - **Agent-Driven**: Uses `Task(conceptual-planning-agent)` for parallel generation - **Token-Driven**: All styles reference per-style design-tokens.json; no hardcoded values - **Production-Ready**: Semantic HTML5, ARIA attributes, responsive design - **Template-Based**: Decouples HTML structure from CSS styling for optimal performance ## Execution Protocol ### Phase 0: Load Layout Strategies ```bash # Determine base path first (using same logic as Phase 1) IF --base-path provided: base_path = {provided_base_path} ELSE IF --session provided: # Find latest design run in session base_path = find_latest_path_matching(".workflow/WFS-{session}/design-*") ELSE: base_path = find_latest_path_matching(".workflow/.design/*") # Load layout strategies from consolidation output layout_strategies_path = "{base_path}/style-consolidation/layout-strategies.json" VERIFY: exists(layout_strategies_path), "Layout strategies not found. Run /workflow:ui-design:consolidate first." layout_strategies = Read(layout_strategies_path) layout_variants = layout_strategies.layout_variants_count REPORT: "📐 Loaded {layout_variants} layout strategies:" FOR strategy IN layout_strategies.strategies: REPORT: " - {strategy.name}: {strategy.description}" # Override layout_variants if --layout-variants is provided (for manual runs) IF --layout-variants provided: WARN: "Overriding layout strategies count from {layout_variants} to {provided_count}" layout_variants = {provided_count} VALIDATE: 1 <= layout_variants <= len(layout_strategies.strategies) # Trim strategies to match count layout_strategies.strategies = layout_strategies.strategies[0:layout_variants] ``` ### Phase 1: Path Resolution & Context Loading ```bash # 1. Determine base path IF --base-path provided: base_path = {provided_base_path} ELSE IF --session provided: base_path = ".workflow/WFS-{session}/latest/.design" ELSE: base_path = find_latest_design_session(".workflow/.scratchpad/") # 2. Determine style variant count (layout_variants already loaded in Phase 0) style_variants = --style-variants OR 3 # Default to 3 VALIDATE: 1 <= style_variants <= 5 # Note: layout_variants is loaded from layout-strategies.json in Phase 0 # 3. Enhanced page list parsing page_list = [] # Priority 1: Explicit --pages parameter IF --pages provided: raw_pages = {--pages value} # Split by comma, semicolon, or Chinese comma page_list = split_and_clean(raw_pages, delimiters=[",", ";", "、"]) # Clean: strip whitespace, lowercase, replace spaces with hyphens page_list = [p.strip().lower().replace(" ", "-") for p in page_list if p.strip()] REPORT: "📋 Using provided pages: {', '.join(page_list)}" # Priority 2: Extract from synthesis-specification.md ELSE IF --session: synthesis_spec = Read(.workflow/WFS-{session}/.brainstorming/synthesis-specification.md) page_list = extract_pages_from_synthesis(synthesis_spec) REPORT: "📋 Extracted pages from synthesis: {', '.join(page_list)}" # Priority 3: Detect from existing prototypes or default ELSE: page_list = detect_from_prototypes({base_path}/prototypes/) OR ["home"] REPORT: "📋 Detected/default pages: {', '.join(page_list)}" # 4. Validate page names validated_pages = [p for p in page_list if regex_match(p, r"^[a-z0-9][a-z0-9_-]*$")] invalid_pages = [p for p in page_list if p not in validated_pages] IF invalid_pages: REPORT: "⚠️ Skipped invalid page names: {', '.join(invalid_pages)}" VALIDATE: validated_pages not empty, "No valid pages found" page_list = validated_pages # 5. Verify design systems exist FOR style_id IN range(1, style_variants + 1): VERIFY: {base_path}/style-consolidation/style-{style_id}/design-tokens.json exists VERIFY: {base_path}/style-consolidation/style-{style_id}/style-guide.md exists # 6. Load requirements (if integrated mode) IF --session: synthesis_spec = Read(.workflow/WFS-{session}/.brainstorming/synthesis-specification.md) ``` ### Phase 1.5: Implementation Pattern Research (Exa MCP) ```bash # Step 1: Extract project context and technology preferences project_context = "" tech_stack_hints = [] IF --session: # Load brainstorming artifacts to understand tech requirements IF exists(.workflow/WFS-{session}/.brainstorming/synthesis-specification.md): project_context = Read(.workflow/WFS-{session}/.brainstorming/synthesis-specification.md) tech_stack_hints = extract_tech_stack(project_context) # e.g., "React", "Vue", "vanilla JS" IF exists(.workflow/WFS-{session}/.brainstorming/system-architect/analysis.md): arch_context = Read(.workflow/WFS-{session}/.brainstorming/system-architect/analysis.md) tech_stack_hints.extend(extract_tech_stack(arch_context)) # Step 2: Extract page types and requirements page_types = classify_pages(page_list) # e.g., "dashboard", "auth", "settings" layout_names = [s.name for s in layout_strategies.strategies] REPORT: "🔍 Researching modern UI implementation patterns..." # Step 3: Multi-dimensional implementation research using Exa MCP exa_queries = { "component_patterns": f"modern UI component implementation patterns {' '.join(tech_stack_hints)} 2024 2025", "responsive_design": f"responsive web design best practices mobile-first {' '.join(page_types)} 2024", "accessibility": f"web accessibility ARIA attributes implementation WCAG 2.2 {' '.join(page_types)}", "html_semantics": f"semantic HTML5 structure best practices {' '.join(page_types)} modern", "css_architecture": f"CSS architecture design tokens custom properties BEM {' '.join(tech_stack_hints)}" } implementation_research = {} FOR category, query IN exa_queries.items(): REPORT: f" Searching {category}..." implementation_research[category] = mcp__exa__get_code_context_exa( query=query, tokensNum="dynamic" ) REPORT: "✅ Implementation research complete:" REPORT: " - Component patterns and best practices" REPORT: " - Responsive design strategies" REPORT: " - Accessibility implementation guides" REPORT: " - Semantic HTML structures" REPORT: " - CSS architecture patterns" ``` ### Phase 2: Optimized Matrix UI Generation **Strategy**: Two-layer generation reduces complexity from `O(S×L×P)` to `O(L×P)`, achieving **`S` times faster** performance. - **Layer 1**: Generate `L × P` layout templates (HTML structure + structural CSS) with modern best practices - **Layer 2**: Instantiate `S × L × P` final prototypes via fast file operations #### Phase 2a: Layout Template Generation (Research-Informed) Generate style-agnostic layout templates for each `{page} × {layout}` combination. Total agent tasks: `layout_variants × len(page_list)` ```bash # Create directories CREATE: {base_path}/prototypes/_templates/ CREATE: {base_path}/prototypes/ # Launch parallel template generation tasks FOR layout_id IN range(1, layout_variants + 1): FOR page IN page_list: Task(conceptual-planning-agent): " [UI_LAYOUT_TEMPLATE_GENERATION] Generate a **style-agnostic** layout template for a specific page and layout strategy, informed by modern web development best practices. ## Context LAYOUT_ID: {layout_id} PAGE: {page} BASE_PATH: {base_path} {IF --session: - Requirements: .workflow/WFS-{session}/.brainstorming/synthesis-specification.md} ## Implementation Research (from web, 2024-2025) COMPONENT PATTERNS: {implementation_research.component_patterns} RESPONSIVE DESIGN: {implementation_research.responsive_design} ACCESSIBILITY GUIDELINES: {implementation_research.accessibility} HTML SEMANTICS: {implementation_research.html_semantics} CSS ARCHITECTURE: {implementation_research.css_architecture} ## Task Generate TWO files that work together as a reusable template, incorporating insights from the implementation research above: **File 1**: `{page}-layout-{layout_id}.html` - Semantic HTML5 structure WITHOUT any style-specific values - Use placeholder links for stylesheets: ```html ``` - Include all semantic elements, ARIA attributes, and responsive structure - NO inline styles, NO hardcoded colors/fonts/spacing **File 2**: `{page}-layout-{layout_id}.css` - Structural CSS rules using CSS variable references - ALL values MUST use `var()` functions (e.g., `background-color: var(--color-surface-background);`) - NO hardcoded values (e.g., #4F46E5, 16px, Arial) - BEM or semantic class naming - Mobile-first responsive design using token-based breakpoints ## Layout Diversity Strategy Apply the following strategy from the planned layout strategies (loaded from layout-strategies.json): **Layout ID**: {layout_id} **Name**: {layout_strategies.strategies[layout_id - 1].name} **Description**: {layout_strategies.strategies[layout_id - 1].description} Apply this strategy CONSISTENTLY to all styles. ## Token Usage Requirements (STRICT) - All colors: var(--color-brand-primary), var(--color-surface-background), etc. - All spacing: var(--spacing-4), var(--spacing-6), etc. - All typography: var(--font-family-heading), var(--font-size-lg), etc. - NO hardcoded values allowed ## HTML Requirements (Apply Modern Best Practices from Research) - Semantic HTML5 elements (
,