Skip to content

aws-samples/sample-kiro-cli-multiagent-development

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Kiro CLI Multi-Agent Development Sample

A sample configuration for multi-agent development workflows using Kiro CLI. Demonstrates how to set up a team of specialized AI agents that collaborate through a spec-driven development process.

This entire setup β€” agents, steering rules, skills, and prompts β€” was built using Kiro CLI itself.

Disclaimer: This repository is provided as an example only. The agent configurations, steering rules, and workflows are starting points β€” not production-ready defaults. You should review, adjust, and tailor them to fit your own project requirements, team conventions, and security posture.

Overview

This repo provides a sample .kiro configuration with five agents that work together:

Agent Role Model
leader Architect β€” researches, designs specs, creates plans, delegates work claude-opus-4.5
coder Implements features and writes tests from specs claude-sonnet-4.5
ops Infrastructure, CI/CD, containers, and documentation claude-sonnet-4.5
reviewer Reviews implementations for correctness, quality, and maintainability claude-opus-4.5
security-reviewer Reviews implementations exclusively for security vulnerabilities and misconfigurations claude-opus-4.5

The leader agent orchestrates the workflow: it writes specs, breaks work into parallelized task groups, delegates to coder and ops for implementation, then sends the results to reviewer and security-reviewer for feedback. This loop continues until both reviewers pass the work.

How It Works

leader (plan + research) β†’ coder + ops (build in parallel) β†’ reviewer (verify) β†’ security-reviewer (security audit) β†’ leader (next group or fix)
  1. Plan β€” leader researches the problem, looks up SDK/framework APIs from live documentation, writes a spec, and creates a task plan
  2. Build β€” leader delegates task groups to coder and/or ops subagents in parallel
  3. Review β€” reviewer analyzes the implementation for correctness and quality
  4. Security Review β€” after the general review passes, security-reviewer audits for vulnerabilities, misconfigurations, and compliance risks
  5. Fix β€” if either review fails, leader creates fix tasks and loops back to build

Before any implementation begins, the leader conducts SDK/framework research using AWS documentation and Context7 to verify API signatures, import paths, and constructor conventions. Findings are written to the project's docs/tech.md so subagents code against verified contracts β€” not assumed APIs.

Quick Start

  1. Install Kiro CLI

  2. Clone this repo into a project's .kiro/ directory (or use it standalone):

