Add Kiro IDE support (.kiro/) (#548)

Co-authored-by: Sungmin Hong <hsungmin@amazon.com>
This commit is contained in:
Himanshu Sharma
2026-03-20 01:50:35 -07:00
committed by GitHub
parent c8f631b046
commit ce828c1c3c
85 changed files with 12110 additions and 0 deletions

93
.kiro/hooks/README.md Normal file
View File

@@ -0,0 +1,93 @@
# Hooks in Kiro
Kiro supports **two types of hooks**:
1. **IDE Hooks** (this directory) - Standalone `.kiro.hook` files that work in the Kiro IDE
2. **CLI Hooks** - Embedded in agent configuration files for CLI usage
## IDE Hooks (Standalone Files)
IDE hooks are `.kiro.hook` files in `.kiro/hooks/` that appear in the Agent Hooks panel in the Kiro IDE.
### Format
```json
{
"version": "1.0.0",
"enabled": true,
"name": "hook-name",
"description": "What this hook does",
"when": {
"type": "fileEdited",
"patterns": ["*.ts", "*.tsx"]
},
"then": {
"type": "runCommand",
"command": "npx tsc --noEmit",
"timeout": 30
}
}
```
### Required Fields
- `version` - Hook version (e.g., "1.0.0")
- `enabled` - Whether the hook is active (true/false)
- `name` - Hook identifier (kebab-case)
- `description` - Human-readable description
- `when` - Trigger configuration
- `then` - Action to perform
### Available Trigger Types
- `fileEdited` - When a file matching patterns is edited
- `fileCreated` - When a file matching patterns is created
- `fileDeleted` - When a file matching patterns is deleted
- `userTriggered` - Manual trigger from Agent Hooks panel
- `promptSubmit` - When user submits a prompt
- `agentStop` - When agent finishes responding
- `preToolUse` - Before a tool is executed (requires `toolTypes`)
- `postToolUse` - After a tool is executed (requires `toolTypes`)
### Action Types
- `runCommand` - Execute a shell command
- Optional `timeout` field (in seconds)
- `askAgent` - Send a prompt to the agent
### Environment Variables
When hooks run, these environment variables are available:
- `$KIRO_HOOK_FILE` - Path to the file that triggered the hook (for file events)
## CLI Hooks (Embedded in Agents)
CLI hooks are embedded in agent configuration files (`.kiro/agents/*.json`) for use with `kiro-cli`.
### Format
```json
{
"name": "my-agent",
"hooks": {
"agentSpawn": [
{
"command": "git status"
}
],
"postToolUse": [
{
"matcher": "fs_write",
"command": "npx tsc --noEmit"
}
]
}
}
```
See `.kiro/agents/tdd-guide-with-hooks.json` for a complete example.
## Documentation
- IDE Hooks: https://kiro.dev/docs/hooks/
- CLI Hooks: https://kiro.dev/docs/cli/hooks/

View File

@@ -0,0 +1,14 @@
{
"name": "auto-format",
"version": "1.0.0",
"enabled": true,
"description": "Automatically format TypeScript and JavaScript files on save",
"when": {
"type": "fileEdited",
"patterns": ["*.ts", "*.tsx", "*.js"]
},
"then": {
"type": "askAgent",
"prompt": "A TypeScript or JavaScript file was just saved. If there are any obvious formatting issues (indentation, trailing whitespace, import ordering), fix them now."
}
}

View File

@@ -0,0 +1,14 @@
{
"name": "code-review-on-write",
"version": "1.0.0",
"enabled": true,
"description": "Performs a quick code review after write operations to catch common issues",
"when": {
"type": "postToolUse",
"toolTypes": ["write"]
},
"then": {
"type": "askAgent",
"prompt": "Code was just written or modified. Perform a quick review checking for: 1) Common security issues (SQL injection, XSS, etc.), 2) Error handling, 3) Code clarity and maintainability, 4) Potential bugs or edge cases. Only comment if you find issues worth addressing."
}
}

View File

@@ -0,0 +1,14 @@
{
"version": "1.0.0",
"enabled": true,
"name": "console-log-check",
"description": "Check for console.log statements in JavaScript and TypeScript files to prevent debug code from being committed.",
"when": {
"type": "fileEdited",
"patterns": ["*.js", "*.ts", "*.tsx"]
},
"then": {
"type": "askAgent",
"prompt": "A JavaScript or TypeScript file was just saved. Check if it contains any console.log statements that should be removed before committing. If found, flag them and offer to remove them."
}
}

View File

@@ -0,0 +1,14 @@
{
"name": "doc-file-warning",
"version": "1.0.0",
"enabled": true,
"description": "Warn before creating documentation files to avoid unnecessary documentation",
"when": {
"type": "preToolUse",
"toolTypes": ["write"]
},
"then": {
"type": "askAgent",
"prompt": "You are about to create or modify a file. If this is a documentation file (README, CHANGELOG, docs/, etc.) that was not explicitly requested by the user, consider whether it's truly necessary. Documentation should be created only when:\n\n1. Explicitly requested by the user\n2. Required for project setup or usage\n3. Part of a formal specification or requirement\n\nIf you're creating documentation that wasn't requested, briefly explain why it's necessary or skip it. Proceed with the write operation if appropriate."
}
}

View File

@@ -0,0 +1,13 @@
{
"name": "extract-patterns",
"version": "1.0.0",
"enabled": true,
"description": "Suggest patterns to add to lessons-learned.md after agent execution completes",
"when": {
"type": "agentStop"
},
"then": {
"type": "askAgent",
"prompt": "Review the conversation that just completed. If you identified any genuinely useful patterns, code style preferences, common pitfalls, or architecture decisions that would benefit future work on this project, suggest adding them to .kiro/steering/lessons-learned.md. Only suggest patterns that are:\n\n1. Project-specific (not general best practices already covered in other steering files)\n2. Repeatedly applicable (not one-off solutions)\n3. Non-obvious (insights that aren't immediately apparent)\n4. Actionable (clear guidance for future development)\n\nIf no such patterns emerged from this conversation, simply respond with 'No new patterns to extract.' Do not force pattern extraction from every interaction."
}
}

View File

@@ -0,0 +1,14 @@
{
"name": "git-push-review",
"version": "1.0.0",
"enabled": true,
"description": "Reviews shell commands before execution to catch potentially destructive git operations",
"when": {
"type": "preToolUse",
"toolTypes": ["shell"]
},
"then": {
"type": "askAgent",
"prompt": "A shell command is about to be executed. If this is a git push or other potentially destructive operation, verify that: 1) All tests pass, 2) Code has been reviewed, 3) Commit messages are clear, 4) The target branch is correct. If it's a routine command, proceed without comment."
}
}

View File

@@ -0,0 +1,13 @@
{
"version": "1.0.0",
"enabled": true,
"name": "quality-gate",
"description": "Run a full quality gate check (build, type check, lint, tests). Trigger manually from the Agent Hooks panel.",
"when": {
"type": "userTriggered"
},
"then": {
"type": "runCommand",
"command": "bash .kiro/scripts/quality-gate.sh"
}
}

View File

@@ -0,0 +1,13 @@
{
"name": "session-summary",
"version": "1.0.0",
"enabled": true,
"description": "Generate a brief summary of what was accomplished after agent execution completes",
"when": {
"type": "agentStop"
},
"then": {
"type": "askAgent",
"prompt": "Provide a brief 2-3 sentence summary of what was accomplished in this conversation. Focus on concrete outcomes: files created/modified, problems solved, decisions made. Keep it concise and actionable."
}
}

View File

@@ -0,0 +1,14 @@
{
"name": "tdd-reminder",
"version": "1.0.0",
"enabled": true,
"description": "Reminds the agent to consider writing tests when new TypeScript files are created",
"when": {
"type": "fileCreated",
"patterns": ["*.ts", "*.tsx"]
},
"then": {
"type": "askAgent",
"prompt": "A new TypeScript file was just created. Consider whether this file needs corresponding test coverage. If it contains logic that should be tested, suggest creating a test file following TDD principles."
}
}

View File

@@ -0,0 +1,14 @@
{
"version": "1.0.0",
"enabled": true,
"name": "typecheck-on-edit",
"description": "Run TypeScript type checking when TypeScript files are edited to catch type errors early.",
"when": {
"type": "fileEdited",
"patterns": ["*.ts", "*.tsx"]
},
"then": {
"type": "askAgent",
"prompt": "A TypeScript file was just saved. Check for any obvious type errors or type safety issues in the modified file and flag them if found."
}
}