Implementation Gap Validation
Execution Steps
Load Context:
- Read
.kiro/specs/$1/spec.json for language and metadata
- Read
.kiro/specs/$1/requirements.md for requirements
- Core steering context:
product.md, tech.md, structure.md
- Additional steering files only when directly relevant to the feature's domain rules, integrations, runtime prerequisites, compliance/security constraints, or existing product boundaries
- Relevant local agent skills or playbooks only when they clearly match the feature's host environment or use case and provide analysis-relevant context
Read Analysis Guidelines:
- Read
rules/gap-analysis.md from this skill's directory for comprehensive analysis framework
Parallel Research
The following research areas are independent and can be executed in parallel:
- Codebase analysis: Existing implementations, architecture patterns, integration points, extension possibilities
- External dependency research: Dependency compatibility, version constraints, known integration challenges (when needed)
- Context loading: Requirements, core steering, task-relevant extra steering, relevant local agent skills/playbooks, and gap-analysis rules
If multi-agent is enabled, spawn sub-agents for each area above. Otherwise execute sequentially.
After all parallel research completes, synthesize findings for gap analysis.
Execute Gap Analysis:
- Follow gap-analysis.md framework for thorough investigation
- Analyze existing codebase using Grep and Read tools
- Use WebSearch/WebFetch for external dependency research if needed
- Evaluate multiple implementation approaches (extend/new/hybrid)
- Use language specified in spec.json for output
Generate Analysis Document:
- Create comprehensive gap analysis following the output guidelines in gap-analysis.md
- Present multiple viable options with trade-offs
- Flag areas requiring further research
Write Gap Analysis to Disk:
Write the gap analysis to disk so it survives session boundaries and can be referenced during design phase.
- Save the gap analysis to
.kiro/specs/$1/research.md
- If the file already exists, append the new analysis (separated by a horizontal rule
---) rather than overwriting previous research
- Verify the file was written by reading it back
Important Constraints
- Information over Decisions: Provide analysis and options, not final implementation choices
- Multiple Options: Present viable alternatives when applicable
- Thorough Investigation: Use tools to deeply understand existing codebase
- Explicit Gaps: Clearly flag areas needing research or investigation
- Context Discipline: Start with core steering and expand only with analysis-relevant steering or use-case-aligned local agent skills/playbooks
Tool Guidance
- Read first: Load spec, core steering, relevant local playbooks/agent skills, and rules before analysis
- Grep extensively: Search codebase for patterns, conventions, and integration points
- WebSearch/WebFetch: Research external dependencies and best practices when needed
- Write last: Generate analysis only after complete investigation
Output Description
Provide output in the language specified in spec.json with:
- Analysis Summary: Brief overview (3-5 bullets) of scope, challenges, and recommendations
- Document Status: Confirm analysis approach used
- Next Steps: Guide user on proceeding to design phase
Format Requirements:
- Use Markdown headings for clarity
- Keep summary concise (under 300 words)
- Detailed analysis follows gap-analysis.md output guidelines
Safety & Fallback
Error Scenarios
- Missing Requirements: If requirements.md doesn't exist, stop with message: "Run
$kiro-spec-requirements $1 first to generate requirements"
- Requirements Not Approved: If requirements not approved, warn user but proceed (gap analysis can inform requirement revisions)
- Empty Steering Directory: Warn user that project context is missing and may affect analysis quality
- Complex Integration Unclear: Flag for comprehensive research in design phase rather than blocking
- Language Undefined: Default to English (
en) if spec.json doesn't specify language
Next Phase: Design Generation
If Gap Analysis Complete:
- Review gap analysis insights
- Run
$kiro-spec-design $1 to create technical design document
- Or
$kiro-spec-design $1 -y to auto-approve requirements and proceed directly
Note: Gap analysis is optional but recommended for brownfield projects to inform design decisions.
1---2name: kiro-validate-gap3description: Analyze implementation gap between requirements and existing codebase4---567# Implementation Gap Validation89<background_information>10- **Mission**: Analyze the gap between requirements and existing codebase to inform implementation strategy11- **Success Criteria**:12 - Comprehensive understanding of existing codebase patterns and components13 - Clear identification of missing capabilities and integration challenges14 - Multiple viable implementation approaches evaluated15 - Technical research needs identified for design phase16</background_information>1718<instructions>19## Core Task20Analyze implementation gap for feature **$1** based on approved requirements and existing codebase.2122## Execution Steps23241. **Load Context**:25 - Read `.kiro/specs/$1/spec.json` for language and metadata26 - Read `.kiro/specs/$1/requirements.md` for requirements27 - Core steering context: `product.md`, `tech.md`, `structure.md`28 - Additional steering files only when directly relevant to the feature's domain rules, integrations, runtime prerequisites, compliance/security constraints, or existing product boundaries29 - Relevant local agent skills or playbooks only when they clearly match the feature's host environment or use case and provide analysis-relevant context30312. **Read Analysis Guidelines**:32 - Read `rules/gap-analysis.md` from this skill's directory for comprehensive analysis framework3334#### Parallel Research3536The following research areas are independent and can be executed in parallel:371. **Codebase analysis**: Existing implementations, architecture patterns, integration points, extension possibilities382. **External dependency research**: Dependency compatibility, version constraints, known integration challenges (when needed)393. **Context loading**: Requirements, core steering, task-relevant extra steering, relevant local agent skills/playbooks, and gap-analysis rules4041If multi-agent is enabled, spawn sub-agents for each area above. Otherwise execute sequentially.4243After all parallel research completes, synthesize findings for gap analysis.44453. **Execute Gap Analysis**:46 - Follow gap-analysis.md framework for thorough investigation47 - Analyze existing codebase using Grep and Read tools48 - Use WebSearch/WebFetch for external dependency research if needed49 - Evaluate multiple implementation approaches (extend/new/hybrid)50 - Use language specified in spec.json for output51524. **Generate Analysis Document**:53 - Create comprehensive gap analysis following the output guidelines in gap-analysis.md54 - Present multiple viable options with trade-offs55 - Flag areas requiring further research56575. **Write Gap Analysis to Disk**:5859 **Write the gap analysis to disk so it survives session boundaries and can be referenced during design phase.**6061 - Save the gap analysis to `.kiro/specs/$1/research.md`62 - If the file already exists, append the new analysis (separated by a horizontal rule `---`) rather than overwriting previous research63 - Verify the file was written by reading it back6465## Important Constraints66- **Information over Decisions**: Provide analysis and options, not final implementation choices67- **Multiple Options**: Present viable alternatives when applicable68- **Thorough Investigation**: Use tools to deeply understand existing codebase69- **Explicit Gaps**: Clearly flag areas needing research or investigation70- **Context Discipline**: Start with core steering and expand only with analysis-relevant steering or use-case-aligned local agent skills/playbooks71</instructions>7273## Tool Guidance74- **Read first**: Load spec, core steering, relevant local playbooks/agent skills, and rules before analysis75- **Grep extensively**: Search codebase for patterns, conventions, and integration points76- **WebSearch/WebFetch**: Research external dependencies and best practices when needed77- **Write last**: Generate analysis only after complete investigation7879## Output Description80Provide output in the language specified in spec.json with:81821. **Analysis Summary**: Brief overview (3-5 bullets) of scope, challenges, and recommendations832. **Document Status**: Confirm analysis approach used843. **Next Steps**: Guide user on proceeding to design phase8586**Format Requirements**:87- Use Markdown headings for clarity88- Keep summary concise (under 300 words)89- Detailed analysis follows gap-analysis.md output guidelines9091## Safety & Fallback9293### Error Scenarios94- **Missing Requirements**: If requirements.md doesn't exist, stop with message: "Run `$kiro-spec-requirements $1` first to generate requirements"95- **Requirements Not Approved**: If requirements not approved, warn user but proceed (gap analysis can inform requirement revisions)96- **Empty Steering Directory**: Warn user that project context is missing and may affect analysis quality97- **Complex Integration Unclear**: Flag for comprehensive research in design phase rather than blocking98- **Language Undefined**: Default to English (`en`) if spec.json doesn't specify language99100### Next Phase: Design Generation101102**If Gap Analysis Complete**:103- Review gap analysis insights104- Run `$kiro-spec-design $1` to create technical design document105- Or `$kiro-spec-design $1 -y` to auto-approve requirements and proceed directly106107**Note**: Gap analysis is optional but recommended for brownfield projects to inform design decisions.