Complete command reference, spec formats, and production patterns. Everything you need to master spec-driven development with Kiro.
Recommended for most users
Using package manager
PowerShell installation
Containerized environment
Pre-installed in CloudShell
Check version and config
kiro doctor after installation to verify your environment is properly configured. It checks for common issues and suggests fixes.
# Initialize a new Kiro project kiro init # Create a new specification kiro spec create user-authentication # Generate code from spec kiro generate # Run with specific model kiro generate --model claude-3-opus # Watch mode for continuous generation kiro watch # List all specifications kiro spec list # Validate specifications kiro spec validate # Show diff before applying changes kiro generate --dry-run
| Command | Description | Common Flags |
|---|---|---|
kiro init |
Initialize new project with .kiro/ directory | --template, --force |
kiro spec create |
Create new specification file | --type, --template |
kiro generate |
Generate code from specifications | --model, --dry-run |
kiro watch |
Watch specs and regenerate on change | --debounce, --filter |
kiro validate |
Validate all specifications | --strict, --fix |
kiro test |
Run generated tests | --coverage, --watch |
kiro rollback |
Rollback to previous generation | --to, --list |
kiro config |
Manage configuration | --get, --set, --list |
apiVersion: kiro.aws/v1
kind: Specification
metadata:
name: user-authentication
description: User authentication and authorization system
tags:
- auth
- security
- api
spec:
requirements:
- id: AUTH-001
description: Users SHALL authenticate using email and password
priority: MUST
acceptance:
- Valid email format required
- Password minimum 8 characters
- Account lockout after 5 failed attempts
- id: AUTH-002
description: System SHALL support OAuth2 providers
priority: SHOULD
providers:
- google
- github
- aws-sso
architecture:
type: microservice
components:
- name: auth-service
type: api
framework: fastapi
database: postgresql
- name: token-store
type: cache
technology: redis
ttl: 3600
testing:
coverage: 80
types:
- unit
- integration
- e2e
apiVersion: kiro.aws/v1
kind: Specification
metadata:
name: payment-processing
version: 2.0.0
owner: platform-team
dependencies:
- user-authentication
- inventory-management
spec:
requirements:
- id: PAY-001
description: |
WHEN a customer initiates payment
THEN the system SHALL validate payment details
AND process the transaction within 3 seconds
type: functional
priority: MUST
constraints:
- id: CON-001
type: performance
description: Response time < 3s for 99% of requests
sla: 99.9
- id: CON-002
type: security
description: PCI DSS Level 1 compliance required
interfaces:
- name: PaymentAPI
type: rest
authentication: bearer
endpoints:
- method: POST
path: /payments
description: Process new payment
request:
schema: PaymentRequest
response:
schema: PaymentResponse
data_models:
PaymentRequest:
type: object
required: [amount, currency, method]
properties:
amount:
type: number
minimum: 0.01
currency:
type: string
enum: [USD, EUR, GBP]
method:
type: string
enum: [card, bank, wallet]
Kiro hooks allow you to customize the generation pipeline with custom scripts and validations.
#!/bin/bash
# Pre-generation hook - runs before code generation
echo "Running pre-generation checks..."
# Validate environment
if [ -z "$AWS_REGION" ]; then
echo "Error: AWS_REGION not set"
exit 1
fi
# Check dependencies
npm audit --audit-level=high
if [ $? -ne 0 ]; then
echo "Security vulnerabilities found"
exit 1
fi
# Format specifications
kiro spec format --write
echo "Pre-generation checks passed ✓"
#!/usr/bin/env python3
"""Post-generation hook - runs after code generation"""
import os
import subprocess
import sys
def run_linters():
"""Run code quality checks"""
print("Running linters...")
# Python files
subprocess.run(["black", ".", "--check"])
subprocess.run(["ruff", "check", "."])
# JavaScript/TypeScript
subprocess.run(["eslint", ".", "--fix"])
def update_documentation():
"""Generate API documentation"""
print("Updating documentation...")
subprocess.run(["npm", "run", "docs:generate"])
def run_tests():
"""Run test suite"""
print("Running tests...")
result = subprocess.run(["npm", "test"], capture_output=True)
if result.returncode != 0:
print("Tests failed!")
sys.exit(1)
if __name__ == "__main__":
run_linters()
update_documentation()
run_tests()
print("Post-generation tasks completed ✓")
| Hook | Timing | Use Cases |
|---|---|---|
pre-init |
Before project initialization | Environment setup, dependency checks |
post-init |
After project initialization | Install dependencies, configure tools |
pre-generate |
Before code generation | Validate specs, format code, security scans |
post-generate |
After code generation | Run tests, update docs, deploy |
pre-validate |
Before spec validation | Custom validation rules |
on-error |
When generation fails | Cleanup, notifications, rollback |
Kiro's multi-agent system coordinates specialized AI agents for complex tasks.
apiVersion: kiro.aws/v1
kind: MultiAgentWorkflow
metadata:
name: full-stack-feature
description: Complete feature implementation workflow
spec:
agents:
- name: architect
role: system-design
model: claude-3-opus
responsibilities:
- Design system architecture
- Define interfaces
- Plan data models
- name: backend-developer
role: implementation
model: gpt-4-turbo
focus: backend
languages: [python, go]
- name: frontend-developer
role: implementation
model: claude-3-sonnet
focus: frontend
frameworks: [react, vue]
- name: tester
role: quality-assurance
model: gpt-4
tasks:
- Write unit tests
- Create integration tests
- Generate test data
- name: reviewer
role: code-review
model: claude-3-opus
criteria:
- Security best practices
- Performance optimization
- Code quality
workflow:
- stage: design
agent: architect
output: architecture-doc
- stage: implement-backend
agent: backend-developer
input: architecture-doc
output: backend-code
- stage: implement-frontend
agent: frontend-developer
input: architecture-doc
output: frontend-code
parallel: true # Run parallel with backend
- stage: test
agent: tester
input: [backend-code, frontend-code]
output: test-suite
- stage: review
agent: reviewer
input: [backend-code, frontend-code, test-suite]
output: review-report
coordination:
strategy: event-driven
communication: shared-context
conflict-resolution: architect-decides
Execute multi-agent workflow
Monitor agent activities
Detailed agent reasoning
The Easy Approach to Requirements Syntax (EARS) provides templates for clear, unambiguous specifications.
# Ubiquitous Requirements (always active) The system SHALL provide user authentication # Event-Driven Requirements WHEN user clicks logout button THEN the system SHALL terminate the session AND redirect to login page # Unwanted Behaviors IF payment processing fails THEN the system SHALL NOT charge the customer AND SHALL rollback the transaction # State-Driven Requirements WHILE the system is in maintenance mode The system SHALL display maintenance page AND SHALL queue incoming requests # Optional Features WHERE high-availability is configured The system SHALL maintain 99.99% uptime AND SHALL auto-failover within 30 seconds # Complex Requirements WHEN user uploads a file IF file size > 100MB THEN the system SHALL use chunked upload AND SHALL show progress indicator WHILE maintaining upload state WHERE network interruption occurs The system SHALL resume from last chunk
| Pattern | Keywords | Use Case | Example |
|---|---|---|---|
| Ubiquitous | SHALL | Always true requirements | System SHALL log all transactions |
| Event-Driven | WHEN...THEN | Triggered by events | WHEN error occurs THEN notify admin |
| Unwanted | IF...THEN...NOT | Prevent behaviors | IF timeout THEN SHALL NOT retry |
| State-Driven | WHILE...THE | During states | WHILE loading THE spinner SHALL show |
| Optional | WHERE...THE | Conditional features | WHERE premium THE limits SHALL increase |
# Optimize for large codebases
generation:
parallel: true
max_workers: 4
cache_enabled: true
incremental: true
# Model selection for speed vs quality
models:
default: claude-3-haiku # Fast iteration
complex: claude-3-opus # Complex logic
review: gpt-4-turbo # Code review
# Selective generation
filters:
include:
- "src/**/*.py"
- "tests/**/*.py"
exclude:
- "**/migrations/**"
- "**/vendor/**"
# Project Setup kiro init && cd .kiro # Daily Workflow kiro spec create feature-name kiro generate --dry-run kiro generate kiro test # Debugging kiro doctor kiro validate --strict kiro generate --debug --verbose # Multi-Agent kiro workflow list kiro workflow run feature --watch # Configuration kiro config set model claude-3-opus kiro config set parallel true # Rollback kiro history kiro rollback --to HEAD~1