|
| 1 | +--- |
| 2 | +description: Create comprehensive technical design for a specification |
| 3 | +allowed-tools: Bash, Glob, Grep, LS, Read, Write, Edit, MultiEdit, Update, WebSearch, WebFetch |
| 4 | +argument-hint: <feature-name> [-y] |
| 5 | +--- |
| 6 | + |
| 7 | +# Technical Design Generator |
| 8 | + |
| 9 | +<background_information> |
| 10 | +- **Mission**: Generate comprehensive technical design document that translates requirements (WHAT) into architectural design (HOW) |
| 11 | +- **Success Criteria**: |
| 12 | + - All requirements mapped to technical components with clear interfaces |
| 13 | + - Appropriate architecture discovery and research completed |
| 14 | + - Design aligns with steering context and existing patterns |
| 15 | + - Visual diagrams included for complex architectures |
| 16 | +</background_information> |
| 17 | + |
| 18 | +<instructions> |
| 19 | +## Core Task |
| 20 | +Generate technical design document for feature **$1** based on approved requirements. |
| 21 | + |
| 22 | +## Execution Steps |
| 23 | + |
| 24 | +### Step 1: Load Context |
| 25 | + |
| 26 | +**Read all necessary context**: |
| 27 | +- `.sdd/specs/$1/spec.json`, `requirements.md`, `design.md` (if exists) |
| 28 | +- **Entire `.sdd/steering/` directory** for complete project memory |
| 29 | +- `.sdd/settings/templates/specs/design.md` for document structure |
| 30 | +- `.sdd/settings/rules/design-principles.md` for design principles |
| 31 | +- `.sdd/settings/templates/specs/research.md` for discovery log structure |
| 32 | + |
| 33 | +**Validate requirements approval**: |
| 34 | +- If `-y` flag provided ($2 == "-y"): Auto-approve requirements in spec.json |
| 35 | +- Otherwise: Verify approval status (stop if unapproved, see Safety & Fallback) |
| 36 | + |
| 37 | +### Step 2: Discovery & Analysis |
| 38 | + |
| 39 | +**Critical: This phase ensures design is based on complete, accurate information.** |
| 40 | + |
| 41 | +1. **Classify Feature Type**: |
| 42 | + - **New Feature** (greenfield) → Full discovery required |
| 43 | + - **Extension** (existing system) → Integration-focused discovery |
| 44 | + - **Simple Addition** (CRUD/UI) → Minimal or no discovery |
| 45 | + - **Complex Integration** → Comprehensive analysis required |
| 46 | + |
| 47 | +2. **Execute Appropriate Discovery Process**: |
| 48 | + |
| 49 | + **For Complex/New Features**: |
| 50 | + - Read and execute `.sdd/settings/rules/design-discovery-full.md` |
| 51 | + - Conduct thorough research using WebSearch/WebFetch: |
| 52 | + - Latest architectural patterns and best practices |
| 53 | + - External dependency verification (APIs, libraries, versions, compatibility) |
| 54 | + - Official documentation, migration guides, known issues |
| 55 | + - Performance benchmarks and security considerations |
| 56 | + |
| 57 | + **For Extensions**: |
| 58 | + - Read and execute `.sdd/settings/rules/design-discovery-light.md` |
| 59 | + - Focus on integration points, existing patterns, compatibility |
| 60 | + - Use Grep to analyze existing codebase patterns |
| 61 | + |
| 62 | + **For Simple Additions**: |
| 63 | + - Skip formal discovery, quick pattern check only |
| 64 | + |
| 65 | +3. **Retain Discovery Findings for Step 3**: |
| 66 | +- External API contracts and constraints |
| 67 | +- Technology decisions with rationale |
| 68 | +- Existing patterns to follow or extend |
| 69 | +- Integration points and dependencies |
| 70 | +- Identified risks and mitigation strategies |
| 71 | +- Potential architecture patterns and boundary options (note details in `research.md`) |
| 72 | +- Parallelization considerations for future tasks (capture dependencies in `research.md`) |
| 73 | + |
| 74 | +4. **Persist Findings to Research Log**: |
| 75 | +- Create or update `.sdd/specs/$1/research.md` using the shared template |
| 76 | +- Summarize discovery scope and key findings (Summary section) |
| 77 | +- Record investigations in Research Log topics with sources and implications |
| 78 | +- Document architecture pattern evaluation, design decisions, and risks using the template sections |
| 79 | +- Use the language specified in spec.json when writing or updating `research.md` |
| 80 | + |
| 81 | +### Step 3: Generate Design Document |
| 82 | + |
| 83 | +1. **Load Design Template and Rules**: |
| 84 | +- Read `.sdd/settings/templates/specs/design.md` for structure |
| 85 | +- Read `.sdd/settings/rules/design-principles.md` for principles |
| 86 | + |
| 87 | +2. **Generate Design Document**: |
| 88 | +- **Follow specs/design.md template structure and generation instructions strictly** |
| 89 | +- **Integrate all discovery findings**: Use researched information (APIs, patterns, technologies) throughout component definitions, architecture decisions, and integration points |
| 90 | +- If existing design.md found in Step 1, use it as reference context (merge mode) |
| 91 | +- Apply design rules: Type Safety, Visual Communication, Formal Tone |
| 92 | +- Use language specified in spec.json |
| 93 | +- Ensure sections reflect updated headings ("Architecture Pattern & Boundary Map", "Technology Stack & Alignment", "Components & Interface Contracts") and reference supporting details from `research.md` |
| 94 | + |
| 95 | +3. **Update Metadata** in spec.json: |
| 96 | +- Set `phase: "design-generated"` |
| 97 | +- Set `approvals.design.generated: true, approved: false` |
| 98 | +- Set `approvals.requirements.approved: true` |
| 99 | +- Update `updated_at` timestamp |
| 100 | + |
| 101 | +## Critical Constraints |
| 102 | + - **Type Safety**: |
| 103 | + - Enforce strong typing aligned with the project's technology stack. |
| 104 | + - For statically typed languages, define explicit types/interfaces and avoid unsafe casts. |
| 105 | + - For TypeScript, never use `any`; prefer precise types and generics. |
| 106 | + - For dynamically typed languages, provide type hints/annotations where available (e.g., Python type hints) and validate inputs at boundaries. |
| 107 | + - Document public interfaces and contracts clearly to ensure cross-component type safety. |
| 108 | +- **Latest Information**: Use WebSearch/WebFetch for external dependencies and best practices |
| 109 | +- **Steering Alignment**: Respect existing architecture patterns from steering context |
| 110 | +- **Template Adherence**: Follow specs/design.md template structure and generation instructions strictly |
| 111 | +- **Design Focus**: Architecture and interfaces ONLY, no implementation code |
| 112 | +- **Requirements Traceability IDs**: Use numeric requirement IDs only (e.g. "1.1", "1.2", "3.1", "3.3") exactly as defined in requirements.md. Do not invent new IDs or use alphabetic labels. |
| 113 | +</instructions> |
| 114 | + |
| 115 | +## Tool Guidance |
| 116 | +- **Read first**: Load all context before taking action (specs, steering, templates, rules) |
| 117 | +- **Research when uncertain**: Use WebSearch/WebFetch for external dependencies, APIs, and latest best practices |
| 118 | +- **Analyze existing code**: Use Grep to find patterns and integration points in codebase |
| 119 | +- **Write last**: Generate design.md only after all research and analysis complete |
| 120 | + |
| 121 | +## Output Description |
| 122 | + |
| 123 | +**Command execution output** (separate from design.md content): |
| 124 | + |
| 125 | +Provide brief summary in the language specified in spec.json: |
| 126 | + |
| 127 | +1. **Status**: Confirm design document generated at `.sdd/specs/$1/design.md` |
| 128 | +2. **Discovery Type**: Which discovery process was executed (full/light/minimal) |
| 129 | +3. **Key Findings**: 2-3 critical insights from `research.md` that shaped the design |
| 130 | +4. **Next Action**: Approval workflow guidance (see Safety & Fallback) |
| 131 | +5. **Research Log**: Confirm `research.md` updated with latest decisions |
| 132 | + |
| 133 | +**Format**: Concise Markdown (under 200 words) - this is the command output, NOT the design document itself |
| 134 | + |
| 135 | +**Note**: The actual design document follows `.sdd/settings/templates/specs/design.md` structure. |
| 136 | + |
| 137 | +## Safety & Fallback |
| 138 | + |
| 139 | +### Error Scenarios |
| 140 | + |
| 141 | +**Requirements Not Approved**: |
| 142 | +- **Stop Execution**: Cannot proceed without approved requirements |
| 143 | +- **User Message**: "Requirements not yet approved. Approval required before design generation." |
| 144 | +- **Suggested Action**: "Run `/sdd:spec-design $1 -y` to auto-approve requirements and proceed" |
| 145 | + |
| 146 | +**Missing Requirements**: |
| 147 | +- **Stop Execution**: Requirements document must exist |
| 148 | +- **User Message**: "No requirements.md found at `.sdd/specs/$1/requirements.md`" |
| 149 | +- **Suggested Action**: "Run `/sdd:spec-requirements $1` to generate requirements first" |
| 150 | + |
| 151 | +**Template Missing**: |
| 152 | +- **User Message**: "Template file missing at `.sdd/settings/templates/specs/design.md`" |
| 153 | +- **Suggested Action**: "Check repository setup or restore template file" |
| 154 | +- **Fallback**: Use inline basic structure with warning |
| 155 | + |
| 156 | +**Steering Context Missing**: |
| 157 | +- **Warning**: "Steering directory empty or missing - design may not align with project standards" |
| 158 | +- **Proceed**: Continue with generation but note limitation in output |
| 159 | + |
| 160 | +**Discovery Complexity Unclear**: |
| 161 | +- **Default**: Use full discovery process (`.sdd/settings/rules/design-discovery-full.md`) |
| 162 | +- **Rationale**: Better to over-research than miss critical context |
| 163 | +- **Invalid Requirement IDs**: |
| 164 | + - **Stop Execution**: If requirements.md is missing numeric IDs or uses non-numeric headings (for example, "Requirement A"), stop and instruct the user to fix requirements.md before continuing. |
| 165 | + |
| 166 | +### Next Phase: Task Generation |
| 167 | + |
| 168 | +**If Design Approved**: |
| 169 | +- Review generated design at `.sdd/specs/$1/design.md` |
| 170 | +- **Optional**: Run `/sdd:validate-design $1` for interactive quality review |
| 171 | +- Then `/sdd:spec-tasks $1 -y` to generate implementation tasks |
| 172 | + |
| 173 | +**If Modifications Needed**: |
| 174 | +- Provide feedback and re-run `/sdd:spec-design $1` |
| 175 | +- Existing design used as reference (merge mode) |
| 176 | + |
| 177 | +**Note**: Design approval is mandatory before proceeding to task generation. |
| 178 | + |
| 179 | +think hard |
0 commit comments