Requirements Generation
Load Context:
- Read
{{KIRO_DIR}}/specs/$1/spec.json for language and metadata
- Read
{{KIRO_DIR}}/specs/$1/brief.md if it exists (discovery context: problem, approach, scope decisions, boundary candidates)
- Read
{{KIRO_DIR}}/specs/$1/requirements.md for project description
- Core steering context:
product.md, tech.md, structure.md
- Additional steering files only when directly relevant to feature scope, user personas, business/domain rules, compliance/security constraints, operational 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 contain domain terminology or workflow rules that shape user-observable requirements
Read Guidelines:
- Read
rules/ears-format.md from this skill's directory for EARS syntax rules
- Read
rules/requirements-review-gate.md from this skill's directory for pre-write review criteria
- Read
{{KIRO_DIR}}/settings/templates/specs/requirements.md for document structure
Parallel Research (sub-agent dispatch)
The following research areas are independent. Decide the optimal decomposition based on project complexity -- split, merge, add, or skip sub-agents as needed.
In main context (essential for requirements generation):
- Spec files: spec.json, brief.md, requirements.md (project description)
- EARS format rules, requirements review gate, requirements template
- Core steering: product.md, tech.md (directly inform scope and constraints)
Delegate to sub-agent (keeps exploration out of main context):
- Codebase hints (brownfield projects): Spawn a sub-agent to explore existing implementations that inform requirement scope. Ask it to summarize: (1) what already exists, (2) relevant interfaces/APIs, (3) patterns that new requirements should align with. Return a summary under 150 lines.
- Domain research (when external knowledge is needed): Spawn a sub-agent for web research on domain-specific requirements, standards, or best practices. Return a concise findings summary.
- Additional steering and playbooks: If many steering files or local agent playbooks exist, spawn a sub-agent to scan them and return only the sections relevant to this feature.
For greenfield projects with minimal codebase, skip sub-agent dispatch and load context directly. If multi-agent is not available, execute sequentially in main context.
After all research completes, synthesize findings in main context before generating requirements.
Generate Requirements Draft:
- Create initial requirements draft based on project description
- Group related functionality into logical requirement areas
- Apply EARS format to all acceptance criteria
- Use language specified in spec.json
- Preserve terminology continuity across phases:
- discovery =
Boundary Candidates
- requirements = explicit inclusion/exclusion and adjacent expectations when needed
- design =
Boundary Commitments
- tasks =
_Boundary:_
- If scope could be misread, add lightweight boundary context without introducing implementation or architecture ownership detail
- Keep this as a draft until the review gate passes; do not write
requirements.md yet
Review Requirements Draft:
- Run the
Requirements Review Gate from rules/requirements-review-gate.md
- Review coverage, EARS compliance, ambiguity, adjacent expectations, and scope boundaries before finalizing
- If issues are local to the draft, repair the requirements and review again
- Keep the review bounded to at most 2 repair passes
- If the draft exposes a real scope ambiguity or contradiction, stop and ask the user to clarify instead of writing guessed requirements
Finalize and Update Metadata:
- Write
{{KIRO_DIR}}/specs/$1/requirements.md only after the requirements review gate passes
- Set
phase: "requirements-generated"
- Set
approvals.requirements.generated: true
- Update
updated_at timestamp
Important Constraints
Requirements Scope: WHAT, not HOW
Requirements describe user-observable behavior, not implementation. Use this to decide what belongs here vs. in design:
Ask the user about (requirements scope):
- Functional scope — what is included and what is excluded
- User-observable behavior — "when X happens, what should the user see/experience?"
- Business rules and edge cases — limits, error conditions, special cases
- Non-functional requirements visible to users — response time expectations, availability, security level
- Adjacent expectations only when they change user-visible behavior or operator expectations — what this feature relies on, and what it explicitly does not own
Do not ask about (design scope — defer to design phase):
- Technology stack choices (database, framework, language)
- Architecture patterns (microservices, monolith, event-driven)
- API design, data models, internal component structure
- How to achieve non-functional requirements (caching strategy, scaling approach)
- Internal ownership mapping, component seams, or implementation boundaries that belong in design
Litmus test: If an EARS acceptance criterion can be written without mentioning any technology, it belongs in requirements. If it requires a technology choice, it belongs in design.
Other Constraints
- Each requirement must be testable and unambiguous. If the project description leaves room for multiple interpretations on scope, behavior, or boundary conditions, ask the user to clarify before generating that requirement. Ask as many questions as needed; do not generate requirements that contain your own assumptions.
- Choose appropriate subject for EARS statements (system/service name for software)
- Requirement headings in requirements.md MUST include a leading numeric ID only (for example: "Requirement 1", "1.", "2 Feature ..."); do not use alphabetic IDs like "Requirement A".
Output Description
Provide output in the language specified in spec.json with:
- Generated Requirements Summary: Brief overview of major requirement areas (3-5 bullets)
- Document Status: Confirm requirements.md updated and spec.json metadata updated
- Review Gate: Confirm the requirements review gate passed
- Next Steps: Guide user on how to proceed (approve and continue, or modify)
Format Requirements:
- Use Markdown headings for clarity
- Include file paths in code blocks
- Keep summary concise (under 300 words)
Safety & Fallback
Error Scenarios
- Missing Project Description: If requirements.md lacks project description, ask user for feature details
- Template Missing: If template files don't exist, use inline fallback structure with warning
- Language Undefined: Default to English (
en) if spec.json doesn't specify language
- Incomplete Requirements: After generation, explicitly ask user if requirements cover all expected functionality
- Steering Directory Empty: Warn user that project context is missing and may affect requirement quality
- Non-numeric Requirement Headings: If existing headings do not include a leading numeric ID (for example, they use "Requirement A"), normalize them to numeric IDs and keep that mapping consistent (never mix numeric and alphabetic labels).
- Scope Ambiguity Found During Requirements Review: Stop execution, do not write a guessed
requirements.md, and ask the user to clarify the missing or conflicting scope before re-running $kiro-spec-requirements $1
Next Phase: Design Generation
If Requirements Approved:
- Review generated requirements at
{{KIRO_DIR}}/specs/$1/requirements.md
- Optional Gap Analysis (for existing codebases):
- Run
$kiro-validate-gap $1 to analyze implementation gap with current code
- Identifies existing components, integration points, and implementation strategy
- Recommended for brownfield projects; skip for greenfield
- Then
$kiro-spec-design $1 -y to proceed to design phase
If Modifications Needed:
- Provide feedback and re-run
$kiro-spec-requirements $1
1---2name: kiro-spec-requirements3description: Generate comprehensive requirements for a specification4---5
6
7# Requirements Generation
8
9<background_information>
10- **Success Criteria**:
11 - Create complete requirements document aligned with steering context
12 - Follow the project's EARS patterns and constraints for all acceptance criteria
13 - Focus on core functionality without implementation details
14 - Make inclusion/exclusion boundaries explicit when scope could otherwise be misread
15 - Update metadata to track generation status
16</background_information>
17
18<instructions>
19## Execution Steps
20
211. **Load Context**:
22 - Read `{{KIRO_DIR}}/specs/$1/spec.json` for language and metadata
23 - Read `{{KIRO_DIR}}/specs/$1/brief.md` if it exists (discovery context: problem, approach, scope decisions, boundary candidates)
24 - Read `{{KIRO_DIR}}/specs/$1/requirements.md` for project description
25 - Core steering context: `product.md`, `tech.md`, `structure.md`
26 - Additional steering files only when directly relevant to feature scope, user personas, business/domain rules, compliance/security constraints, operational constraints, or existing product boundaries
27 - Relevant local agent skills or playbooks only when they clearly match the feature's host environment or use case and contain domain terminology or workflow rules that shape user-observable requirements
28
292. **Read Guidelines**:
30 - Read `rules/ears-format.md` from this skill's directory for EARS syntax rules
31 - Read `rules/requirements-review-gate.md` from this skill's directory for pre-write review criteria
32 - Read `{{KIRO_DIR}}/settings/templates/specs/requirements.md` for document structure
33
34#### Parallel Research (sub-agent dispatch)
35
36The following research areas are independent. Decide the optimal decomposition based on project complexity -- split, merge, add, or skip sub-agents as needed.
37
38**In main context** (essential for requirements generation):
39- Spec files: spec.json, brief.md, requirements.md (project description)
40- EARS format rules, requirements review gate, requirements template
41- Core steering: product.md, tech.md (directly inform scope and constraints)
42
43**Delegate to sub-agent** (keeps exploration out of main context):
44- **Codebase hints** (brownfield projects): Spawn a sub-agent to explore existing implementations that inform requirement scope. Ask it to summarize: (1) what already exists, (2) relevant interfaces/APIs, (3) patterns that new requirements should align with. Return a summary under 150 lines.
45- **Domain research** (when external knowledge is needed): Spawn a sub-agent for web research on domain-specific requirements, standards, or best practices. Return a concise findings summary.
46- **Additional steering and playbooks**: If many steering files or local agent playbooks exist, spawn a sub-agent to scan them and return only the sections relevant to this feature.
47
48For greenfield projects with minimal codebase, skip sub-agent dispatch and load context directly. If multi-agent is not available, execute sequentially in main context.
49
50After all research completes, synthesize findings in main context before generating requirements.
51
523. **Generate Requirements Draft**:
53 - Create initial requirements draft based on project description
54 - Group related functionality into logical requirement areas
55 - Apply EARS format to all acceptance criteria
56 - Use language specified in spec.json
57 - Preserve terminology continuity across phases:
58 - discovery = `Boundary Candidates`
59 - requirements = explicit inclusion/exclusion and adjacent expectations when needed
60 - design = `Boundary Commitments`
61 - tasks = `_Boundary:_`
62 - If scope could be misread, add lightweight boundary context without introducing implementation or architecture ownership detail
63 - Keep this as a draft until the review gate passes; do not write `requirements.md` yet
64
654. **Review Requirements Draft**:
66 - Run the `Requirements Review Gate` from `rules/requirements-review-gate.md`
67 - Review coverage, EARS compliance, ambiguity, adjacent expectations, and scope boundaries before finalizing
68 - If issues are local to the draft, repair the requirements and review again
69 - Keep the review bounded to at most 2 repair passes
70 - If the draft exposes a real scope ambiguity or contradiction, stop and ask the user to clarify instead of writing guessed requirements
71
725. **Finalize and Update Metadata**:
73 - Write `{{KIRO_DIR}}/specs/$1/requirements.md` only after the requirements review gate passes
74 - Set `phase: "requirements-generated"`
75 - Set `approvals.requirements.generated: true`
76 - Update `updated_at` timestamp
77
78## Important Constraints
79
80### Requirements Scope: WHAT, not HOW
81Requirements describe user-observable behavior, not implementation. Use this to decide what belongs here vs. in design:
82
83**Ask the user about (requirements scope):**
84- Functional scope — what is included and what is excluded
85- User-observable behavior — "when X happens, what should the user see/experience?"
86- Business rules and edge cases — limits, error conditions, special cases
87- Non-functional requirements visible to users — response time expectations, availability, security level
88- Adjacent expectations only when they change user-visible behavior or operator expectations — what this feature relies on, and what it explicitly does not own
89
90**Do not ask about (design scope — defer to design phase):**
91- Technology stack choices (database, framework, language)
92- Architecture patterns (microservices, monolith, event-driven)
93- API design, data models, internal component structure
94- How to achieve non-functional requirements (caching strategy, scaling approach)
95- Internal ownership mapping, component seams, or implementation boundaries that belong in design
96
97**Litmus test**: If an EARS acceptance criterion can be written without mentioning any technology, it belongs in requirements. If it requires a technology choice, it belongs in design.
98
99### Other Constraints
100- Each requirement must be testable and unambiguous. If the project description leaves room for multiple interpretations on scope, behavior, or boundary conditions, ask the user to clarify before generating that requirement. Ask as many questions as needed; do not generate requirements that contain your own assumptions.
101- Choose appropriate subject for EARS statements (system/service name for software)
102- Requirement headings in requirements.md MUST include a leading numeric ID only (for example: "Requirement 1", "1.", "2 Feature ..."); do not use alphabetic IDs like "Requirement A".
103</instructions>
104
105## Output Description
106Provide output in the language specified in spec.json with:
107
1081. **Generated Requirements Summary**: Brief overview of major requirement areas (3-5 bullets)
1092. **Document Status**: Confirm requirements.md updated and spec.json metadata updated
1103. **Review Gate**: Confirm the requirements review gate passed
1114. **Next Steps**: Guide user on how to proceed (approve and continue, or modify)
112
113**Format Requirements**:
114- Use Markdown headings for clarity
115- Include file paths in code blocks
116- Keep summary concise (under 300 words)
117
118## Safety & Fallback
119
120### Error Scenarios
121- **Missing Project Description**: If requirements.md lacks project description, ask user for feature details
122- **Template Missing**: If template files don't exist, use inline fallback structure with warning
123- **Language Undefined**: Default to English (`en`) if spec.json doesn't specify language
124- **Incomplete Requirements**: After generation, explicitly ask user if requirements cover all expected functionality
125- **Steering Directory Empty**: Warn user that project context is missing and may affect requirement quality
126- **Non-numeric Requirement Headings**: If existing headings do not include a leading numeric ID (for example, they use "Requirement A"), normalize them to numeric IDs and keep that mapping consistent (never mix numeric and alphabetic labels).
127- **Scope Ambiguity Found During Requirements Review**: Stop execution, do not write a guessed `requirements.md`, and ask the user to clarify the missing or conflicting scope before re-running `$kiro-spec-requirements $1`
128
129### Next Phase: Design Generation
130
131**If Requirements Approved**:
132- Review generated requirements at `{{KIRO_DIR}}/specs/$1/requirements.md`
133- **Optional Gap Analysis** (for existing codebases):
134 - Run `$kiro-validate-gap $1` to analyze implementation gap with current code
135 - Identifies existing components, integration points, and implementation strategy
136 - Recommended for brownfield projects; skip for greenfield
137- Then `$kiro-spec-design $1 -y` to proceed to design phase
138
139**If Modifications Needed**:
140- Provide feedback and re-run `$kiro-spec-requirements $1`