kiro-spec-design Skill
Core Mission
- Success Criteria:
- All requirements mapped to technical components with clear interfaces
- The design makes responsibility boundaries explicit enough to guide task generation and review
- Appropriate architecture discovery and research completed
- Design aligns with steering context and existing patterns
- Visual diagrams included for complex architectures
Execution Steps
Step 1: Gather Context
If steering/spec context is already available from conversation, skip redundant file reads.
Otherwise, load all necessary context:
.kiro/specs/{feature}/spec.json, requirements.md, design.md (if exists)
.kiro/specs/{feature}/research.md (if exists, contains gap analysis from /kiro-validate-gap)
- Core steering context:
product.md, tech.md, structure.md
- Additional steering files only when directly relevant to requirement coverage, architecture boundaries, integrations, runtime prerequisites, security/performance constraints, or team conventions that affect implementation readiness
.kiro/settings/templates/specs/design.md for document structure
- Read
rules/design-principles.md from this skill's directory for design principles
.kiro/settings/templates/specs/research.md for discovery log structure
Validate requirements approval:
- If auto-approve flag is true: Auto-approve requirements in spec.json
- Otherwise: Verify approval status (stop if unapproved, see Safety & Fallback)
Step 2: Discovery & Analysis
Critical: This phase ensures design is based on complete, accurate information.
Classify Feature Type:
- New Feature (greenfield) → Full discovery required
- Extension (existing system) → Integration-focused discovery
- Simple Addition (CRUD/UI) → Minimal or no discovery
- Complex Integration → Comprehensive analysis required
Execute Appropriate Discovery Process:
For Complex/New Features:
- Read and execute
rules/design-discovery-full.md from this skill's directory
- Conduct thorough research using WebSearch/WebFetch:
- Latest architectural patterns and best practices
- External dependency verification (APIs, libraries, versions, compatibility)
- Official documentation, migration guides, known issues
- Performance benchmarks and security considerations
For Extensions:
- Read and execute
rules/design-discovery-light.md from this skill's directory
- Focus on integration points, existing patterns, compatibility
- Use Grep to analyze existing codebase patterns
For Simple Additions:
- Skip formal discovery, quick pattern check only
Parallel Research (subagent dispatch)
The following research areas are independent and can be dispatched as subagents via the Agent tool. The agent should decide the optimal decomposition based on feature complexity — split, merge, add, or skip subagents as needed. Each subagent returns a findings summary (not raw data) to keep the main context clean for synthesis.
Typical research areas (adjust as appropriate):
- Codebase analysis: Existing architecture patterns, integration points, code conventions (using Grep/Glob)
- External research: Dependencies, APIs, latest best practices (using WebSearch/WebFetch)
- Context loading (usually main context): Steering files, design principles, discovery rules, templates
For simple additions, skip subagent dispatch entirely and do a quick pattern check in main context.
After all findings return, synthesize in main context before proceeding.
Retain Discovery Findings for Step 3:
- External API contracts and constraints
- Technology decisions with rationale
- Existing patterns to follow or extend
- Integration points and dependencies
- Identified risks and mitigation strategies
- Boundary candidates, out-of-boundary decisions, and likely revalidation triggers
Persist Findings to Research Log:
- Create or update
.kiro/specs/{feature}/research.md using the shared template
- Summarize discovery scope and key findings
- Record investigations with sources and implications
- Document architecture pattern evaluation, design decisions, and risks
- Use the language specified in spec.json when writing or updating
research.md
Step 3: Synthesis
Apply design synthesis to discovery findings before writing.
- Read and apply
rules/design-synthesis.md from this skill's directory
- This step requires the full picture from discovery findings — execute in main context, not in a subagent
- Record synthesis outcomes (generalizations found, build-vs-adopt decisions, simplifications) in
research.md
Step 4: Generate Design Draft
- Generate Design Draft:
- Follow specs/design.md template structure and generation instructions strictly
- Boundary-first requirement: Before expanding supporting sections, make the boundary explicit. The draft must clearly define what this spec owns, what it does not own, which dependencies are allowed, and what changes would require downstream revalidation.
- Integrate all discovery findings and synthesis outcomes: Use researched information (APIs, patterns, technologies) and synthesis decisions (generalizations, build-vs-adopt, simplifications) throughout component definitions, architecture decisions, and integration points
- File Structure Plan (required): Populate the File Structure Plan section with concrete file paths and responsibilities. Analyze the codebase to determine which files need to be created vs. modified. Each file must have one clear responsibility. This section directly drives task
_Boundary:_ annotations and implementation Task Briefs — vague file structures produce vague implementations.
- Testing Strategy: Derive test items from requirements' acceptance criteria, not generic patterns. Each test item should reference specific components and behaviors from this design. E2E paths must map to the critical user flows identified in requirements. Avoid vague entries like "test login works" -- instead specify what is being verified and why it matters.
- If existing design.md found in Step 1, use it as reference context (merge mode)
- Apply design rules: Type Safety, Visual Communication, Formal Tone
- Use language specified in spec.json
- Keep this as a draft until the review gate passes; do not write
design.md yet
Step 5: Review Design Draft
- Read and apply
rules/design-review-gate.md from this skill's directory
- Verify requirements coverage, architecture readiness, and implementation executability before finalizing the design
- If issues are local to the draft, repair the design and review again
- Keep the review bounded to at most 2 repair passes
- If the draft exposes a real requirements/design gap, stop and return to requirements clarification instead of papering over it in
design.md
Step 6: Finalize Design Document
Write Final Design:
- Write
.kiro/specs/{feature}/design.md only after the design review gate passes
- Write research.md with discovery findings and synthesis outcomes (if not already written)
Update Metadata in spec.json:
- Set
phase: "design-generated"
- Set
approvals.design.generated: true, approved: false
- Set
approvals.requirements.approved: true
- Update
updated_at timestamp
Critical Constraints
- Type Safety:
- Enforce strong typing aligned with the project's technology stack.
- For statically typed languages, define explicit types/interfaces and avoid unsafe casts.
- For TypeScript, never use
any; prefer precise types and generics.
- For dynamically typed languages, provide type hints/annotations where available (e.g., Python type hints) and validate inputs at boundaries.
- Document public interfaces and contracts clearly to ensure cross-component type safety.
- 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.
Output Description
Command execution output (separate from design.md content):
Provide brief summary in the language specified in spec.json:
- Status: Confirm design document generated at
.kiro/specs/{feature}/design.md
- Discovery Type: Which discovery process was executed (full/light/minimal)
- Key Findings: 2-3 critical insights from discovery that shaped the design
- Review Gate: Confirm the design review gate passed
- Next Action: Approval workflow guidance (see Safety & Fallback)
- Research Log: Confirm
research.md updated with latest decisions
Format: Concise Markdown (under 200 words) - this is the command output, NOT the design document itself
Note: The actual design document follows .kiro/settings/templates/specs/design.md structure.
Safety & Fallback
Error Scenarios
Requirements Not Approved:
- Stop Execution: Cannot proceed without approved requirements
- User Message: "Requirements not yet approved. Approval required before design generation."
- Suggested Action: "Run
/kiro-spec-design {feature} -y to auto-approve requirements and proceed"
Missing Requirements:
- Stop Execution: Requirements document must exist
- User Message: "No requirements.md found at
.kiro/specs/{feature}/requirements.md"
- Suggested Action: "Run
/kiro-spec-requirements {feature} to generate requirements first"
Template Missing:
- User Message: "Template file missing at
.kiro/settings/templates/specs/design.md"
- Suggested Action: "Check repository setup or restore template file"
- Fallback: Use inline basic structure with warning
Steering Context Missing:
- Warning: "Steering directory empty or missing - design may not align with project standards"
- Proceed: Continue with generation but note limitation in output
Invalid Requirement IDs:
- 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.
Spec Gap Found During Design Review:
- Stop Execution: Do not write a patched-over
design.md
- User Message: "Design review found a real spec gap or ambiguity that must be resolved before design can be finalized."
- Suggested Action: Clarify or fix
requirements.md, then re-run /kiro-spec-design {feature}
Next Phase: Task Generation
If Design Approved:
- Optional: Run
/kiro-validate-design {feature} for interactive quality review
- Run
/kiro-spec-tasks {feature} to generate implementation tasks
- Or
/kiro-spec-tasks {feature} -y to auto-approve and proceed directly
If Modifications Needed:
- Provide feedback and re-run
/kiro-spec-design {feature}
- Existing design used as reference (merge mode)
1---2name: kiro-spec-design3description: Generate comprehensive technical design translating requirements (WHAT) into architecture (HOW) with discovery process. Use when creating architecture from requirements.4---56# kiro-spec-design Skill78## Core Mission9- **Success Criteria**:10 - All requirements mapped to technical components with clear interfaces11 - The design makes responsibility boundaries explicit enough to guide task generation and review12 - Appropriate architecture discovery and research completed13 - Design aligns with steering context and existing patterns14 - Visual diagrams included for complex architectures1516## Execution Steps1718### Step 1: Gather Context1920If steering/spec context is already available from conversation, skip redundant file reads.21Otherwise, load all necessary context:22- `.kiro/specs/{feature}/spec.json`, `requirements.md`, `design.md` (if exists)23- `.kiro/specs/{feature}/research.md` (if exists, contains gap analysis from `/kiro-validate-gap`)24- Core steering context: `product.md`, `tech.md`, `structure.md`25- Additional steering files only when directly relevant to requirement coverage, architecture boundaries, integrations, runtime prerequisites, security/performance constraints, or team conventions that affect implementation readiness26- `.kiro/settings/templates/specs/design.md` for document structure27- Read `rules/design-principles.md` from this skill's directory for design principles28- `.kiro/settings/templates/specs/research.md` for discovery log structure2930**Validate requirements approval**:31- If auto-approve flag is true: Auto-approve requirements in spec.json32- Otherwise: Verify approval status (stop if unapproved, see Safety & Fallback)3334### Step 2: Discovery & Analysis3536**Critical: This phase ensures design is based on complete, accurate information.**37381. **Classify Feature Type**:39 - **New Feature** (greenfield) → Full discovery required40 - **Extension** (existing system) → Integration-focused discovery41 - **Simple Addition** (CRUD/UI) → Minimal or no discovery42 - **Complex Integration** → Comprehensive analysis required43442. **Execute Appropriate Discovery Process**:4546 **For Complex/New Features**:47 - Read and execute `rules/design-discovery-full.md` from this skill's directory48 - Conduct thorough research using WebSearch/WebFetch:49 - Latest architectural patterns and best practices50 - External dependency verification (APIs, libraries, versions, compatibility)51 - Official documentation, migration guides, known issues52 - Performance benchmarks and security considerations5354 **For Extensions**:55 - Read and execute `rules/design-discovery-light.md` from this skill's directory56 - Focus on integration points, existing patterns, compatibility57 - Use Grep to analyze existing codebase patterns5859 **For Simple Additions**:60 - Skip formal discovery, quick pattern check only6162#### Parallel Research (subagent dispatch)6364The following research areas are independent and can be dispatched as **subagents** via the Agent tool. The agent should decide the optimal decomposition based on feature complexity — split, merge, add, or skip subagents as needed. Each subagent returns a **findings summary** (not raw data) to keep the main context clean for synthesis.6566**Typical research areas** (adjust as appropriate):67- **Codebase analysis**: Existing architecture patterns, integration points, code conventions (using Grep/Glob)68- **External research**: Dependencies, APIs, latest best practices (using WebSearch/WebFetch)69- **Context loading** (usually main context): Steering files, design principles, discovery rules, templates7071For simple additions, skip subagent dispatch entirely and do a quick pattern check in main context.7273After all findings return, synthesize in main context before proceeding.74753. **Retain Discovery Findings for Step 3**:76 - External API contracts and constraints77 - Technology decisions with rationale78 - Existing patterns to follow or extend79 - Integration points and dependencies80 - Identified risks and mitigation strategies81 - Boundary candidates, out-of-boundary decisions, and likely revalidation triggers82834. **Persist Findings to Research Log**:84 - Create or update `.kiro/specs/{feature}/research.md` using the shared template85 - Summarize discovery scope and key findings86 - Record investigations with sources and implications87 - Document architecture pattern evaluation, design decisions, and risks88 - Use the language specified in spec.json when writing or updating `research.md`8990### Step 3: Synthesis9192**Apply design synthesis to discovery findings before writing.**9394- Read and apply `rules/design-synthesis.md` from this skill's directory95- This step requires the full picture from discovery findings — execute in main context, not in a subagent96- Record synthesis outcomes (generalizations found, build-vs-adopt decisions, simplifications) in `research.md`9798### Step 4: Generate Design Draft991001. **Generate Design Draft**:101 - **Follow specs/design.md template structure and generation instructions strictly**102 - **Boundary-first requirement**: Before expanding supporting sections, make the boundary explicit. The draft must clearly define what this spec owns, what it does not own, which dependencies are allowed, and what changes would require downstream revalidation.103 - **Integrate all discovery findings and synthesis outcomes**: Use researched information (APIs, patterns, technologies) and synthesis decisions (generalizations, build-vs-adopt, simplifications) throughout component definitions, architecture decisions, and integration points104 - **File Structure Plan** (required): Populate the File Structure Plan section with concrete file paths and responsibilities. Analyze the codebase to determine which files need to be created vs. modified. Each file must have one clear responsibility. This section directly drives task `_Boundary:_` annotations and implementation Task Briefs — vague file structures produce vague implementations.105 - **Testing Strategy**: Derive test items from requirements' acceptance criteria, not generic patterns. Each test item should reference specific components and behaviors from this design. E2E paths must map to the critical user flows identified in requirements. Avoid vague entries like "test login works" -- instead specify what is being verified and why it matters.106 - If existing design.md found in Step 1, use it as reference context (merge mode)107 - Apply design rules: Type Safety, Visual Communication, Formal Tone108 - Use language specified in spec.json109 - Keep this as a draft until the review gate passes; do not write `design.md` yet110111### Step 5: Review Design Draft112113- Read and apply `rules/design-review-gate.md` from this skill's directory114- Verify requirements coverage, architecture readiness, and implementation executability before finalizing the design115- If issues are local to the draft, repair the design and review again116- Keep the review bounded to at most 2 repair passes117- If the draft exposes a real requirements/design gap, stop and return to requirements clarification instead of papering over it in `design.md`118119### Step 6: Finalize Design Document1201211. **Write Final Design**:122 - Write `.kiro/specs/{feature}/design.md` only after the design review gate passes123 - Write research.md with discovery findings and synthesis outcomes (if not already written)1241252. **Update Metadata** in spec.json:126127 - Set `phase: "design-generated"`128 - Set `approvals.design.generated: true, approved: false`129 - Set `approvals.requirements.approved: true`130 - Update `updated_at` timestamp131132## Critical Constraints133 - **Type Safety**:134 - Enforce strong typing aligned with the project's technology stack.135 - For statically typed languages, define explicit types/interfaces and avoid unsafe casts.136 - For TypeScript, never use `any`; prefer precise types and generics.137 - For dynamically typed languages, provide type hints/annotations where available (e.g., Python type hints) and validate inputs at boundaries.138 - Document public interfaces and contracts clearly to ensure cross-component type safety.139- **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.140141## Output Description142143**Command execution output** (separate from design.md content):144145Provide brief summary in the language specified in spec.json:1461471. **Status**: Confirm design document generated at `.kiro/specs/{feature}/design.md`1482. **Discovery Type**: Which discovery process was executed (full/light/minimal)1493. **Key Findings**: 2-3 critical insights from discovery that shaped the design1504. **Review Gate**: Confirm the design review gate passed1515. **Next Action**: Approval workflow guidance (see Safety & Fallback)1526. **Research Log**: Confirm `research.md` updated with latest decisions153154**Format**: Concise Markdown (under 200 words) - this is the command output, NOT the design document itself155156**Note**: The actual design document follows `.kiro/settings/templates/specs/design.md` structure.157158## Safety & Fallback159160### Error Scenarios161162**Requirements Not Approved**:163- **Stop Execution**: Cannot proceed without approved requirements164- **User Message**: "Requirements not yet approved. Approval required before design generation."165- **Suggested Action**: "Run `/kiro-spec-design {feature} -y` to auto-approve requirements and proceed"166167**Missing Requirements**:168- **Stop Execution**: Requirements document must exist169- **User Message**: "No requirements.md found at `.kiro/specs/{feature}/requirements.md`"170- **Suggested Action**: "Run `/kiro-spec-requirements {feature}` to generate requirements first"171172**Template Missing**:173- **User Message**: "Template file missing at `.kiro/settings/templates/specs/design.md`"174- **Suggested Action**: "Check repository setup or restore template file"175- **Fallback**: Use inline basic structure with warning176177**Steering Context Missing**:178- **Warning**: "Steering directory empty or missing - design may not align with project standards"179- **Proceed**: Continue with generation but note limitation in output180181**Invalid Requirement IDs**:182 - **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.183184**Spec Gap Found During Design Review**:185- **Stop Execution**: Do not write a patched-over `design.md`186- **User Message**: "Design review found a real spec gap or ambiguity that must be resolved before design can be finalized."187- **Suggested Action**: Clarify or fix `requirements.md`, then re-run `/kiro-spec-design {feature}`188189### Next Phase: Task Generation190191**If Design Approved**:192- **Optional**: Run `/kiro-validate-design {feature}` for interactive quality review193- Run `/kiro-spec-tasks {feature}` to generate implementation tasks194- Or `/kiro-spec-tasks {feature} -y` to auto-approve and proceed directly195196**If Modifications Needed**:197- Provide feedback and re-run `/kiro-spec-design {feature}`198- Existing design used as reference (merge mode)