git clone https://github.com/aws-samples/sample-kiro-cli-multiagent-development.git .kiro
cd .kiro
chmod +x hooks/*.sh
  1. Start a chat with the leader agent:
kiro-cli chat --agent leader

Everything works immediately β€” agent prompts, steering rules, skills, and hooks all use relative paths.

Moving to Global Configuration

If you want these agents available across all your projects (not just this directory), promote the local config to ~/.kiro/:

# Copy everything to global config
cp -r agents/ steering/ skills/ hooks/ prompts/ settings/ ~/.kiro/
chmod +x ~/.kiro/hooks/*.sh

# Update agent prompt paths from relative to absolute
# In each ~/.kiro/agents/*.json, change:
#   "prompt": "file://agents/leader.md"
# to:
#   "prompt": "file:///Users/<you>/.kiro/agents/leader.md"

# Update hook paths from local to global
# In each ~/.kiro/agents/*.json, change:
#   "command": ".kiro/hooks/check-secrets.sh"
# to:
#   "command": "~/.kiro/hooks/check-secrets.sh"

Local .kiro/ takes precedence over global ~/.kiro/ β€” remove the local copy after promoting to avoid conflicts.

Repository Structure

β”œβ”€β”€ agents/                  # Agent definitions (JSON config + markdown prompts)
β”‚   β”œβ”€β”€ leader.json          # Leader agent config (MCP servers, tools, subagent access)
β”‚   β”œβ”€β”€ leader.md            # Leader agent system prompt
β”‚   β”œβ”€β”€ coder.json / .md     # Coder agent config and prompt
β”‚   β”œβ”€β”€ ops.json / .md       # Ops agent config and prompt
β”‚   β”œβ”€β”€ reviewer.json / .md  # Reviewer agent config and prompt
β”‚   └── security-reviewer.json / .md  # Security reviewer config and prompt
β”œβ”€β”€ hooks/                   # Hook scripts β€” executed at agent lifecycle trigger points
β”‚   β”œβ”€β”€ check-dependency-pins.sh  # Block unpinned versions in dependency files
β”‚   β”œβ”€β”€ check-secrets.sh          # Block writes containing secrets or API keys
β”‚   β”œβ”€β”€ config-drift-guard.sh     # Block writes to config without approval
β”‚   β”œβ”€β”€ flywheel-log.sh           # Log turn summaries for flywheel analysis
β”‚   β”œβ”€β”€ git-context.sh            # Inject git status into agent context
β”‚   β”œβ”€β”€ guard-destructive-commands.sh  # Block dangerous shell commands
β”‚   └── validate-environment.sh   # Check required tools on agent spawn
β”œβ”€β”€ prompts/                 # Stored prompts β€” reusable workflows invoked by name
β”‚   └── flywheel.md          # Session analysis β†’ config improvement loop
β”œβ”€β”€ steering/                # Global behavioral rules for all agents
β”‚   β”œβ”€β”€ spec-workflow.md     # Spec-driven development loop with dependency research
β”‚   β”œβ”€β”€ sdk-verification.md  # Universal SDK/framework API verification tiers
β”‚   β”œβ”€β”€ doc-research.md      # Mandatory documentation research before implementation
β”‚   β”œβ”€β”€ deploy-validation.md # Post-deploy smoke test requirements
β”‚   β”œβ”€β”€ non-interactive.md   # All commands must run non-interactively
β”‚   β”œβ”€β”€ virtual-environments.md  # Dependency isolation requirements
β”‚   β”œβ”€β”€ documentation.md     # Documentation requirements for every spec
β”‚   β”œβ”€β”€ testing.md           # Test-first development workflow
β”‚   └── latest-versions.md   # Use latest stable versions by default
β”œβ”€β”€ skills/                  # Domain-specific knowledge files
β”‚   β”œβ”€β”€ agentcore-patterns/  # Amazon Bedrock AgentCore runtime, gateway, and memory patterns
β”‚   β”œβ”€β”€ aws-cli/             # AWS CLI best practices
β”‚   β”œβ”€β”€ cloudwatch-dashboards/ # CloudWatch dashboard observability patterns
β”‚   β”œβ”€β”€ docker-build/        # Docker image building patterns
β”‚   β”œβ”€β”€ documentation/       # Technical writing patterns
β”‚   β”œβ”€β”€ git-workflow/        # Git operations and conventions
β”‚   └── shell-scripting/     # Bash/Zsh scripting patterns
└── settings/
    └── cli.json             # Kiro CLI settings (default agent, model)

Key Concepts

Agents define who does what. Each agent has a JSON config (tools, MCP servers, model) and a markdown prompt (role, constraints, workflow).

Steering files are global rules that apply to all agents. They enforce consistency β€” like requiring non-interactive execution, dependency isolation, or mandatory SDK verification before writing code.

Skills are domain-specific knowledge that agents can reference. They provide patterns and best practices for specific tools and technologies.

Specs are created at runtime in .kiro/specs/YYYY-MM-DD-<slug>/ and contain the design decisions, task plans, review findings, and decision logs for each piece of work. Date-prefixed slugs ensure chronological ordering.

Prompts are stored workflows that you invoke by name. Unlike agent prompts (which define an agent's role), stored prompts are reusable task definitions β€” like scripts for the agent. See The Flywheel below for an example.

Hooks are scripts that execute at agent lifecycle trigger points β€” before/after tool use, on agent spawn, on user prompt submit, and when the assistant finishes responding. They enable enforcement (blocking unsafe operations), logging (collecting data for the flywheel), and guardrails (preventing config drift). See Hooks below.

Issues are tracked in issues/YYYY-MM-DD-<slug>/ at the project root. Each issue has a report.md (problem description, reproduction, investigation) and a summary.md (root cause, fix, prevention) written after resolution.

Steering Rules

Rule Purpose
spec-workflow.md Defines the full plan β†’ build β†’ review loop with parallel task groups, mandatory dependency research, mandatory final documentation group, and issue tracking
sdk-verification.md Tiered API verification β€” Tier 1 (always verify signatures, ARNs, imports) and Tier 2 (deep verify for alpha/unfamiliar SDKs)
doc-research.md Mandates using AWS documentation search and Context7 to look up live docs before writing implementation code
deploy-validation.md Every deploy script must include a post-deploy smoke test; exit non-zero on failure
non-interactive.md All commands must run without user prompts β€” pass flags, provide all inputs via arguments
virtual-environments.md Project dependency isolation per language (venv, node_modules, cargo, go mod)
documentation.md Every non-trivial change must include documentation updates; mandatory final group in every spec
testing.md Test-first development β€” define tests before or alongside implementation
latest-versions.md Pin dependency versions, 7-day quarantine on new releases, security patch exception

Hooks

Hooks are shell scripts that fire at specific points during agent execution. They receive JSON context via stdin and control behavior through exit codes: 0 to allow, 2 to block (preToolUse only), anything else to warn.

Enforcement hooks (preToolUse β€” block before damage)

Hook Matcher Purpose
check-dependency-pins.sh fs_write Blocks writes to package.json, requirements.txt, pyproject.toml, or Cargo.toml with unpinned versions. Protects against supply chain attacks.
check-secrets.sh fs_write Blocks writes containing AWS keys, private keys, GitHub/Slack tokens, or generic API key patterns. Allowlists .md files and placeholder values.
config-drift-guard.sh fs_write Blocks writes to steering/skills/agents config directories. Prevents agents from silently modifying their own configuration. Bypass with KIRO_ALLOW_CONFIG_WRITES=1.
guard-destructive-commands.sh execute_bash Blocks rm -rf /, DROP TABLE, terraform destroy (without -target), git push --force to protected branches, and kubectl delete namespace on critical namespaces.

Context hooks (agentSpawn / userPromptSubmit β€” inject information)

Hook Trigger Purpose
validate-environment.sh agentSpawn Checks that required tools are installed (python3, git, node, aws, docker, cargo) and prints versions. Exits non-zero only if critical tools are missing.
git-context.sh userPromptSubmit Injects a one-line git summary (branch, staged/modified/untracked counts, last commit) into agent context. Silent no-op outside git repos.

Observability hooks (stop β€” log after the fact)

Hook Trigger Purpose
flywheel-log.sh stop Logs turn summaries to ~/.kiro/flywheel-log.jsonl for the flywheel prompt.

All log files use 0o600 permissions and 10MB rotation. Enforcement hooks are applied to agents that write code (leader, coder, ops). Context and observability hooks are applied to all agents.

The Flywheel

The prompts/flywheel.md prompt turns your session history into configuration improvements. Every time you correct the agent β€” "no, I meant...", "try again but...", "stop, use X instead" β€” that's a signal. The flywheel reads recent session logs, identifies correction patterns, cross-references your existing steering/skills/agent configs, and proposes targeted changes to prevent recurrence.

Sessions ──▢ Corrections ──▢ Patterns ──▢ Config changes
    β–²                                         β”‚
    └──────────── better behavior β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

It works in five phases:

  1. Session analysis β€” scans ~/.kiro/sessions/cli/*.jsonl for correction events (explicit corrections, cancelled turns, repeated instructions, frustration signals)
  2. Pattern recognition β€” groups corrections by theme, filters out one-offs, focuses on patterns across 2+ sessions
  3. Cross-reference β€” checks existing steering docs, skills, and agent prompts for coverage gaps or weak rules
  4. Propose changes β€” writes a structured report with evidence (quoted user messages) and draft config content
  5. Interactive review β€” walks through each proposal for your approval before applying

Run it periodically β€” weekly works well β€” or whenever you notice the agent repeating a mistake you've already corrected:

kiro-cli chat
# then type: run flywheel

Each approved change makes the next run's report shorter. Over time, the agent accumulates your preferences and conventions as persistent configuration rather than ephemeral context.

Agent JSON Configuration

Each agent JSON file supports these fields:

Field Purpose
name Agent identifier
description Human-readable role description
prompt Path to the markdown system prompt
mcpServers MCP server configurations (HTTP or stdio)
tools Tool access pattern ("*" for all)
toolAliases Custom tool name mappings
allowedTools Explicit tool allowlist
resources File and skill resource patterns
hooks Lifecycle hooks (pre/post actions)
toolsSettings Tool-specific config (e.g., subagent access)
useLegacyMcpJson Whether to use legacy MCP config format
model AI model to use

Subagent Limitations

When agents run as subagents (delegated by the leader), some tools are not available in the subagent runtime:

Available Not Available
read, write, shell web_search, web_fetch
code (symbol search, references) use_aws (AWS CLI)
MCP tools grep, glob
thinking

Subagents can still execute AWS CLI commands via the shell tool, but won't have the structured use_aws tool. Plan your agent prompts accordingly.

MCP Servers

This configuration uses the following MCP servers:

Server Source Used By
aws-knowledge-mcp-server AWS (official) All agents
awslabs.document-loader-mcp-server AWS Labs (official) leader
awslabs.aws-iac-mcp-server AWS Labs (official) leader, coder, ops
context7 Upstash (open source) leader, coder, reviewer, security-reviewer
deepwiki DeepWiki (public) leader

Context7 provides live documentation lookup for any library or framework. DeepWiki provides AI-powered Q&A against GitHub repositories. Together with the AWS documentation servers, these give agents access to current API references instead of relying on training data.

Experimental Features (Optional)

This configuration ships with GA (generally available) features only. To enhance the experience, you can opt into these experimental features:

# Thinking tool β€” shows AI reasoning for complex problems
kiro-cli settings chat.enableThinking true

# Knowledge management β€” persistent context storage with semantic search
kiro-cli settings chat.enableKnowledge true

# Checkpointing β€” git-like snapshots of file changes during a session
kiro-cli settings chat.enableCheckpoint true

# Tangent mode β€” conversation checkpoints to explore side topics
kiro-cli settings chat.enableTangentMode true

# Context usage indicator β€” shows context window usage percentage in prompt
kiro-cli settings chat.enableContextUsageIndicator true

These features may change or be removed. See Experimental Features for details.

Customization

  • Add agents: Create a new <name>.json and <name>.md in agents/, then add the agent name to leader.json's toolsSettings.subagent.availableAgents array
  • Add steering rules: Drop a markdown file in steering/ β€” all agents will follow it
  • Add skills: Create a <name>/SKILL.md in skills/ β€” agents reference these for domain knowledge
  • Add prompts: Drop a markdown file in prompts/ β€” reusable workflows you can invoke by name during a chat session
  • Add hooks: Create executable scripts in hooks/ and reference them in agent JSON configs under the appropriate trigger (preToolUse, postToolUse, stop, agentSpawn, userPromptSubmit)
  • Change models: Edit the model field in each agent's JSON config. Available GA models: auto, claude-opus-4.5, claude-sonnet-4.5, claude-sonnet-4.0, claude-haiku-4.5
  • Change default agent: Edit chat.defaultAgent in settings/cli.json

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages