--- 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/runs/run-xxx/.design\"] [--style-variants 3] [--layout-variants 3]" examples: - /workflow:ui-design:generate --base-path ".workflow/WFS-auth/runs/run-xxx/.design" --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 "./design-session-xxx/.design" --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 ## Execution Protocol ### Phase 1: Path Resolution & Context Loading (Enhanced) ```bash # Determine base path IF --base-path provided: base_path = {provided_base_path} # e.g., ".workflow/WFS-xxx/runs/run-xxx/.design" ELSE IF --session provided: session_id = {provided_session} base_path = ".workflow/WFS-{session_id}/latest/.design" # Use latest run ELSE: # Standalone mode: search for most recent design-session in scratchpad base_path = find_latest_design_session(".workflow/.scratchpad/") # Determine style and layout variant counts style_variants = --style-variants OR 3 # Default to 3 layout_variants = --layout-variants OR 3 # Default to 3 VALIDATE: 1 <= style_variants <= 5 VALIDATE: 1 <= layout_variants <= 5 # Enhanced page list parsing page_list = [] page_source = "none" # Priority 1: Explicit --pages parameter (with robust parsing) IF --pages provided: # Enhanced parsing: handle spaces, multiple delimiters raw_pages = {--pages value} # Split by comma, semicolon, or Chinese comma, then clean page_list = split_and_clean(raw_pages, delimiters=[",", ";", "、"]) # Clean each page name: strip whitespace, convert to lowercase page_list = [p.strip().lower().replace(" ", "-") for p in page_list if p.strip()] page_source = "explicit_parameter" REPORT: "📋 Using provided pages: {', '.join(page_list)}" # Priority 2: Extract from synthesis-specification.md ELSE IF --session: # Read synthesis-specification.md to extract page requirements synthesis_spec = Read(.workflow/WFS-{session}/.brainstorming/synthesis-specification.md) page_list = extract_pages_from_synthesis(synthesis_spec) page_source = "synthesis_specification" REPORT: "📋 Extracted pages from synthesis: {', '.join(page_list)}" # Priority 3: Detect from existing prototypes ELSE: # Infer from existing prototypes or default page_list = detect_from_prototypes({base_path}/prototypes/) IF page_list: page_source = "existing_prototypes" REPORT: "📋 Detected pages from existing prototypes: {', '.join(page_list)}" ELSE: page_list = ["home"] page_source = "default" REPORT: "⚠️ No pages found, using default: 'home'" # Validation: ensure page names are valid validated_pages = [] invalid_pages = [] FOR page IN page_list: # Validate format: must start with letter/number, can contain alphanumeric, hyphens, underscores IF regex_match(page, r"^[a-z0-9][a-z0-9_-]*$"): validated_pages.append(page) ELSE: invalid_pages.append(page) IF invalid_pages: REPORT: "⚠️ Skipped invalid page names: {', '.join(invalid_pages)}" REPORT: " Valid format: lowercase, alphanumeric, hyphens, underscores" VALIDATE: validated_pages not empty, "No valid pages found" # Use validated list page_list = validated_pages REPORT: "✅ Final page list ({len(page_list)}): {', '.join(page_list)}" # Verify design systems exist for all styles 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 # Load requirements (if integrated mode) IF --session: synthesis_spec = Read(.workflow/WFS-{session}/.brainstorming/synthesis-specification.md) ``` ### Phase 2: Optimized Matrix UI Generation (Layered, Template-Based) **Strategy**: Decouple HTML structure from CSS styling to eliminate redundancy. - **Layer 1**: Generate `L × P` layout templates (HTML structure + structural CSS) - **Layer 2**: Instantiate `S × L × P` final prototypes via fast file operations **Performance**: Reduces core generation tasks from `O(S×L×P)` to `O(L×P)` — **`S` times faster** --- #### Phase 2a: Layout Template Generation (Parallel Agent Execution) Generate style-agnostic layout templates for each `{page} × {layout}` combination. Total agent tasks: `layout_variants × len(page_list)` ```bash # Create template directory CREATE: {base_path}/prototypes/_templates/ CREATE: {base_path}/prototypes/ # Launch layout_variants × page_list parallel 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. ## Context LAYOUT_ID: {layout_id} PAGE: {page} BASE_PATH: {base_path} {IF --session: - Requirements: .workflow/WFS-{session}/.brainstorming/synthesis-specification.md} ## Task Generate TWO files that work together as a reusable template: **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 You are responsible for Layout {layout_id}. Apply this strategy CONSISTENTLY to all styles in your batch. {IF layout_id == 1} **Layout 1: Classic Hierarchy** - Traditional F-pattern reading flow - Top navigation with sidebar - Card-based content sections {ELSE IF layout_id == 2} **Layout 2: Modern Asymmetric** - Z-pattern visual flow - Split-screen hero sections - Grid-based modular content {ELSE IF layout_id == 3} **Layout 3: Minimal Focus** - Centered single-column content - Floating navigation - Generous whitespace and breathing room {ELSE} **Layout {layout_id}: Custom Variant** - Develop a unique and consistent layout structure different from the standard three {ENDIF} Adapt this strategy to each page's purpose while maintaining layout consistency. ## Token Usage Requirements (STRICT) - For each style, load design tokens from its specific file: {base_path}/style-consolidation/style-{style_id}/design-tokens.json - 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 (e.g., #4F46E5, 16px) allowed ## HTML Requirements - Semantic HTML5 elements (
,