Skip to content

An AI skill that provides design intelligence for building professional UI/UX across multiple platforms.

feat: Add design system persistence with Master + Overrides pattern (#91)

mmcc9988f5978e096b84
diff --git a/.agent/workflows/ui-ux-pro-max.md b/.agent/workflows/ui-ux-pro-max.md
index f93712d..f64bb81 100644
--- a/.agent/workflows/ui-ux-pro-max.md
+++ b/.agent/workflows/ui-ux-pro-max.md
@@ -1,7 +1,3 @@
----
-description: Plan and implement UI
----
-
# ui-ux-pro-max
Comprehensive design guide for web and mobile applications. Contains 50+ styles, 97 color palettes, 57 font pairings, 99 UX guidelines, and 25 chart types across 9 technology stacks. Searchable database with priority-based recommendations.
@@ -64,6 +60,31 @@ This command:
python3 .shared/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for hierarchical retrieval across sessions, add `--persist`:
+
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
@@ -89,8 +110,9 @@ Get implementation-specific best practices. If user doesn't specify a stack, **d
```bash
python3 .shared/ui-ux-pro-max/scripts/search.py "<keyword>" --stack html-tailwind
```
-Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`, `jetpack-compose`
+Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`, `jetpack-compose`
+, `jetpack-compose`
---
## Search Reference
@@ -263,4 +285,4 @@ Before delivering UI code, verify these items:
- [ ] All images have alt text
- [ ] Form inputs have labels
- [ ] Color is not the only indicator
-- [ ] `prefers-reduced-motion` respected
\ No newline at end of file
+- [ ] `prefers-reduced-motion` respected
diff --git a/.claude/skills/ui-ux-pro-max/SKILL.md b/.claude/skills/ui-ux-pro-max/SKILL.md
index 782f7ce..3edddb4 100644
--- a/.claude/skills/ui-ux-pro-max/SKILL.md
+++ b/.claude/skills/ui-ux-pro-max/SKILL.md
@@ -149,6 +149,40 @@ This command:
python3 .claude/skills/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for **hierarchical retrieval across sessions**, add `--persist`:
+
+```bash
+python3 .claude/skills/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .claude/skills/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
+**Context-aware retrieval prompt:**
+```
+I am building the [Page Name] page. Please read design-system/MASTER.md.
+Also check if design-system/pages/[page-name].md exists.
+If the page file exists, prioritize its rules.
+If not, use the Master rules exclusively.
+Now, generate the code...
+```
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
diff --git a/.claude/skills/ui-ux-pro-max/scripts/design_system.py b/.claude/skills/ui-ux-pro-max/scripts/design_system.py
index 4e19b52..f2e1898 100644
--- a/.claude/skills/ui-ux-pro-max/scripts/design_system.py
+++ b/.claude/skills/ui-ux-pro-max/scripts/design_system.py
@@ -7,10 +7,16 @@ to generate comprehensive design system recommendations.
Usage:
from design_system import generate_design_system
result = generate_design_system("SaaS dashboard", "My Project")
+
+ # With persistence (Master + Overrides pattern)
+ result = generate_design_system("SaaS dashboard", "My Project", persist=True)
+ result = generate_design_system("SaaS dashboard", "My Project", persist=True, page="dashboard")
"""
import csv
import json
+import os
+from datetime import datetime
from pathlib import Path
from core import search, DATA_DIR
@@ -452,7 +458,8 @@ def format_markdown(design_system: dict) -> str:
# ============ MAIN ENTRY POINT ============
-def generate_design_system(query: str, project_name: str = None, output_format: str = "ascii") -> str:
+def generate_design_system(query: str, project_name: str = None, output_format: str = "ascii",
+ persist: bool = False, page: str = None, output_dir: str = None) -> str:
"""
Main entry point for design system generation.
@@ -460,18 +467,422 @@ def generate_design_system(query: str, project_name: str = None, output_format:
query: Search query (e.g., "SaaS dashboard", "e-commerce luxury")
project_name: Optional project name for output header
output_format: "ascii" (default) or "markdown"
+ persist: If True, save design system to design-system/ folder
+ page: Optional page name for page-specific override file
+ output_dir: Optional output directory (defaults to current working directory)
Returns:
Formatted design system string
"""
generator = DesignSystemGenerator()
design_system = generator.generate(query, project_name)
+
+ # Persist to files if requested
+ if persist:
+ persist_design_system(design_system, page, output_dir)
if output_format == "markdown":
return format_markdown(design_system)
return format_ascii_box(design_system)
+# ============ PERSISTENCE FUNCTIONS ============
+def persist_design_system(design_system: dict, page: str = None, output_dir: str = None) -> dict:
+ """
+ Persist design system to design-system/ folder using Master + Overrides pattern.
+
+ Args:
+ design_system: The generated design system dictionary
+ page: Optional page name for page-specific override file
+ output_dir: Optional output directory (defaults to current working directory)
+
+ Returns:
+ dict with created file paths and status
+ """
+ base_dir = Path(output_dir) if output_dir else Path.cwd()
+ design_system_dir = base_dir / "design-system"
+ pages_dir = design_system_dir / "pages"
+
+ created_files = []
+
+ # Create directories
+ design_system_dir.mkdir(parents=True, exist_ok=True)
+ pages_dir.mkdir(parents=True, exist_ok=True)
+
+ master_file = design_system_dir / "MASTER.md"
+
+ # Generate and write MASTER.md
+ master_content = format_master_md(design_system)
+ with open(master_file, 'w', encoding='utf-8') as f:
+ f.write(master_content)
+ created_files.append(str(master_file))
+
+ # If page is specified, create page override file
+ if page:
+ page_file = pages_dir / f"{page.lower().replace(' ', '-')}.md"
+ page_content = format_page_override_md(design_system, page)
+ with open(page_file, 'w', encoding='utf-8') as f:
+ f.write(page_content)
+ created_files.append(str(page_file))
+
+ return {
+ "status": "success",
+ "design_system_dir": str(design_system_dir),
+ "created_files": created_files
+ }
+
+
+def format_master_md(design_system: dict) -> str:
+ """Format design system as MASTER.md with hierarchical override logic."""
+ project = design_system.get("project_name", "PROJECT")
+ pattern = design_system.get("pattern", {})
+ style = design_system.get("style", {})
+ colors = design_system.get("colors", {})
+ typography = design_system.get("typography", {})
+ effects = design_system.get("key_effects", "")
+ anti_patterns = design_system.get("anti_patterns", "")
+
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+
+ lines = []
+
+ # Logic header
+ lines.append("# Design System Master File")
+ lines.append("")
+ lines.append("> **LOGIC:** When building a specific page, first check `design-system/pages/[page-name].md`.")
+ lines.append("> If that file exists, its rules **override** this Master file.")
+ lines.append("> If not, strictly follow the rules below.")
+ lines.append("")
+ lines.append("---")
+ lines.append("")
+ lines.append(f"**Project:** {project}")
+ lines.append(f"**Generated:** {timestamp}")
+ lines.append(f"**Category:** {design_system.get('category', 'General')}")
+ lines.append("")
+ lines.append("---")
+ lines.append("")
+
+ # Global Rules section
+ lines.append("## Global Rules")
+ lines.append("")
+
+ # Color Palette
+ lines.append("### Color Palette")
+ lines.append("")
+ lines.append("| Role | Hex | CSS Variable |")
+ lines.append("|------|-----|--------------|")
+ lines.append(f"| Primary | `{colors.get('primary', '#2563EB')}` | `--color-primary` |")
+ lines.append(f"| Secondary | `{colors.get('secondary', '#3B82F6')}` | `--color-secondary` |")
+ lines.append(f"| CTA/Accent | `{colors.get('cta', '#F97316')}` | `--color-cta` |")
+ lines.append(f"| Background | `{colors.get('background', '#F8FAFC')}` | `--color-background` |")
+ lines.append(f"| Text | `{colors.get('text', '#1E293B')}` | `--color-text` |")
+ lines.append("")
+ if colors.get("notes"):
+ lines.append(f"**Color Notes:** {colors.get('notes', '')}")
+ lines.append("")
+
+ # Typography
+ lines.append("### Typography")
+ lines.append("")
+ lines.append(f"- **Heading Font:** {typography.get('heading', 'Inter')}")
+ lines.append(f"- **Body Font:** {typography.get('body', 'Inter')}")
+ if typography.get("mood"):
+ lines.append(f"- **Mood:** {typography.get('mood', '')}")
+ if typography.get("google_fonts_url"):
+ lines.append(f"- **Google Fonts:** [{typography.get('heading', '')} + {typography.get('body', '')}]({typography.get('google_fonts_url', '')})")
+ lines.append("")
+ if typography.get("css_import"):
+ lines.append("**CSS Import:**")
+ lines.append("```css")
+ lines.append(typography.get("css_import", ""))
+ lines.append("```")
+ lines.append("")
+
+ # Spacing Variables
+ lines.append("### Spacing Variables")
+ lines.append("")
+ lines.append("| Token | Value | Usage |")
+ lines.append("|-------|-------|-------|")
+ lines.append("| `--space-xs` | `4px` / `0.25rem` | Tight gaps |")
+ lines.append("| `--space-sm` | `8px` / `0.5rem` | Icon gaps, inline spacing |")
+ lines.append("| `--space-md` | `16px` / `1rem` | Standard padding |")
+ lines.append("| `--space-lg` | `24px` / `1.5rem` | Section padding |")
+ lines.append("| `--space-xl` | `32px` / `2rem` | Large gaps |")
+ lines.append("| `--space-2xl` | `48px` / `3rem` | Section margins |")
+ lines.append("| `--space-3xl` | `64px` / `4rem` | Hero padding |")
+ lines.append("")
+
+ # Shadow Depths
+ lines.append("### Shadow Depths")
+ lines.append("")
+ lines.append("| Level | Value | Usage |")
+ lines.append("|-------|-------|-------|")
+ lines.append("| `--shadow-sm` | `0 1px 2px rgba(0,0,0,0.05)` | Subtle lift |")
+ lines.append("| `--shadow-md` | `0 4px 6px rgba(0,0,0,0.1)` | Cards, buttons |")
+ lines.append("| `--shadow-lg` | `0 10px 15px rgba(0,0,0,0.1)` | Modals, dropdowns |")
+ lines.append("| `--shadow-xl` | `0 20px 25px rgba(0,0,0,0.15)` | Hero images, featured cards |")
+ lines.append("")
+
+ # Component Specs section
+ lines.append("---")
+ lines.append("")
+ lines.append("## Component Specs")
+ lines.append("")
+
+ # Buttons
+ lines.append("### Buttons")
+ lines.append("")
+ lines.append("```css")
+ lines.append("/* Primary Button */")
+ lines.append(".btn-primary {")
+ lines.append(f" background: {colors.get('cta', '#F97316')};")
+ lines.append(" color: white;")
+ lines.append(" padding: 12px 24px;")
+ lines.append(" border-radius: 8px;")
+ lines.append(" font-weight: 600;")
+ lines.append(" transition: all 200ms ease;")
+ lines.append(" cursor: pointer;")
+ lines.append("}")
+ lines.append("")
+ lines.append(".btn-primary:hover {")
+ lines.append(" opacity: 0.9;")
+ lines.append(" transform: translateY(-1px);")
+ lines.append("}")
+ lines.append("")
+ lines.append("/* Secondary Button */")
+ lines.append(".btn-secondary {")
+ lines.append(f" background: transparent;")
+ lines.append(f" color: {colors.get('primary', '#2563EB')};")
+ lines.append(f" border: 2px solid {colors.get('primary', '#2563EB')};")
+ lines.append(" padding: 12px 24px;")
+ lines.append(" border-radius: 8px;")
+ lines.append(" font-weight: 600;")
+ lines.append(" transition: all 200ms ease;")
+ lines.append(" cursor: pointer;")
+ lines.append("}")
+ lines.append("```")
+ lines.append("")
+
+ # Cards
+ lines.append("### Cards")
+ lines.append("")
+ lines.append("```css")
+ lines.append(".card {")
+ lines.append(f" background: {colors.get('background', '#FFFFFF')};")
+ lines.append(" border-radius: 12px;")
+ lines.append(" padding: 24px;")
+ lines.append(" box-shadow: var(--shadow-md);")
+ lines.append(" transition: all 200ms ease;")
+ lines.append(" cursor: pointer;")
+ lines.append("}")
+ lines.append("")
+ lines.append(".card:hover {")
+ lines.append(" box-shadow: var(--shadow-lg);")
+ lines.append(" transform: translateY(-2px);")
+ lines.append("}")
+ lines.append("```")
+ lines.append("")
+
+ # Inputs
+ lines.append("### Inputs")
+ lines.append("")
+ lines.append("```css")
+ lines.append(".input {")
+ lines.append(" padding: 12px 16px;")
+ lines.append(" border: 1px solid #E2E8F0;")
+ lines.append(" border-radius: 8px;")
+ lines.append(" font-size: 16px;")
+ lines.append(" transition: border-color 200ms ease;")
+ lines.append("}")
+ lines.append("")
+ lines.append(".input:focus {")
+ lines.append(f" border-color: {colors.get('primary', '#2563EB')};")
+ lines.append(" outline: none;")
+ lines.append(f" box-shadow: 0 0 0 3px {colors.get('primary', '#2563EB')}20;")
+ lines.append("}")
+ lines.append("```")
+ lines.append("")
+
+ # Modals
+ lines.append("### Modals")
+ lines.append("")
+ lines.append("```css")
+ lines.append(".modal-overlay {")
+ lines.append(" background: rgba(0, 0, 0, 0.5);")
+ lines.append(" backdrop-filter: blur(4px);")
+ lines.append("}")
+ lines.append("")
+ lines.append(".modal {")
+ lines.append(" background: white;")
+ lines.append(" border-radius: 16px;")
+ lines.append(" padding: 32px;")
+ lines.append(" box-shadow: var(--shadow-xl);")
+ lines.append(" max-width: 500px;")
+ lines.append(" width: 90%;")
+ lines.append("}")
+ lines.append("```")
+ lines.append("")
+
+ # Style section
+ lines.append("---")
+ lines.append("")
+ lines.append("## Style Guidelines")
+ lines.append("")
+ lines.append(f"**Style:** {style.get('name', 'Minimalism')}")
+ lines.append("")
+ if style.get("keywords"):
+ lines.append(f"**Keywords:** {style.get('keywords', '')}")
+ lines.append("")
+ if style.get("best_for"):
+ lines.append(f"**Best For:** {style.get('best_for', '')}")
+ lines.append("")
+ if effects:
+ lines.append(f"**Key Effects:** {effects}")
+ lines.append("")
+
+ # Layout Pattern
+ lines.append("### Page Pattern")
+ lines.append("")
+ lines.append(f"**Pattern Name:** {pattern.get('name', '')}")
+ lines.append("")
+ if pattern.get('conversion'):
+ lines.append(f"- **Conversion Strategy:** {pattern.get('conversion', '')}")
+ if pattern.get('cta_placement'):
+ lines.append(f"- **CTA Placement:** {pattern.get('cta_placement', '')}")
+ lines.append(f"- **Section Order:** {pattern.get('sections', '')}")
+ lines.append("")
+
+ # Anti-Patterns section
+ lines.append("---")
+ lines.append("")
+ lines.append("## Anti-Patterns (Do NOT Use)")
+ lines.append("")
+ if anti_patterns:
+ anti_list = [a.strip() for a in anti_patterns.split("+")]
+ for anti in anti_list:
+ if anti:
+ lines.append(f"- ❌ {anti}")
+ lines.append("")
+ lines.append("### Additional Forbidden Patterns")
+ lines.append("")
+ lines.append("- ❌ **Emojis as icons** — Use SVG icons (Heroicons, Lucide, Simple Icons)")
+ lines.append("- ❌ **Missing cursor:pointer** — All clickable elements must have cursor:pointer")
+ lines.append("- ❌ **Layout-shifting hovers** — Avoid scale transforms that shift layout")
+ lines.append("- ❌ **Low contrast text** — Maintain 4.5:1 minimum contrast ratio")
+ lines.append("- ❌ **Instant state changes** — Always use transitions (150-300ms)")
+ lines.append("- ❌ **Invisible focus states** — Focus states must be visible for a11y")
+ lines.append("")
+
+ # Pre-Delivery Checklist
+ lines.append("---")
+ lines.append("")
+ lines.append("## Pre-Delivery Checklist")
+ lines.append("")
+ lines.append("Before delivering any UI code, verify:")
+ lines.append("")
+ lines.append("- [ ] No emojis used as icons (use SVG instead)")
+ lines.append("- [ ] All icons from consistent icon set (Heroicons/Lucide)")
+ lines.append("- [ ] `cursor-pointer` on all clickable elements")
+ lines.append("- [ ] Hover states with smooth transitions (150-300ms)")
+ lines.append("- [ ] Light mode: text contrast 4.5:1 minimum")
+ lines.append("- [ ] Focus states visible for keyboard navigation")
+ lines.append("- [ ] `prefers-reduced-motion` respected")
+ lines.append("- [ ] Responsive: 375px, 768px, 1024px, 1440px")
+ lines.append("- [ ] No content hidden behind fixed navbars")
+ lines.append("- [ ] No horizontal scroll on mobile")
+ lines.append("")
+
+ return "\n".join(lines)
+
+
+def format_page_override_md(design_system: dict, page_name: str) -> str:
+ """Format a page-specific override file."""
+ project = design_system.get("project_name", "PROJECT")
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+ page_title = page_name.replace("-", " ").replace("_", " ").title()
+
+ lines = []
+
+ lines.append(f"# {page_title} Page Overrides")
+ lines.append("")
+ lines.append(f"> **PROJECT:** {project}")
+ lines.append(f"> **Generated:** {timestamp}")
+ lines.append("")
+ lines.append("> ⚠️ **IMPORTANT:** Rules in this file **override** the Master file (`design-system/MASTER.md`).")
+ lines.append("> Only deviations from the Master are documented here. For all other rules, refer to the Master.")
+ lines.append("")
+ lines.append("---")
+ lines.append("")
+
+ # Page-specific sections (template)
+ lines.append("## Page-Specific Rules")
+ lines.append("")
+ lines.append("<!-- Document only the DEVIATIONS from MASTER.md for this page -->")
+ lines.append("")
+ lines.append("### Layout Overrides")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Example: This page uses a different max-width -->")
+ lines.append("max-width: 1400px (instead of default 1200px)")
+ lines.append("```")
+ lines.append("")
+ lines.append("### Color Overrides")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Example: This page uses a darker background -->")
+ lines.append("No overrides - use Master colors")
+ lines.append("```")
+ lines.append("")
+ lines.append("### Component Overrides")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Example: Cards on this page have different padding -->")
+ lines.append("No overrides - use Master component specs")
+ lines.append("```")
+ lines.append("")
+ lines.append("### Typography Overrides")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Example: Hero heading uses larger font size -->")
+ lines.append("No overrides - use Master typography")
+ lines.append("```")
+ lines.append("")
+
+ # Page-specific patterns
+ lines.append("---")
+ lines.append("")
+ lines.append("## Unique Page Elements")
+ lines.append("")
+ lines.append("<!-- Document any elements unique to this page -->")
+ lines.append("")
+ lines.append("### Hero Section")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Describe hero-specific styling if different from Master -->")
+ lines.append("```")
+ lines.append("")
+ lines.append("### Page-Specific Components")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- List any components only used on this page -->")
+ lines.append("```")
+ lines.append("")
+
+ # Notes section
+ lines.append("---")
+ lines.append("")
+ lines.append("## Notes")
+ lines.append("")
+ lines.append("<!-- Add any additional context for AI or developers -->")
+ lines.append("")
+ lines.append("- Refer to `design-system/MASTER.md` for all base rules")
+ lines.append("- Only add overrides here when this page deviates from the Master")
+ lines.append("- Delete placeholder sections if no overrides are needed")
+ lines.append("")
+
+ return "\n".join(lines)
+
+
# ============ CLI SUPPORT ============
if __name__ == "__main__":
import argparse
diff --git a/.claude/skills/ui-ux-pro-max/scripts/search.py b/.claude/skills/ui-ux-pro-max/scripts/search.py
index 00a38df..43e5fa5 100644
--- a/.claude/skills/ui-ux-pro-max/scripts/search.py
+++ b/.claude/skills/ui-ux-pro-max/scripts/search.py
@@ -4,14 +4,19 @@
UI/UX Pro Max Search - BM25 search engine for UI/UX style guides
Usage: python search.py "<query>" [--domain <domain>] [--stack <stack>] [--max-results 3]
python search.py "<query>" --design-system [-p "Project Name"]
+ python search.py "<query>" --design-system --persist [-p "Project Name"] [--page "dashboard"]
Domains: style, prompt, color, chart, landing, product, ux, typography
Stacks: html-tailwind, react, nextjs
+
+Persistence (Master + Overrides pattern):
+ --persist Save design system to design-system/MASTER.md
+ --page Also create a page-specific override file in design-system/pages/
"""
import argparse
from core import CSV_CONFIG, AVAILABLE_STACKS, MAX_RESULTS, search, search_stack
-from design_system import generate_design_system
+from design_system import generate_design_system, persist_design_system
def format_output(result):
@@ -51,13 +56,37 @@ if __name__ == "__main__":
parser.add_argument("--design-system", "-ds", action="store_true", help="Generate complete design system recommendation")
parser.add_argument("--project-name", "-p", type=str, default=None, help="Project name for design system output")
parser.add_argument("--format", "-f", choices=["ascii", "markdown"], default="ascii", help="Output format for design system")
+ # Persistence (Master + Overrides pattern)
+ parser.add_argument("--persist", action="store_true", help="Save design system to design-system/MASTER.md (creates hierarchical structure)")
+ parser.add_argument("--page", type=str, default=None, help="Create page-specific override file in design-system/pages/")
+ parser.add_argument("--output-dir", "-o", type=str, default=None, help="Output directory for persisted files (default: current directory)")
args = parser.parse_args()
# Design system takes priority
if args.design_system:
- result = generate_design_system(args.query, args.project_name, args.format)
+ result = generate_design_system(
+ args.query,
+ args.project_name,
+ args.format,
+ persist=args.persist,
+ page=args.page,
+ output_dir=args.output_dir
+ )
print(result)
+
+ # Print persistence confirmation
+ if args.persist:
+ print("\n" + "=" * 60)
+ print("✅ Design system persisted to design-system/ folder")
+ print(" 📄 design-system/MASTER.md (Global Source of Truth)")
+ if args.page:
+ page_filename = args.page.lower().replace(' ', '-')
+ print(f" 📄 design-system/pages/{page_filename}.md (Page Overrides)")
+ print("")
+ print("📖 Usage: When building a page, check design-system/pages/[page].md first.")
+ print(" If exists, its rules override MASTER.md. Otherwise, use MASTER.md.")
+ print("=" * 60)
# Stack search
elif args.stack:
result = search_stack(args.query, args.stack, args.max_results)
diff --git a/.cursor/commands/ui-ux-pro-max.md b/.cursor/commands/ui-ux-pro-max.md
index c50a453..f64bb81 100644
--- a/.cursor/commands/ui-ux-pro-max.md
+++ b/.cursor/commands/ui-ux-pro-max.md
@@ -60,6 +60,31 @@ This command:
python3 .shared/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for hierarchical retrieval across sessions, add `--persist`:
+
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
diff --git a/.kiro/steering/ui-ux-pro-max.md b/.kiro/steering/ui-ux-pro-max.md
index dff7038..f64bb81 100644
--- a/.kiro/steering/ui-ux-pro-max.md
+++ b/.kiro/steering/ui-ux-pro-max.md
@@ -60,6 +60,31 @@ This command:
python3 .shared/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for hierarchical retrieval across sessions, add `--persist`:
+
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
@@ -87,7 +112,7 @@ python3 .shared/ui-ux-pro-max/scripts/search.py "<keyword>" --stack html-tailwin
```
Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`, `jetpack-compose`
-
+, `jetpack-compose`
---
## Search Reference
diff --git a/.qoder/skills/ui-ux-pro-max.md b/.qoder/skills/ui-ux-pro-max.md
index b7eff9f..f64bb81 100644
--- a/.qoder/skills/ui-ux-pro-max.md
+++ b/.qoder/skills/ui-ux-pro-max.md
@@ -60,6 +60,31 @@ This command:
python3 .shared/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for hierarchical retrieval across sessions, add `--persist`:
+
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
@@ -86,8 +111,8 @@ Get implementation-specific best practices. If user doesn't specify a stack, **d
python3 .shared/ui-ux-pro-max/scripts/search.py "<keyword>" --stack html-tailwind
```
-Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`
-
+Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`, `jetpack-compose`
+, `jetpack-compose`
---
## Search Reference
@@ -120,6 +145,7 @@ Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`
| `react-native` | Components, Navigation, Lists |
| `flutter` | Widgets, State, Layout, Theming |
| `shadcn` | shadcn/ui components, theming, forms, patterns |
+| `jetpack-compose` | Composables, Modifiers, State Hoisting, Recomposition |
---
diff --git a/.roo/rules/ui-ux-pro-max.md b/.roo/rules/ui-ux-pro-max.md
index b7eff9f..f64bb81 100644
--- a/.roo/rules/ui-ux-pro-max.md
+++ b/.roo/rules/ui-ux-pro-max.md
@@ -60,6 +60,31 @@ This command:
python3 .shared/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for hierarchical retrieval across sessions, add `--persist`:
+
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
@@ -86,8 +111,8 @@ Get implementation-specific best practices. If user doesn't specify a stack, **d
python3 .shared/ui-ux-pro-max/scripts/search.py "<keyword>" --stack html-tailwind
```
-Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`
-
+Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`, `jetpack-compose`
+, `jetpack-compose`
---
## Search Reference
@@ -120,6 +145,7 @@ Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`
| `react-native` | Components, Navigation, Lists |
| `flutter` | Widgets, State, Layout, Theming |
| `shadcn` | shadcn/ui components, theming, forms, patterns |
+| `jetpack-compose` | Composables, Modifiers, State Hoisting, Recomposition |
---
diff --git a/.shared/ui-ux-pro-max/scripts/design_system.py b/.shared/ui-ux-pro-max/scripts/design_system.py
index 4e19b52..f2e1898 100644
--- a/.shared/ui-ux-pro-max/scripts/design_system.py
+++ b/.shared/ui-ux-pro-max/scripts/design_system.py
@@ -7,10 +7,16 @@ to generate comprehensive design system recommendations.
Usage:
from design_system import generate_design_system
result = generate_design_system("SaaS dashboard", "My Project")
+
+ # With persistence (Master + Overrides pattern)
+ result = generate_design_system("SaaS dashboard", "My Project", persist=True)
+ result = generate_design_system("SaaS dashboard", "My Project", persist=True, page="dashboard")
"""
import csv
import json
+import os
+from datetime import datetime
from pathlib import Path
from core import search, DATA_DIR
@@ -452,7 +458,8 @@ def format_markdown(design_system: dict) -> str:
# ============ MAIN ENTRY POINT ============
-def generate_design_system(query: str, project_name: str = None, output_format: str = "ascii") -> str:
+def generate_design_system(query: str, project_name: str = None, output_format: str = "ascii",
+ persist: bool = False, page: str = None, output_dir: str = None) -> str:
"""
Main entry point for design system generation.
@@ -460,18 +467,422 @@ def generate_design_system(query: str, project_name: str = None, output_format:
query: Search query (e.g., "SaaS dashboard", "e-commerce luxury")
project_name: Optional project name for output header
output_format: "ascii" (default) or "markdown"
+ persist: If True, save design system to design-system/ folder
+ page: Optional page name for page-specific override file
+ output_dir: Optional output directory (defaults to current working directory)
Returns:
Formatted design system string
"""
generator = DesignSystemGenerator()
design_system = generator.generate(query, project_name)
+
+ # Persist to files if requested
+ if persist:
+ persist_design_system(design_system, page, output_dir)
if output_format == "markdown":
return format_markdown(design_system)
return format_ascii_box(design_system)
+# ============ PERSISTENCE FUNCTIONS ============
+def persist_design_system(design_system: dict, page: str = None, output_dir: str = None) -> dict:
+ """
+ Persist design system to design-system/ folder using Master + Overrides pattern.
+
+ Args:
+ design_system: The generated design system dictionary
+ page: Optional page name for page-specific override file
+ output_dir: Optional output directory (defaults to current working directory)
+
+ Returns:
+ dict with created file paths and status
+ """
+ base_dir = Path(output_dir) if output_dir else Path.cwd()
+ design_system_dir = base_dir / "design-system"
+ pages_dir = design_system_dir / "pages"
+
+ created_files = []
+
+ # Create directories
+ design_system_dir.mkdir(parents=True, exist_ok=True)
+ pages_dir.mkdir(parents=True, exist_ok=True)
+
+ master_file = design_system_dir / "MASTER.md"
+
+ # Generate and write MASTER.md
+ master_content = format_master_md(design_system)
+ with open(master_file, 'w', encoding='utf-8') as f:
+ f.write(master_content)
+ created_files.append(str(master_file))
+
+ # If page is specified, create page override file
+ if page:
+ page_file = pages_dir / f"{page.lower().replace(' ', '-')}.md"
+ page_content = format_page_override_md(design_system, page)
+ with open(page_file, 'w', encoding='utf-8') as f:
+ f.write(page_content)
+ created_files.append(str(page_file))
+
+ return {
+ "status": "success",
+ "design_system_dir": str(design_system_dir),
+ "created_files": created_files
+ }
+
+
+def format_master_md(design_system: dict) -> str:
+ """Format design system as MASTER.md with hierarchical override logic."""
+ project = design_system.get("project_name", "PROJECT")
+ pattern = design_system.get("pattern", {})
+ style = design_system.get("style", {})
+ colors = design_system.get("colors", {})
+ typography = design_system.get("typography", {})
+ effects = design_system.get("key_effects", "")
+ anti_patterns = design_system.get("anti_patterns", "")
+
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+
+ lines = []
+
+ # Logic header
+ lines.append("# Design System Master File")
+ lines.append("")
+ lines.append("> **LOGIC:** When building a specific page, first check `design-system/pages/[page-name].md`.")
+ lines.append("> If that file exists, its rules **override** this Master file.")
+ lines.append("> If not, strictly follow the rules below.")
+ lines.append("")
+ lines.append("---")
+ lines.append("")
+ lines.append(f"**Project:** {project}")
+ lines.append(f"**Generated:** {timestamp}")
+ lines.append(f"**Category:** {design_system.get('category', 'General')}")
+ lines.append("")
+ lines.append("---")
+ lines.append("")
+
+ # Global Rules section
+ lines.append("## Global Rules")
+ lines.append("")
+
+ # Color Palette
+ lines.append("### Color Palette")
+ lines.append("")
+ lines.append("| Role | Hex | CSS Variable |")
+ lines.append("|------|-----|--------------|")
+ lines.append(f"| Primary | `{colors.get('primary', '#2563EB')}` | `--color-primary` |")
+ lines.append(f"| Secondary | `{colors.get('secondary', '#3B82F6')}` | `--color-secondary` |")
+ lines.append(f"| CTA/Accent | `{colors.get('cta', '#F97316')}` | `--color-cta` |")
+ lines.append(f"| Background | `{colors.get('background', '#F8FAFC')}` | `--color-background` |")
+ lines.append(f"| Text | `{colors.get('text', '#1E293B')}` | `--color-text` |")
+ lines.append("")
+ if colors.get("notes"):
+ lines.append(f"**Color Notes:** {colors.get('notes', '')}")
+ lines.append("")
+
+ # Typography
+ lines.append("### Typography")
+ lines.append("")
+ lines.append(f"- **Heading Font:** {typography.get('heading', 'Inter')}")
+ lines.append(f"- **Body Font:** {typography.get('body', 'Inter')}")
+ if typography.get("mood"):
+ lines.append(f"- **Mood:** {typography.get('mood', '')}")
+ if typography.get("google_fonts_url"):
+ lines.append(f"- **Google Fonts:** [{typography.get('heading', '')} + {typography.get('body', '')}]({typography.get('google_fonts_url', '')})")
+ lines.append("")
+ if typography.get("css_import"):
+ lines.append("**CSS Import:**")
+ lines.append("```css")
+ lines.append(typography.get("css_import", ""))
+ lines.append("```")
+ lines.append("")
+
+ # Spacing Variables
+ lines.append("### Spacing Variables")
+ lines.append("")
+ lines.append("| Token | Value | Usage |")
+ lines.append("|-------|-------|-------|")
+ lines.append("| `--space-xs` | `4px` / `0.25rem` | Tight gaps |")
+ lines.append("| `--space-sm` | `8px` / `0.5rem` | Icon gaps, inline spacing |")
+ lines.append("| `--space-md` | `16px` / `1rem` | Standard padding |")
+ lines.append("| `--space-lg` | `24px` / `1.5rem` | Section padding |")
+ lines.append("| `--space-xl` | `32px` / `2rem` | Large gaps |")
+ lines.append("| `--space-2xl` | `48px` / `3rem` | Section margins |")
+ lines.append("| `--space-3xl` | `64px` / `4rem` | Hero padding |")
+ lines.append("")
+
+ # Shadow Depths
+ lines.append("### Shadow Depths")
+ lines.append("")
+ lines.append("| Level | Value | Usage |")
+ lines.append("|-------|-------|-------|")
+ lines.append("| `--shadow-sm` | `0 1px 2px rgba(0,0,0,0.05)` | Subtle lift |")
+ lines.append("| `--shadow-md` | `0 4px 6px rgba(0,0,0,0.1)` | Cards, buttons |")
+ lines.append("| `--shadow-lg` | `0 10px 15px rgba(0,0,0,0.1)` | Modals, dropdowns |")
+ lines.append("| `--shadow-xl` | `0 20px 25px rgba(0,0,0,0.15)` | Hero images, featured cards |")
+ lines.append("")
+
+ # Component Specs section
+ lines.append("---")
+ lines.append("")
+ lines.append("## Component Specs")
+ lines.append("")
+
+ # Buttons
+ lines.append("### Buttons")
+ lines.append("")
+ lines.append("```css")
+ lines.append("/* Primary Button */")
+ lines.append(".btn-primary {")
+ lines.append(f" background: {colors.get('cta', '#F97316')};")
+ lines.append(" color: white;")
+ lines.append(" padding: 12px 24px;")
+ lines.append(" border-radius: 8px;")
+ lines.append(" font-weight: 600;")
+ lines.append(" transition: all 200ms ease;")
+ lines.append(" cursor: pointer;")
+ lines.append("}")
+ lines.append("")
+ lines.append(".btn-primary:hover {")
+ lines.append(" opacity: 0.9;")
+ lines.append(" transform: translateY(-1px);")
+ lines.append("}")
+ lines.append("")
+ lines.append("/* Secondary Button */")
+ lines.append(".btn-secondary {")
+ lines.append(f" background: transparent;")
+ lines.append(f" color: {colors.get('primary', '#2563EB')};")
+ lines.append(f" border: 2px solid {colors.get('primary', '#2563EB')};")
+ lines.append(" padding: 12px 24px;")
+ lines.append(" border-radius: 8px;")
+ lines.append(" font-weight: 600;")
+ lines.append(" transition: all 200ms ease;")
+ lines.append(" cursor: pointer;")
+ lines.append("}")
+ lines.append("```")
+ lines.append("")
+
+ # Cards
+ lines.append("### Cards")
+ lines.append("")
+ lines.append("```css")
+ lines.append(".card {")
+ lines.append(f" background: {colors.get('background', '#FFFFFF')};")
+ lines.append(" border-radius: 12px;")
+ lines.append(" padding: 24px;")
+ lines.append(" box-shadow: var(--shadow-md);")
+ lines.append(" transition: all 200ms ease;")
+ lines.append(" cursor: pointer;")
+ lines.append("}")
+ lines.append("")
+ lines.append(".card:hover {")
+ lines.append(" box-shadow: var(--shadow-lg);")
+ lines.append(" transform: translateY(-2px);")
+ lines.append("}")
+ lines.append("```")
+ lines.append("")
+
+ # Inputs
+ lines.append("### Inputs")
+ lines.append("")
+ lines.append("```css")
+ lines.append(".input {")
+ lines.append(" padding: 12px 16px;")
+ lines.append(" border: 1px solid #E2E8F0;")
+ lines.append(" border-radius: 8px;")
+ lines.append(" font-size: 16px;")
+ lines.append(" transition: border-color 200ms ease;")
+ lines.append("}")
+ lines.append("")
+ lines.append(".input:focus {")
+ lines.append(f" border-color: {colors.get('primary', '#2563EB')};")
+ lines.append(" outline: none;")
+ lines.append(f" box-shadow: 0 0 0 3px {colors.get('primary', '#2563EB')}20;")
+ lines.append("}")
+ lines.append("```")
+ lines.append("")
+
+ # Modals
+ lines.append("### Modals")
+ lines.append("")
+ lines.append("```css")
+ lines.append(".modal-overlay {")
+ lines.append(" background: rgba(0, 0, 0, 0.5);")
+ lines.append(" backdrop-filter: blur(4px);")
+ lines.append("}")
+ lines.append("")
+ lines.append(".modal {")
+ lines.append(" background: white;")
+ lines.append(" border-radius: 16px;")
+ lines.append(" padding: 32px;")
+ lines.append(" box-shadow: var(--shadow-xl);")
+ lines.append(" max-width: 500px;")
+ lines.append(" width: 90%;")
+ lines.append("}")
+ lines.append("```")
+ lines.append("")
+
+ # Style section
+ lines.append("---")
+ lines.append("")
+ lines.append("## Style Guidelines")
+ lines.append("")
+ lines.append(f"**Style:** {style.get('name', 'Minimalism')}")
+ lines.append("")
+ if style.get("keywords"):
+ lines.append(f"**Keywords:** {style.get('keywords', '')}")
+ lines.append("")
+ if style.get("best_for"):
+ lines.append(f"**Best For:** {style.get('best_for', '')}")
+ lines.append("")
+ if effects:
+ lines.append(f"**Key Effects:** {effects}")
+ lines.append("")
+
+ # Layout Pattern
+ lines.append("### Page Pattern")
+ lines.append("")
+ lines.append(f"**Pattern Name:** {pattern.get('name', '')}")
+ lines.append("")
+ if pattern.get('conversion'):
+ lines.append(f"- **Conversion Strategy:** {pattern.get('conversion', '')}")
+ if pattern.get('cta_placement'):
+ lines.append(f"- **CTA Placement:** {pattern.get('cta_placement', '')}")
+ lines.append(f"- **Section Order:** {pattern.get('sections', '')}")
+ lines.append("")
+
+ # Anti-Patterns section
+ lines.append("---")
+ lines.append("")
+ lines.append("## Anti-Patterns (Do NOT Use)")
+ lines.append("")
+ if anti_patterns:
+ anti_list = [a.strip() for a in anti_patterns.split("+")]
+ for anti in anti_list:
+ if anti:
+ lines.append(f"- ❌ {anti}")
+ lines.append("")
+ lines.append("### Additional Forbidden Patterns")
+ lines.append("")
+ lines.append("- ❌ **Emojis as icons** — Use SVG icons (Heroicons, Lucide, Simple Icons)")
+ lines.append("- ❌ **Missing cursor:pointer** — All clickable elements must have cursor:pointer")
+ lines.append("- ❌ **Layout-shifting hovers** — Avoid scale transforms that shift layout")
+ lines.append("- ❌ **Low contrast text** — Maintain 4.5:1 minimum contrast ratio")
+ lines.append("- ❌ **Instant state changes** — Always use transitions (150-300ms)")
+ lines.append("- ❌ **Invisible focus states** — Focus states must be visible for a11y")
+ lines.append("")
+
+ # Pre-Delivery Checklist
+ lines.append("---")
+ lines.append("")
+ lines.append("## Pre-Delivery Checklist")
+ lines.append("")
+ lines.append("Before delivering any UI code, verify:")
+ lines.append("")
+ lines.append("- [ ] No emojis used as icons (use SVG instead)")
+ lines.append("- [ ] All icons from consistent icon set (Heroicons/Lucide)")
+ lines.append("- [ ] `cursor-pointer` on all clickable elements")
+ lines.append("- [ ] Hover states with smooth transitions (150-300ms)")
+ lines.append("- [ ] Light mode: text contrast 4.5:1 minimum")
+ lines.append("- [ ] Focus states visible for keyboard navigation")
+ lines.append("- [ ] `prefers-reduced-motion` respected")
+ lines.append("- [ ] Responsive: 375px, 768px, 1024px, 1440px")
+ lines.append("- [ ] No content hidden behind fixed navbars")
+ lines.append("- [ ] No horizontal scroll on mobile")
+ lines.append("")
+
+ return "\n".join(lines)
+
+
+def format_page_override_md(design_system: dict, page_name: str) -> str:
+ """Format a page-specific override file."""
+ project = design_system.get("project_name", "PROJECT")
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+ page_title = page_name.replace("-", " ").replace("_", " ").title()
+
+ lines = []
+
+ lines.append(f"# {page_title} Page Overrides")
+ lines.append("")
+ lines.append(f"> **PROJECT:** {project}")
+ lines.append(f"> **Generated:** {timestamp}")
+ lines.append("")
+ lines.append("> ⚠️ **IMPORTANT:** Rules in this file **override** the Master file (`design-system/MASTER.md`).")
+ lines.append("> Only deviations from the Master are documented here. For all other rules, refer to the Master.")
+ lines.append("")
+ lines.append("---")
+ lines.append("")
+
+ # Page-specific sections (template)
+ lines.append("## Page-Specific Rules")
+ lines.append("")
+ lines.append("<!-- Document only the DEVIATIONS from MASTER.md for this page -->")
+ lines.append("")
+ lines.append("### Layout Overrides")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Example: This page uses a different max-width -->")
+ lines.append("max-width: 1400px (instead of default 1200px)")
+ lines.append("```")
+ lines.append("")
+ lines.append("### Color Overrides")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Example: This page uses a darker background -->")
+ lines.append("No overrides - use Master colors")
+ lines.append("```")
+ lines.append("")
+ lines.append("### Component Overrides")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Example: Cards on this page have different padding -->")
+ lines.append("No overrides - use Master component specs")
+ lines.append("```")
+ lines.append("")
+ lines.append("### Typography Overrides")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Example: Hero heading uses larger font size -->")
+ lines.append("No overrides - use Master typography")
+ lines.append("```")
+ lines.append("")
+
+ # Page-specific patterns
+ lines.append("---")
+ lines.append("")
+ lines.append("## Unique Page Elements")
+ lines.append("")
+ lines.append("<!-- Document any elements unique to this page -->")
+ lines.append("")
+ lines.append("### Hero Section")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Describe hero-specific styling if different from Master -->")
+ lines.append("```")
+ lines.append("")
+ lines.append("### Page-Specific Components")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- List any components only used on this page -->")
+ lines.append("```")
+ lines.append("")
+
+ # Notes section
+ lines.append("---")
+ lines.append("")
+ lines.append("## Notes")
+ lines.append("")
+ lines.append("<!-- Add any additional context for AI or developers -->")
+ lines.append("")
+ lines.append("- Refer to `design-system/MASTER.md` for all base rules")
+ lines.append("- Only add overrides here when this page deviates from the Master")
+ lines.append("- Delete placeholder sections if no overrides are needed")
+ lines.append("")
+
+ return "\n".join(lines)
+
+
# ============ CLI SUPPORT ============
if __name__ == "__main__":
import argparse
diff --git a/.shared/ui-ux-pro-max/scripts/search.py b/.shared/ui-ux-pro-max/scripts/search.py
index 00a38df..43e5fa5 100644
--- a/.shared/ui-ux-pro-max/scripts/search.py
+++ b/.shared/ui-ux-pro-max/scripts/search.py
@@ -4,14 +4,19 @@
UI/UX Pro Max Search - BM25 search engine for UI/UX style guides
Usage: python search.py "<query>" [--domain <domain>] [--stack <stack>] [--max-results 3]
python search.py "<query>" --design-system [-p "Project Name"]
+ python search.py "<query>" --design-system --persist [-p "Project Name"] [--page "dashboard"]
Domains: style, prompt, color, chart, landing, product, ux, typography
Stacks: html-tailwind, react, nextjs
+
+Persistence (Master + Overrides pattern):
+ --persist Save design system to design-system/MASTER.md
+ --page Also create a page-specific override file in design-system/pages/
"""
import argparse
from core import CSV_CONFIG, AVAILABLE_STACKS, MAX_RESULTS, search, search_stack
-from design_system import generate_design_system
+from design_system import generate_design_system, persist_design_system
def format_output(result):
@@ -51,13 +56,37 @@ if __name__ == "__main__":
parser.add_argument("--design-system", "-ds", action="store_true", help="Generate complete design system recommendation")
parser.add_argument("--project-name", "-p", type=str, default=None, help="Project name for design system output")
parser.add_argument("--format", "-f", choices=["ascii", "markdown"], default="ascii", help="Output format for design system")
+ # Persistence (Master + Overrides pattern)
+ parser.add_argument("--persist", action="store_true", help="Save design system to design-system/MASTER.md (creates hierarchical structure)")
+ parser.add_argument("--page", type=str, default=None, help="Create page-specific override file in design-system/pages/")
+ parser.add_argument("--output-dir", "-o", type=str, default=None, help="Output directory for persisted files (default: current directory)")
args = parser.parse_args()
# Design system takes priority
if args.design_system:
- result = generate_design_system(args.query, args.project_name, args.format)
+ result = generate_design_system(
+ args.query,
+ args.project_name,
+ args.format,
+ persist=args.persist,
+ page=args.page,
+ output_dir=args.output_dir
+ )
print(result)
+
+ # Print persistence confirmation
+ if args.persist:
+ print("\n" + "=" * 60)
+ print("✅ Design system persisted to design-system/ folder")
+ print(" 📄 design-system/MASTER.md (Global Source of Truth)")
+ if args.page:
+ page_filename = args.page.lower().replace(' ', '-')
+ print(f" 📄 design-system/pages/{page_filename}.md (Page Overrides)")
+ print("")
+ print("📖 Usage: When building a page, check design-system/pages/[page].md first.")
+ print(" If exists, its rules override MASTER.md. Otherwise, use MASTER.md.")
+ print("=" * 60)
# Stack search
elif args.stack:
result = search_stack(args.query, args.stack, args.max_results)
diff --git a/.windsurf/workflows/ui-ux-pro-max.md b/.windsurf/workflows/ui-ux-pro-max.md
index dff7038..f64bb81 100644
--- a/.windsurf/workflows/ui-ux-pro-max.md
+++ b/.windsurf/workflows/ui-ux-pro-max.md
@@ -60,6 +60,31 @@ This command:
python3 .shared/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for hierarchical retrieval across sessions, add `--persist`:
+
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
@@ -87,7 +112,7 @@ python3 .shared/ui-ux-pro-max/scripts/search.py "<keyword>" --stack html-tailwin
```
Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`, `jetpack-compose`
-
+, `jetpack-compose`
---
## Search Reference
diff --git a/README.md b/README.md
index 37a0034..ef34520 100644
--- a/README.md
+++ b/README.md
@@ -359,6 +359,41 @@ python3 .claude/skills/ui-ux-pro-max/scripts/search.py "form validation" --stack
python3 .claude/skills/ui-ux-pro-max/scripts/search.py "responsive layout" --stack html-tailwind
```
+### Persist Design System (Master + Overrides Pattern)
+
+Save your design system to files for **hierarchical retrieval across sessions**:
+
+```bash
+# Generate and persist to design-system/MASTER.md
+python3 .claude/skills/ui-ux-pro-max/scripts/search.py "SaaS dashboard" --design-system --persist -p "MyApp"
+
+# Also create a page-specific override file
+python3 .claude/skills/ui-ux-pro-max/scripts/search.py "SaaS dashboard" --design-system --persist -p "MyApp" --page "dashboard"
+```
+
+This creates a `design-system/` folder structure:
+
+```
+design-system/
+├── MASTER.md # Global Source of Truth (colors, typography, spacing, components)
+└── pages/
+ └── dashboard.md # Page-specific overrides (only deviations from Master)
+```
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
+**Context-aware retrieval prompt:**
+```
+I am building the [Page Name] page. Please read design-system/MASTER.md.
+Also check if design-system/pages/[page-name].md exists.
+If the page file exists, prioritize its rules.
+If not, use the Master rules exclusively.
+Now, generate the code...
+```
+
## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=nextlevelbuilder/ui-ux-pro-max-skill&type=Date)](https://star-history.com/#nextlevelbuilder/ui-ux-pro-max-skill&Date)
diff --git a/cli/assets/.agent/workflows/ui-ux-pro-max.md b/cli/assets/.agent/workflows/ui-ux-pro-max.md
index dbfbb5c..f64bb81 100644
--- a/cli/assets/.agent/workflows/ui-ux-pro-max.md
+++ b/cli/assets/.agent/workflows/ui-ux-pro-max.md
@@ -1,7 +1,3 @@
----
-description: Plan and implement UI
----
-
# ui-ux-pro-max
Comprehensive design guide for web and mobile applications. Contains 50+ styles, 97 color palettes, 57 font pairings, 99 UX guidelines, and 25 chart types across 9 technology stacks. Searchable database with priority-based recommendations.
@@ -64,6 +60,31 @@ This command:
python3 .shared/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for hierarchical retrieval across sessions, add `--persist`:
+
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
@@ -91,7 +112,7 @@ python3 .shared/ui-ux-pro-max/scripts/search.py "<keyword>" --stack html-tailwin
```
Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`, `jetpack-compose`
-
+, `jetpack-compose`
---
## Search Reference
@@ -264,4 +285,4 @@ Before delivering UI code, verify these items:
- [ ] All images have alt text
- [ ] Form inputs have labels
- [ ] Color is not the only indicator
-- [ ] `prefers-reduced-motion` respected
\ No newline at end of file
+- [ ] `prefers-reduced-motion` respected
diff --git a/cli/assets/.claude/skills/ui-ux-pro-max/SKILL.md b/cli/assets/.claude/skills/ui-ux-pro-max/SKILL.md
index 815459c..3edddb4 100644
--- a/cli/assets/.claude/skills/ui-ux-pro-max/SKILL.md
+++ b/cli/assets/.claude/skills/ui-ux-pro-max/SKILL.md
@@ -149,6 +149,40 @@ This command:
python3 .claude/skills/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for **hierarchical retrieval across sessions**, add `--persist`:
+
+```bash
+python3 .claude/skills/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .claude/skills/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
+**Context-aware retrieval prompt:**
+```
+I am building the [Page Name] page. Please read design-system/MASTER.md.
+Also check if design-system/pages/[page-name].md exists.
+If the page file exists, prioritize its rules.
+If not, use the Master rules exclusively.
+Now, generate the code...
+```
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
@@ -208,8 +242,8 @@ Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`
| `swiftui` | Views, State, Navigation, Animation |
| `react-native` | Components, Navigation, Lists |
| `flutter` | Widgets, State, Layout, Theming |
-| `jetpack-compose` | Composables, Modifiers, State Hoisting, Recomposition |
| `shadcn` | shadcn/ui components, theming, forms, patterns |
+| `jetpack-compose` | Composables, Modifiers, State Hoisting, Recomposition |
---
diff --git a/cli/assets/.cursor/commands/ui-ux-pro-max.md b/cli/assets/.cursor/commands/ui-ux-pro-max.md
index dff7038..f64bb81 100644
--- a/cli/assets/.cursor/commands/ui-ux-pro-max.md
+++ b/cli/assets/.cursor/commands/ui-ux-pro-max.md
@@ -60,6 +60,31 @@ This command:
python3 .shared/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for hierarchical retrieval across sessions, add `--persist`:
+
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
@@ -87,7 +112,7 @@ python3 .shared/ui-ux-pro-max/scripts/search.py "<keyword>" --stack html-tailwin
```
Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`, `jetpack-compose`
-
+, `jetpack-compose`
---
## Search Reference
diff --git a/cli/assets/.kiro/steering/ui-ux-pro-max.md b/cli/assets/.kiro/steering/ui-ux-pro-max.md
index dff7038..f64bb81 100644
--- a/cli/assets/.kiro/steering/ui-ux-pro-max.md
+++ b/cli/assets/.kiro/steering/ui-ux-pro-max.md
@@ -60,6 +60,31 @@ This command:
python3 .shared/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for hierarchical retrieval across sessions, add `--persist`:
+
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
@@ -87,7 +112,7 @@ python3 .shared/ui-ux-pro-max/scripts/search.py "<keyword>" --stack html-tailwin
```
Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`, `jetpack-compose`
-
+, `jetpack-compose`
---
## Search Reference
diff --git a/cli/assets/.qoder/skills/ui-ux-pro-max.md b/cli/assets/.qoder/skills/ui-ux-pro-max.md
index b7eff9f..f64bb81 100644
--- a/cli/assets/.qoder/skills/ui-ux-pro-max.md
+++ b/cli/assets/.qoder/skills/ui-ux-pro-max.md
@@ -60,6 +60,31 @@ This command:
python3 .shared/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for hierarchical retrieval across sessions, add `--persist`:
+
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
@@ -86,8 +111,8 @@ Get implementation-specific best practices. If user doesn't specify a stack, **d
python3 .shared/ui-ux-pro-max/scripts/search.py "<keyword>" --stack html-tailwind
```
-Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`
-
+Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`, `jetpack-compose`
+, `jetpack-compose`
---
## Search Reference
@@ -120,6 +145,7 @@ Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`
| `react-native` | Components, Navigation, Lists |
| `flutter` | Widgets, State, Layout, Theming |
| `shadcn` | shadcn/ui components, theming, forms, patterns |
+| `jetpack-compose` | Composables, Modifiers, State Hoisting, Recomposition |
---
diff --git a/cli/assets/.roo/rules/ui-ux-pro-max.md b/cli/assets/.roo/rules/ui-ux-pro-max.md
index b7eff9f..f64bb81 100644
--- a/cli/assets/.roo/rules/ui-ux-pro-max.md
+++ b/cli/assets/.roo/rules/ui-ux-pro-max.md
@@ -60,6 +60,31 @@ This command:
python3 .shared/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for hierarchical retrieval across sessions, add `--persist`:
+
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
@@ -86,8 +111,8 @@ Get implementation-specific best practices. If user doesn't specify a stack, **d
python3 .shared/ui-ux-pro-max/scripts/search.py "<keyword>" --stack html-tailwind
```
-Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`
-
+Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`, `jetpack-compose`
+, `jetpack-compose`
---
## Search Reference
@@ -120,6 +145,7 @@ Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`
| `react-native` | Components, Navigation, Lists |
| `flutter` | Widgets, State, Layout, Theming |
| `shadcn` | shadcn/ui components, theming, forms, patterns |
+| `jetpack-compose` | Composables, Modifiers, State Hoisting, Recomposition |
---
diff --git a/cli/assets/.shared/ui-ux-pro-max/scripts/design_system.py b/cli/assets/.shared/ui-ux-pro-max/scripts/design_system.py
index 4e19b52..f2e1898 100644
--- a/cli/assets/.shared/ui-ux-pro-max/scripts/design_system.py
+++ b/cli/assets/.shared/ui-ux-pro-max/scripts/design_system.py
@@ -7,10 +7,16 @@ to generate comprehensive design system recommendations.
Usage:
from design_system import generate_design_system
result = generate_design_system("SaaS dashboard", "My Project")
+
+ # With persistence (Master + Overrides pattern)
+ result = generate_design_system("SaaS dashboard", "My Project", persist=True)
+ result = generate_design_system("SaaS dashboard", "My Project", persist=True, page="dashboard")
"""
import csv
import json
+import os
+from datetime import datetime
from pathlib import Path
from core import search, DATA_DIR
@@ -452,7 +458,8 @@ def format_markdown(design_system: dict) -> str:
# ============ MAIN ENTRY POINT ============
-def generate_design_system(query: str, project_name: str = None, output_format: str = "ascii") -> str:
+def generate_design_system(query: str, project_name: str = None, output_format: str = "ascii",
+ persist: bool = False, page: str = None, output_dir: str = None) -> str:
"""
Main entry point for design system generation.
@@ -460,18 +467,422 @@ def generate_design_system(query: str, project_name: str = None, output_format:
query: Search query (e.g., "SaaS dashboard", "e-commerce luxury")
project_name: Optional project name for output header
output_format: "ascii" (default) or "markdown"
+ persist: If True, save design system to design-system/ folder
+ page: Optional page name for page-specific override file
+ output_dir: Optional output directory (defaults to current working directory)
Returns:
Formatted design system string
"""
generator = DesignSystemGenerator()
design_system = generator.generate(query, project_name)
+
+ # Persist to files if requested
+ if persist:
+ persist_design_system(design_system, page, output_dir)
if output_format == "markdown":
return format_markdown(design_system)
return format_ascii_box(design_system)
+# ============ PERSISTENCE FUNCTIONS ============
+def persist_design_system(design_system: dict, page: str = None, output_dir: str = None) -> dict:
+ """
+ Persist design system to design-system/ folder using Master + Overrides pattern.
+
+ Args:
+ design_system: The generated design system dictionary
+ page: Optional page name for page-specific override file
+ output_dir: Optional output directory (defaults to current working directory)
+
+ Returns:
+ dict with created file paths and status
+ """
+ base_dir = Path(output_dir) if output_dir else Path.cwd()
+ design_system_dir = base_dir / "design-system"
+ pages_dir = design_system_dir / "pages"
+
+ created_files = []
+
+ # Create directories
+ design_system_dir.mkdir(parents=True, exist_ok=True)
+ pages_dir.mkdir(parents=True, exist_ok=True)
+
+ master_file = design_system_dir / "MASTER.md"
+
+ # Generate and write MASTER.md
+ master_content = format_master_md(design_system)
+ with open(master_file, 'w', encoding='utf-8') as f:
+ f.write(master_content)
+ created_files.append(str(master_file))
+
+ # If page is specified, create page override file
+ if page:
+ page_file = pages_dir / f"{page.lower().replace(' ', '-')}.md"
+ page_content = format_page_override_md(design_system, page)
+ with open(page_file, 'w', encoding='utf-8') as f:
+ f.write(page_content)
+ created_files.append(str(page_file))
+
+ return {
+ "status": "success",
+ "design_system_dir": str(design_system_dir),
+ "created_files": created_files
+ }
+
+
+def format_master_md(design_system: dict) -> str:
+ """Format design system as MASTER.md with hierarchical override logic."""
+ project = design_system.get("project_name", "PROJECT")
+ pattern = design_system.get("pattern", {})
+ style = design_system.get("style", {})
+ colors = design_system.get("colors", {})
+ typography = design_system.get("typography", {})
+ effects = design_system.get("key_effects", "")
+ anti_patterns = design_system.get("anti_patterns", "")
+
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+
+ lines = []
+
+ # Logic header
+ lines.append("# Design System Master File")
+ lines.append("")
+ lines.append("> **LOGIC:** When building a specific page, first check `design-system/pages/[page-name].md`.")
+ lines.append("> If that file exists, its rules **override** this Master file.")
+ lines.append("> If not, strictly follow the rules below.")
+ lines.append("")
+ lines.append("---")
+ lines.append("")
+ lines.append(f"**Project:** {project}")
+ lines.append(f"**Generated:** {timestamp}")
+ lines.append(f"**Category:** {design_system.get('category', 'General')}")
+ lines.append("")
+ lines.append("---")
+ lines.append("")
+
+ # Global Rules section
+ lines.append("## Global Rules")
+ lines.append("")
+
+ # Color Palette
+ lines.append("### Color Palette")
+ lines.append("")
+ lines.append("| Role | Hex | CSS Variable |")
+ lines.append("|------|-----|--------------|")
+ lines.append(f"| Primary | `{colors.get('primary', '#2563EB')}` | `--color-primary` |")
+ lines.append(f"| Secondary | `{colors.get('secondary', '#3B82F6')}` | `--color-secondary` |")
+ lines.append(f"| CTA/Accent | `{colors.get('cta', '#F97316')}` | `--color-cta` |")
+ lines.append(f"| Background | `{colors.get('background', '#F8FAFC')}` | `--color-background` |")
+ lines.append(f"| Text | `{colors.get('text', '#1E293B')}` | `--color-text` |")
+ lines.append("")
+ if colors.get("notes"):
+ lines.append(f"**Color Notes:** {colors.get('notes', '')}")
+ lines.append("")
+
+ # Typography
+ lines.append("### Typography")
+ lines.append("")
+ lines.append(f"- **Heading Font:** {typography.get('heading', 'Inter')}")
+ lines.append(f"- **Body Font:** {typography.get('body', 'Inter')}")
+ if typography.get("mood"):
+ lines.append(f"- **Mood:** {typography.get('mood', '')}")
+ if typography.get("google_fonts_url"):
+ lines.append(f"- **Google Fonts:** [{typography.get('heading', '')} + {typography.get('body', '')}]({typography.get('google_fonts_url', '')})")
+ lines.append("")
+ if typography.get("css_import"):
+ lines.append("**CSS Import:**")
+ lines.append("```css")
+ lines.append(typography.get("css_import", ""))
+ lines.append("```")
+ lines.append("")
+
+ # Spacing Variables
+ lines.append("### Spacing Variables")
+ lines.append("")
+ lines.append("| Token | Value | Usage |")
+ lines.append("|-------|-------|-------|")
+ lines.append("| `--space-xs` | `4px` / `0.25rem` | Tight gaps |")
+ lines.append("| `--space-sm` | `8px` / `0.5rem` | Icon gaps, inline spacing |")
+ lines.append("| `--space-md` | `16px` / `1rem` | Standard padding |")
+ lines.append("| `--space-lg` | `24px` / `1.5rem` | Section padding |")
+ lines.append("| `--space-xl` | `32px` / `2rem` | Large gaps |")
+ lines.append("| `--space-2xl` | `48px` / `3rem` | Section margins |")
+ lines.append("| `--space-3xl` | `64px` / `4rem` | Hero padding |")
+ lines.append("")
+
+ # Shadow Depths
+ lines.append("### Shadow Depths")
+ lines.append("")
+ lines.append("| Level | Value | Usage |")
+ lines.append("|-------|-------|-------|")
+ lines.append("| `--shadow-sm` | `0 1px 2px rgba(0,0,0,0.05)` | Subtle lift |")
+ lines.append("| `--shadow-md` | `0 4px 6px rgba(0,0,0,0.1)` | Cards, buttons |")
+ lines.append("| `--shadow-lg` | `0 10px 15px rgba(0,0,0,0.1)` | Modals, dropdowns |")
+ lines.append("| `--shadow-xl` | `0 20px 25px rgba(0,0,0,0.15)` | Hero images, featured cards |")
+ lines.append("")
+
+ # Component Specs section
+ lines.append("---")
+ lines.append("")
+ lines.append("## Component Specs")
+ lines.append("")
+
+ # Buttons
+ lines.append("### Buttons")
+ lines.append("")
+ lines.append("```css")
+ lines.append("/* Primary Button */")
+ lines.append(".btn-primary {")
+ lines.append(f" background: {colors.get('cta', '#F97316')};")
+ lines.append(" color: white;")
+ lines.append(" padding: 12px 24px;")
+ lines.append(" border-radius: 8px;")
+ lines.append(" font-weight: 600;")
+ lines.append(" transition: all 200ms ease;")
+ lines.append(" cursor: pointer;")
+ lines.append("}")
+ lines.append("")
+ lines.append(".btn-primary:hover {")
+ lines.append(" opacity: 0.9;")
+ lines.append(" transform: translateY(-1px);")
+ lines.append("}")
+ lines.append("")
+ lines.append("/* Secondary Button */")
+ lines.append(".btn-secondary {")
+ lines.append(f" background: transparent;")
+ lines.append(f" color: {colors.get('primary', '#2563EB')};")
+ lines.append(f" border: 2px solid {colors.get('primary', '#2563EB')};")
+ lines.append(" padding: 12px 24px;")
+ lines.append(" border-radius: 8px;")
+ lines.append(" font-weight: 600;")
+ lines.append(" transition: all 200ms ease;")
+ lines.append(" cursor: pointer;")
+ lines.append("}")
+ lines.append("```")
+ lines.append("")
+
+ # Cards
+ lines.append("### Cards")
+ lines.append("")
+ lines.append("```css")
+ lines.append(".card {")
+ lines.append(f" background: {colors.get('background', '#FFFFFF')};")
+ lines.append(" border-radius: 12px;")
+ lines.append(" padding: 24px;")
+ lines.append(" box-shadow: var(--shadow-md);")
+ lines.append(" transition: all 200ms ease;")
+ lines.append(" cursor: pointer;")
+ lines.append("}")
+ lines.append("")
+ lines.append(".card:hover {")
+ lines.append(" box-shadow: var(--shadow-lg);")
+ lines.append(" transform: translateY(-2px);")
+ lines.append("}")
+ lines.append("```")
+ lines.append("")
+
+ # Inputs
+ lines.append("### Inputs")
+ lines.append("")
+ lines.append("```css")
+ lines.append(".input {")
+ lines.append(" padding: 12px 16px;")
+ lines.append(" border: 1px solid #E2E8F0;")
+ lines.append(" border-radius: 8px;")
+ lines.append(" font-size: 16px;")
+ lines.append(" transition: border-color 200ms ease;")
+ lines.append("}")
+ lines.append("")
+ lines.append(".input:focus {")
+ lines.append(f" border-color: {colors.get('primary', '#2563EB')};")
+ lines.append(" outline: none;")
+ lines.append(f" box-shadow: 0 0 0 3px {colors.get('primary', '#2563EB')}20;")
+ lines.append("}")
+ lines.append("```")
+ lines.append("")
+
+ # Modals
+ lines.append("### Modals")
+ lines.append("")
+ lines.append("```css")
+ lines.append(".modal-overlay {")
+ lines.append(" background: rgba(0, 0, 0, 0.5);")
+ lines.append(" backdrop-filter: blur(4px);")
+ lines.append("}")
+ lines.append("")
+ lines.append(".modal {")
+ lines.append(" background: white;")
+ lines.append(" border-radius: 16px;")
+ lines.append(" padding: 32px;")
+ lines.append(" box-shadow: var(--shadow-xl);")
+ lines.append(" max-width: 500px;")
+ lines.append(" width: 90%;")
+ lines.append("}")
+ lines.append("```")
+ lines.append("")
+
+ # Style section
+ lines.append("---")
+ lines.append("")
+ lines.append("## Style Guidelines")
+ lines.append("")
+ lines.append(f"**Style:** {style.get('name', 'Minimalism')}")
+ lines.append("")
+ if style.get("keywords"):
+ lines.append(f"**Keywords:** {style.get('keywords', '')}")
+ lines.append("")
+ if style.get("best_for"):
+ lines.append(f"**Best For:** {style.get('best_for', '')}")
+ lines.append("")
+ if effects:
+ lines.append(f"**Key Effects:** {effects}")
+ lines.append("")
+
+ # Layout Pattern
+ lines.append("### Page Pattern")
+ lines.append("")
+ lines.append(f"**Pattern Name:** {pattern.get('name', '')}")
+ lines.append("")
+ if pattern.get('conversion'):
+ lines.append(f"- **Conversion Strategy:** {pattern.get('conversion', '')}")
+ if pattern.get('cta_placement'):
+ lines.append(f"- **CTA Placement:** {pattern.get('cta_placement', '')}")
+ lines.append(f"- **Section Order:** {pattern.get('sections', '')}")
+ lines.append("")
+
+ # Anti-Patterns section
+ lines.append("---")
+ lines.append("")
+ lines.append("## Anti-Patterns (Do NOT Use)")
+ lines.append("")
+ if anti_patterns:
+ anti_list = [a.strip() for a in anti_patterns.split("+")]
+ for anti in anti_list:
+ if anti:
+ lines.append(f"- ❌ {anti}")
+ lines.append("")
+ lines.append("### Additional Forbidden Patterns")
+ lines.append("")
+ lines.append("- ❌ **Emojis as icons** — Use SVG icons (Heroicons, Lucide, Simple Icons)")
+ lines.append("- ❌ **Missing cursor:pointer** — All clickable elements must have cursor:pointer")
+ lines.append("- ❌ **Layout-shifting hovers** — Avoid scale transforms that shift layout")
+ lines.append("- ❌ **Low contrast text** — Maintain 4.5:1 minimum contrast ratio")
+ lines.append("- ❌ **Instant state changes** — Always use transitions (150-300ms)")
+ lines.append("- ❌ **Invisible focus states** — Focus states must be visible for a11y")
+ lines.append("")
+
+ # Pre-Delivery Checklist
+ lines.append("---")
+ lines.append("")
+ lines.append("## Pre-Delivery Checklist")
+ lines.append("")
+ lines.append("Before delivering any UI code, verify:")
+ lines.append("")
+ lines.append("- [ ] No emojis used as icons (use SVG instead)")
+ lines.append("- [ ] All icons from consistent icon set (Heroicons/Lucide)")
+ lines.append("- [ ] `cursor-pointer` on all clickable elements")
+ lines.append("- [ ] Hover states with smooth transitions (150-300ms)")
+ lines.append("- [ ] Light mode: text contrast 4.5:1 minimum")
+ lines.append("- [ ] Focus states visible for keyboard navigation")
+ lines.append("- [ ] `prefers-reduced-motion` respected")
+ lines.append("- [ ] Responsive: 375px, 768px, 1024px, 1440px")
+ lines.append("- [ ] No content hidden behind fixed navbars")
+ lines.append("- [ ] No horizontal scroll on mobile")
+ lines.append("")
+
+ return "\n".join(lines)
+
+
+def format_page_override_md(design_system: dict, page_name: str) -> str:
+ """Format a page-specific override file."""
+ project = design_system.get("project_name", "PROJECT")
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+ page_title = page_name.replace("-", " ").replace("_", " ").title()
+
+ lines = []
+
+ lines.append(f"# {page_title} Page Overrides")
+ lines.append("")
+ lines.append(f"> **PROJECT:** {project}")
+ lines.append(f"> **Generated:** {timestamp}")
+ lines.append("")
+ lines.append("> ⚠️ **IMPORTANT:** Rules in this file **override** the Master file (`design-system/MASTER.md`).")
+ lines.append("> Only deviations from the Master are documented here. For all other rules, refer to the Master.")
+ lines.append("")
+ lines.append("---")
+ lines.append("")
+
+ # Page-specific sections (template)
+ lines.append("## Page-Specific Rules")
+ lines.append("")
+ lines.append("<!-- Document only the DEVIATIONS from MASTER.md for this page -->")
+ lines.append("")
+ lines.append("### Layout Overrides")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Example: This page uses a different max-width -->")
+ lines.append("max-width: 1400px (instead of default 1200px)")
+ lines.append("```")
+ lines.append("")
+ lines.append("### Color Overrides")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Example: This page uses a darker background -->")
+ lines.append("No overrides - use Master colors")
+ lines.append("```")
+ lines.append("")
+ lines.append("### Component Overrides")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Example: Cards on this page have different padding -->")
+ lines.append("No overrides - use Master component specs")
+ lines.append("```")
+ lines.append("")
+ lines.append("### Typography Overrides")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Example: Hero heading uses larger font size -->")
+ lines.append("No overrides - use Master typography")
+ lines.append("```")
+ lines.append("")
+
+ # Page-specific patterns
+ lines.append("---")
+ lines.append("")
+ lines.append("## Unique Page Elements")
+ lines.append("")
+ lines.append("<!-- Document any elements unique to this page -->")
+ lines.append("")
+ lines.append("### Hero Section")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- Describe hero-specific styling if different from Master -->")
+ lines.append("```")
+ lines.append("")
+ lines.append("### Page-Specific Components")
+ lines.append("")
+ lines.append("```")
+ lines.append("<!-- List any components only used on this page -->")
+ lines.append("```")
+ lines.append("")
+
+ # Notes section
+ lines.append("---")
+ lines.append("")
+ lines.append("## Notes")
+ lines.append("")
+ lines.append("<!-- Add any additional context for AI or developers -->")
+ lines.append("")
+ lines.append("- Refer to `design-system/MASTER.md` for all base rules")
+ lines.append("- Only add overrides here when this page deviates from the Master")
+ lines.append("- Delete placeholder sections if no overrides are needed")
+ lines.append("")
+
+ return "\n".join(lines)
+
+
# ============ CLI SUPPORT ============
if __name__ == "__main__":
import argparse
diff --git a/cli/assets/.shared/ui-ux-pro-max/scripts/search.py b/cli/assets/.shared/ui-ux-pro-max/scripts/search.py
index 00a38df..43e5fa5 100644
--- a/cli/assets/.shared/ui-ux-pro-max/scripts/search.py
+++ b/cli/assets/.shared/ui-ux-pro-max/scripts/search.py
@@ -4,14 +4,19 @@
UI/UX Pro Max Search - BM25 search engine for UI/UX style guides
Usage: python search.py "<query>" [--domain <domain>] [--stack <stack>] [--max-results 3]
python search.py "<query>" --design-system [-p "Project Name"]
+ python search.py "<query>" --design-system --persist [-p "Project Name"] [--page "dashboard"]
Domains: style, prompt, color, chart, landing, product, ux, typography
Stacks: html-tailwind, react, nextjs
+
+Persistence (Master + Overrides pattern):
+ --persist Save design system to design-system/MASTER.md
+ --page Also create a page-specific override file in design-system/pages/
"""
import argparse
from core import CSV_CONFIG, AVAILABLE_STACKS, MAX_RESULTS, search, search_stack
-from design_system import generate_design_system
+from design_system import generate_design_system, persist_design_system
def format_output(result):
@@ -51,13 +56,37 @@ if __name__ == "__main__":
parser.add_argument("--design-system", "-ds", action="store_true", help="Generate complete design system recommendation")
parser.add_argument("--project-name", "-p", type=str, default=None, help="Project name for design system output")
parser.add_argument("--format", "-f", choices=["ascii", "markdown"], default="ascii", help="Output format for design system")
+ # Persistence (Master + Overrides pattern)
+ parser.add_argument("--persist", action="store_true", help="Save design system to design-system/MASTER.md (creates hierarchical structure)")
+ parser.add_argument("--page", type=str, default=None, help="Create page-specific override file in design-system/pages/")
+ parser.add_argument("--output-dir", "-o", type=str, default=None, help="Output directory for persisted files (default: current directory)")
args = parser.parse_args()
# Design system takes priority
if args.design_system:
- result = generate_design_system(args.query, args.project_name, args.format)
+ result = generate_design_system(
+ args.query,
+ args.project_name,
+ args.format,
+ persist=args.persist,
+ page=args.page,
+ output_dir=args.output_dir
+ )
print(result)
+
+ # Print persistence confirmation
+ if args.persist:
+ print("\n" + "=" * 60)
+ print("✅ Design system persisted to design-system/ folder")
+ print(" 📄 design-system/MASTER.md (Global Source of Truth)")
+ if args.page:
+ page_filename = args.page.lower().replace(' ', '-')
+ print(f" 📄 design-system/pages/{page_filename}.md (Page Overrides)")
+ print("")
+ print("📖 Usage: When building a page, check design-system/pages/[page].md first.")
+ print(" If exists, its rules override MASTER.md. Otherwise, use MASTER.md.")
+ print("=" * 60)
# Stack search
elif args.stack:
result = search_stack(args.query, args.stack, args.max_results)
diff --git a/cli/assets/.windsurf/workflows/ui-ux-pro-max.md b/cli/assets/.windsurf/workflows/ui-ux-pro-max.md
index dff7038..f64bb81 100644
--- a/cli/assets/.windsurf/workflows/ui-ux-pro-max.md
+++ b/cli/assets/.windsurf/workflows/ui-ux-pro-max.md
@@ -60,6 +60,31 @@ This command:
python3 .shared/ui-ux-pro-max/scripts/search.py "beauty spa wellness service" --design-system -p "Serenity Spa"
```
+### Step 2b: Persist Design System (Master + Overrides Pattern)
+
+To save the design system for hierarchical retrieval across sessions, add `--persist`:
+
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name"
+```
+
+This creates:
+- `design-system/MASTER.md` — Global Source of Truth with all design rules
+- `design-system/pages/` — Folder for page-specific overrides
+
+**With page-specific override:**
+```bash
+python3 .shared/ui-ux-pro-max/scripts/search.py "<query>" --design-system --persist -p "Project Name" --page "dashboard"
+```
+
+This also creates:
+- `design-system/pages/dashboard.md` — Page-specific deviations from Master
+
+**How hierarchical retrieval works:**
+1. When building a specific page (e.g., "Checkout"), first check `design-system/pages/checkout.md`
+2. If the page file exists, its rules **override** the Master file
+3. If not, use `design-system/MASTER.md` exclusively
+
### Step 3: Supplement with Detailed Searches (as needed)
After getting the design system, use domain searches to get additional details:
@@ -87,7 +112,7 @@ python3 .shared/ui-ux-pro-max/scripts/search.py "<keyword>" --stack html-tailwin
```
Available stacks: `html-tailwind`, `react`, `nextjs`, `vue`, `svelte`, `swiftui`, `react-native`, `flutter`, `shadcn`, `jetpack-compose`
-
+, `jetpack-compose`
---
## Search Reference