From c71a03f728a54d912bf4943e4e5cf89fe7c50a17 Mon Sep 17 00:00:00 2001 From: Rafael Rodrigues Date: Mon, 26 Jan 2026 13:30:14 -0300 Subject: [PATCH] Add /speckit.designsystem command for design system management This commit introduces a new optional command that enables teams to create and maintain a comprehensive design system as part of the Spec-Driven Development workflow. The design system serves as the single source of truth for visual design, component patterns, and UX guidelines. Key features: - Create design system from scratch with guided questions - Update existing design systems with semantic versioning - Validate alignment with project constitution - Document colors, typography, spacing, components, and UX patterns - Generate visual documentation with Mermaid diagrams - Specify tech stack (Tailwind, shadcn/ui, component libraries) - Include accessibility standards (WCAG AA/AAA) - Handoff integration with /speckit.specify and /speckit.plan The command is automatically generated for all 18 supported AI agents (15 Markdown, 2 TOML, 1 via AGENTS.md) through the existing build system without requiring any additional configuration. Changes: - Add templates/commands/designsystem.md (command workflow) - Add templates/design-system-template.md (detailed template) - Update README.md (command documentation) - Update spec-driven.md (workflow integration) - Update templates/spec-template.md (design system reference) - Update templates/plan-template.md (design system reference) - Bump version to 0.0.91 in src/specify_cli/__init__.py All agents tested and validated. No breaking changes. --- README.md | 11 +- spec-driven.md | 12 + src/specify_cli/__init__.py | 1 + templates/commands/designsystem.md | 341 +++++++++++ templates/design-system-template.md | 907 ++++++++++++++++++++++++++++ templates/plan-template.md | 61 ++ templates/spec-template.md | 53 ++ 7 files changed, 1381 insertions(+), 5 deletions(-) create mode 100644 templates/commands/designsystem.md create mode 100644 templates/design-system-template.md diff --git a/README.md b/README.md index 76149512f6..d0c09ecca8 100644 --- a/README.md +++ b/README.md @@ -262,11 +262,12 @@ Essential commands for the Spec-Driven Development workflow: Additional commands for enhanced quality and validation: -| Command | Description | -| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | -| `/speckit.clarify` | Clarify underspecified areas (recommended before `/speckit.plan`; formerly `/quizme`) | -| `/speckit.analyze` | Cross-artifact consistency & coverage analysis (run after `/speckit.tasks`, before `/speckit.implement`) | -| `/speckit.checklist` | Generate custom quality checklists that validate requirements completeness, clarity, and consistency (like "unit tests for English") | +| Command | Description | +| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | +| `/speckit.designsystem` | Define and manage design system (visual design, components, UX guidelines) for consistent UI (run after `/speckit.constitution`) | +| `/speckit.clarify` | Clarify underspecified areas (recommended before `/speckit.plan`; formerly `/quizme`) | +| `/speckit.analyze` | Cross-artifact consistency & coverage analysis (run after `/speckit.tasks`, before `/speckit.implement`) | +| `/speckit.checklist` | Generate custom quality checklists that validate requirements completeness, clarity, and consistency (like "unit tests for English") | ### Environment Variables diff --git a/spec-driven.md b/spec-driven.md index 70b9789708..d855bc82e9 100644 --- a/spec-driven.md +++ b/spec-driven.md @@ -102,6 +102,18 @@ After a plan is created, this command analyzes the plan and related design docum 3. **Parallelization**: Marks independent tasks `[P]` and outlines safe parallel groups 4. **Output**: Writes `tasks.md` in the feature directory, ready for execution by a Task agent +### Optional: The `/speckit.designsystem` Command + +For projects with UI components, this optional command helps establish and maintain consistent design patterns: + +1. **Design Foundation**: Defines visual elements (colors, typography, spacing, icons) +2. **Component Library**: Documents component patterns and their usage +3. **UX Guidelines**: Establishes accessibility, responsiveness, and interaction standards +4. **Implementation Guidance**: Specifies tech stack (CSS framework, component library) and naming conventions +5. **Governance**: Sets versioning rules and change management processes + +The design system is stored in `.specify/memory/design-system.md` and can be referenced by specifications and plans to ensure UI consistency. Run this command after `/speckit.constitution` but before creating feature specifications if your project involves user interfaces. + ### Example: Building a Chat Feature Here's how these commands transform the traditional development workflow: diff --git a/src/specify_cli/__init__.py b/src/specify_cli/__init__.py index 1dedb31949..a468df251c 100644 --- a/src/specify_cli/__init__.py +++ b/src/specify_cli/__init__.py @@ -1232,6 +1232,7 @@ def init( enhancement_lines = [ "Optional commands that you can use for your specs [bright_black](improve quality & confidence)[/bright_black]", "", + f"○ [cyan]/speckit.designsystem[/] [bright_black](optional)[/bright_black] - Define design system (visual, components, UX) for consistent UI (run after [cyan]/speckit.constitution[/], before [cyan]/speckit.specify[/] if used)", f"○ [cyan]/speckit.clarify[/] [bright_black](optional)[/bright_black] - Ask structured questions to de-risk ambiguous areas before planning (run before [cyan]/speckit.plan[/] if used)", f"○ [cyan]/speckit.analyze[/] [bright_black](optional)[/bright_black] - Cross-artifact consistency & alignment report (after [cyan]/speckit.tasks[/], before [cyan]/speckit.implement[/])", f"○ [cyan]/speckit.checklist[/] [bright_black](optional)[/bright_black] - Generate quality checklists to validate requirements completeness, clarity, and consistency (after [cyan]/speckit.plan[/])" diff --git a/templates/commands/designsystem.md b/templates/commands/designsystem.md new file mode 100644 index 0000000000..a5c279d41c --- /dev/null +++ b/templates/commands/designsystem.md @@ -0,0 +1,341 @@ +--- +description: Create or update the project design system defining visual design, component patterns, and UX guidelines. +handoffs: + - label: Create Feature Spec + agent: speckit.specify + prompt: Create a spec following our design system. I want to build... + - label: Update Constitution + agent: speckit.constitution + prompt: Update constitution to align with design principles + - label: Create Implementation Plan + agent: speckit.plan + prompt: Create a plan that follows the design system guidelines +--- + +## User Input + +```text +$ARGUMENTS +``` + +You **MUST** consider the user input before proceeding (if not empty). + +## Outline + +You are creating or updating the project design system at `/memory/design-system.md`. This file serves as the single source of truth for visual design, component patterns, and UX guidelines. Your job is to (a) collect design requirements, (b) fill the template with concrete design decisions, and (c) ensure consistency with the project constitution. + +Follow this execution flow: + +1. **Check if design system exists**: + - Load `/memory/design-system.md` if it exists + - If exists: identify what the user wants to update/add + - If not exists: prepare to create from scratch + - Load `/memory/constitution.md` to ensure alignment with project principles + +2. **Determine the scope of work**: + - **For new design system**: Collect comprehensive design requirements + - **For updates**: Identify specific sections to modify (colors, typography, components, etc.) + - Parse user input to understand: + - Visual identity requirements (colors, fonts, spacing) + - Component library approach (custom, third-party, hybrid) + - UX priorities (accessibility, responsiveness, performance) + - Technology choices (CSS framework, component library, icon set) + +3. **Information collection strategy**: + + **If creating new design system (file doesn't exist)**: + + Ask the user targeted questions ONLY if the user input doesn't provide enough information: + + a. **Visual Foundation** (only ask if not specified): + - Primary color palette and intent + - Typography choices (font families, scale) + - Spacing/layout system (grid, spacing scale) + - Icon system preference + + b. **Component Approach** (only ask if not specified): + - Using existing library (shadcn/ui, Material UI, etc.) or custom? + - Component customization level + - State management approach for UI + + c. **UX Standards** (only ask if not specified): + - Accessibility target (WCAG AA, AAA) + - Responsive approach (mobile-first, desktop-first) + - Animation philosophy (minimal, moderate, rich) + + d. **Technology Stack** (only ask if not specified): + - CSS approach (Tailwind, CSS-in-JS, SCSS, etc.) + - Component library choice + - Icon library preference + + **IMPORTANT**: Make informed guesses based on common patterns if user doesn't specify everything. Only mark items as [NEEDS CLARIFICATION] if they significantly impact design direction and have no reasonable default. + + **If updating existing design system**: + - Load current design system + - Identify the specific changes requested + - Validate changes don't conflict with existing specs/plans + - Propose version bump (MAJOR/MINOR/PATCH) + +4. **Generate design system content**: + + Use the template at `/templates/design-system-template.md` and fill with collected information. + + **Mandatory sections**: + - Visual Foundation (colors, typography, spacing, icons) + - Component Library (core components, patterns, states) + - UX Guidelines (accessibility, responsiveness, interactions) + - Implementation Notes (tech stack, file structure, naming) + - Governance (versioning, change management) + + **Optional enhancements**: + - Generate mermaid diagrams for: + - Color palette visualization + - Component hierarchy (graph) + - Responsive breakpoint flows + - Typography scale + - Include code examples for: + - Color usage patterns + - Component composition examples + - Responsive patterns + +5. **Validate and ensure consistency**: + + **Quality checklist**: + - [ ] All mandatory sections completed + - [ ] Visual foundation clearly defined (colors, typography, spacing) + - [ ] Component patterns documented with examples + - [ ] Accessibility standards specified (WCAG level, keyboard nav) + - [ ] Responsive strategy defined (breakpoints, approach) + - [ ] Technology choices specified and justified + - [ ] Aligns with constitution principles + - [ ] Version number follows semantic versioning + - [ ] No placeholder tokens remaining (except intentionally deferred items) + + **Constitution alignment**: + - Compare design principles with constitution + - Ensure no conflicts (e.g., constitution requires simplicity, design doesn't add unnecessary complexity) + - If conflicts found, flag them and suggest resolution + + **Impact assessment** (if updating): + - Check existing specs in `specs/*/spec.md` for design references + - Check existing plans in `specs/*/plan.md` for component usage + - Identify specs/plans that may be affected by design changes + - Generate list of potentially impacted artifacts + +6. **Write the design system file**: + - Write to `/memory/design-system.md` + - Include sync impact report as HTML comment at the top (for updates) + - Ensure proper markdown formatting + - Include version information and dates + +7. **Generate visual documentation** (when applicable): + + Create mermaid diagrams to visualize: + + **Color Palette Example**: + ```mermaid + graph LR + subgraph primary [Primary Colors] + P1[Primary: #3B82F6] + P2[Primary Dark: #2563EB] + P3[Primary Light: #60A5FA] + end + subgraph semantic [Semantic Colors] + S1[Success: #10B981] + S2[Warning: #F59E0B] + S3[Error: #EF4444] + end + ``` + + **Component Hierarchy Example**: + ```mermaid + graph TD + Base[Base Components] --> Button[Button] + Base --> Input[Input] + Base --> Card[Card] + + Button --> PrimaryButton[Primary Button] + Button --> SecondaryButton[Secondary Button] + + Card --> ContentCard[Content Card] + Card --> FeatureCard[Feature Card] + + Patterns[Composite Patterns] --> Form[Form Pattern] + Form --> Input + Form --> Button + ``` + +8. **Output summary to user**: + + Provide a clear summary with: + - Design system file location: `/memory/design-system.md` + - Version information (new version if update) + - Key design decisions documented + - Technology choices confirmed + - Next steps: + - Review the generated design system + - Use `/speckit.specify` to create specs that follow the design system + - Use `/speckit.plan` to create implementation plans aligned with design + - If updates made: List of specs/plans that may need review + - Suggested commit message (if applicable) + +## Key Guidelines + +### For AI Generation + +When creating/updating the design system: + +1. **Be specific and concrete**: Replace all placeholders with actual values + - ❌ Bad: "Use a modern color palette" + - ✅ Good: "Primary: #3B82F6 (blue), Secondary: #8B5CF6 (purple)" + +2. **Provide context and rationale**: Explain design decisions + - Why these colors? (brand alignment, accessibility, psychology) + - Why this component library? (ecosystem, flexibility, learning curve) + - Why this spacing system? (consistency, flexibility, development speed) + +3. **Include practical examples**: Show, don't just tell + - Color usage: "Primary for CTAs, Secondary for highlights, Muted for disabled states" + - Component composition: "Cards contain Heading + Content + optional Button" + - Responsive patterns: "Stack vertically on mobile, 2-column grid on tablet, 3-column on desktop" + +4. **Document accessibility**: Be explicit about a11y standards + - Color contrast ratios (AA: 4.5:1 for text, AAA: 7:1) + - Keyboard navigation patterns + - Screen reader considerations + - Focus indicators + +5. **Define component states clearly**: + - Default, Hover, Active, Focus, Disabled, Loading, Error + - Visual changes for each state + - Animation/transition timing if applicable + +6. **Technology choices must be actionable**: + - Specify exact libraries/versions when possible + - Include installation/setup notes if relevant + - Reference documentation URLs + +### Versioning Rules + +Design system versions follow semantic versioning: + +- **MAJOR (X.0.0)**: Breaking changes + - Changing component library (Material UI → shadcn/ui) + - Complete color palette overhaul + - Typography system replacement + - Changes requiring component rewrites + +- **MINOR (0.X.0)**: Additive changes + - New components added to library + - New color variations (dark mode palette) + - Extended spacing scale + - New animation patterns + - Additional accessibility features + +- **PATCH (0.0.X)**: Non-breaking refinements + - Color value adjustments (shade tweaks) + - Documentation improvements + - Example additions + - Clarifications to guidelines + - Fixed typos or formatting + +### When to Ask for Clarification + +Only use [NEEDS CLARIFICATION: ...] markers for: + +1. **Critical brand decisions** with no context: + - Color palette when no brand guidelines exist + - Typography when no brand fonts specified + +2. **Significant technical tradeoffs**: + - Component library choice when multiple viable options + - CSS approach with different architectural implications + +3. **Accessibility requirements** when legally sensitive: + - Specific WCAG conformance level for regulated industries + - Required accessibility features for specific user groups + +**Do NOT ask about**: +- Common spacing scales (use 4px/8px base) +- Standard responsive breakpoints (use Tailwind defaults or common standards) +- Basic accessibility (always target WCAG AA minimum) +- Icon libraries (suggest popular choices like Lucide, Heroicons) + +### Integration with Other Commands + +- **`/speckit.constitution`**: Design system must align with constitution principles +- **`/speckit.specify`**: Specs should reference design system components +- **`/speckit.plan`**: Plans should validate against design system guidelines +- **`/speckit.tasks`**: Tasks should include design system compliance checks +- **`/speckit.implement`**: Implementation must follow design system patterns + +### Common Patterns to Include + +When documenting, always include: + +1. **Color Usage Patterns**: + ``` + - Primary: Call-to-action buttons, links, focused states + - Secondary: Less prominent actions, secondary information + - Accent: Highlights, badges, special callouts + - Success/Warning/Error: Feedback messages, form validation + - Muted: Disabled states, placeholder text, secondary content + - Background: Page backgrounds, card surfaces, dividers + ``` + +2. **Typography Scale** (example using Tailwind): + ``` + - xs: 0.75rem (12px) - Captions, helper text + - sm: 0.875rem (14px) - Secondary text + - base: 1rem (16px) - Body text + - lg: 1.125rem (18px) - Lead paragraphs + - xl: 1.25rem (20px) - Subheadings + - 2xl: 1.5rem (24px) - Headings + - 3xl: 1.875rem (30px) - Page titles + ``` + +3. **Spacing Scale** (example using 4px base): + ``` + - 1: 0.25rem (4px) - Tight spacing + - 2: 0.5rem (8px) - Compact spacing + - 4: 1rem (16px) - Default spacing + - 6: 1.5rem (24px) - Comfortable spacing + - 8: 2rem (32px) - Loose spacing + - 12: 3rem (48px) - Section spacing + - 16: 4rem (64px) - Major section spacing + ``` + +4. **Responsive Breakpoints** (example using Tailwind): + ``` + - sm: 640px - Tablet portrait + - md: 768px - Tablet landscape + - lg: 1024px - Desktop + - xl: 1280px - Large desktop + - 2xl: 1536px - Extra large desktop + ``` + +## Formatting & Style Requirements + +- Use Markdown headings exactly as in template +- Keep sections organized and scannable +- Use bullet points for lists of guidelines +- Use code blocks for technical examples +- Include mermaid diagrams for visual concepts +- Maintain consistent terminology throughout +- Keep line length reasonable (<100 chars ideally) +- No trailing whitespace +- Single blank line between sections + +## Error Handling + +If critical information is missing and cannot be reasonably inferred: +1. Document what's missing with [NEEDS CLARIFICATION: specific question] +2. Provide 2-3 reasonable options with tradeoffs +3. Set a sensible default if user doesn't respond +4. Include rationale for the default choice + +If conflicts with constitution are found: +1. Clearly identify the conflict +2. Explain why it's a problem +3. Suggest 2-3 resolution paths +4. Wait for user decision before proceeding diff --git a/templates/design-system-template.md b/templates/design-system-template.md new file mode 100644 index 0000000000..8d72b5105d --- /dev/null +++ b/templates/design-system-template.md @@ -0,0 +1,907 @@ +# [PROJECT_NAME] Design System + + + +## Visual Foundation + +### Color Palette + +**Primary Colors** + +[PRIMARY_COLOR_SCHEME] + + +**Secondary Colors** + +[SECONDARY_COLOR_SCHEME] + + +**Semantic Colors** + +[SEMANTIC_COLOR_SCHEME] + + +**Neutral Colors** + +[NEUTRAL_COLOR_SCHEME] + + +**Accessibility Notes** + +[COLOR_ACCESSIBILITY_NOTES] + + +### Typography + +**Font Families** + +[FONT_FAMILIES] + + +**Type Scale** + +[TYPE_SCALE] + + +**Font Weights** + +[FONT_WEIGHTS] + + +### Spacing & Layout + +**Spacing Scale** + +[SPACING_SCALE] + + +**Grid System** + +[GRID_SYSTEM] + + +**Responsive Breakpoints** + +[RESPONSIVE_BREAKPOINTS] + + +### Iconography + +**Icon System** + +[ICON_SYSTEM] + + +**Icon Colors** + +[ICON_COLOR_GUIDELINES] + + +## Component Library + +### Core Components + +[CORE_COMPONENTS] + + +### Patterns & Compositions + +[COMPOSITION_PATTERNS] + + +### Component States + +[COMPONENT_STATE_DEFINITIONS] + + +## UX Guidelines + +### Accessibility + +**WCAG Compliance Level**: [WCAG_LEVEL] + + +[ACCESSIBILITY_STANDARDS] + + +### Responsiveness + +**Mobile-First Approach**: [RESPONSIVE_STRATEGY] + + +[RESPONSIVE_DESIGN_GUIDELINES] + + +### Interactions & Animations + +**Animation Philosophy**: [ANIMATION_APPROACH] + + +[ANIMATION_PRINCIPLES] + + +### Feedback & Messaging + +[FEEDBACK_GUIDELINES] + + +## Implementation Notes + +### Technology Stack + +[TECH_STACK_UI] + + +### File Structure + +[FILE_ORGANIZATION] + + +### Naming Conventions + +[NAMING_RULES] + + +### Design Tokens + +[DESIGN_TOKENS] + + +## Governance + +[GOVERNANCE_RULES] + + +## Version History + +**Current Version**: [DESIGN_SYSTEM_VERSION] +**Created**: [CREATION_DATE] +**Last Updated**: [LAST_UPDATED_DATE] + +[VERSION_CHANGELOG] + + +--- + +**Maintained by**: [TEAM_OR_PERSON] +**Questions or suggestions?**: [CONTACT_METHOD] diff --git a/templates/plan-template.md b/templates/plan-template.md index 6a8bfc6c8a..fe729cdb8b 100644 --- a/templates/plan-template.md +++ b/templates/plan-template.md @@ -33,6 +33,67 @@ [Gates determined based on constitution file] +## Design System Check + +*GATE: Verify alignment with design system (if exists). Skip if no design system defined.* + +**Reference**: `.specify/memory/design-system.md` + + + +[DESIGN_SYSTEM_VALIDATION] + + ## Project Structure ### Documentation (this feature) diff --git a/templates/spec-template.md b/templates/spec-template.md index c67d914980..32663b4c5b 100644 --- a/templates/spec-template.md +++ b/templates/spec-template.md @@ -113,3 +113,56 @@ - **SC-002**: [Measurable metric, e.g., "System handles 1000 concurrent users without degradation"] - **SC-003**: [User satisfaction metric, e.g., "90% of users successfully complete primary task on first attempt"] - **SC-004**: [Business metric, e.g., "Reduce support tickets related to [X] by 50%"] + +## Design Considerations *(optional)* + + + +[DESIGN_NOTES] +