Hooks: Automating Your Workflow
Duration: 5 min
Kiro hooks are event-driven automations that trigger Kiro actions when something happens in your project — a file is saved, a spec is updated, or a task is completed. They let you encode your team's workflow into the project itself.
Hook configuration
Hooks are defined in .kiro/hooks/ as YAML files. Each hook specifies a trigger (file glob, event type) and an action (a prompt Kiro runs automatically).
name: Generate tests on implementation
trigger:
type: file_change
glob: "src/**/*.ts"
exclude: "**/*.test.ts"
action:
prompt: |
A source file was just modified: {{changed_file}
If there is no corresponding test file, create one.
If a test file exists, update it to cover the new changes.
Follow the existing test patterns in the project.💡 Tip: Start with one or two hooks. Over-automating early creates noise. Add hooks when you notice yourself doing the same manual step repeatedly.
Common hook patterns
- Auto-generate tests when source files change
- Update API documentation when route files are modified
- Run a linter prompt when a PR is opened
- Sync design.md when the database schema changes
- Notify in chat when a task is marked complete
name: Sync API docs on route change
trigger:
type: file_change
glob: "src/routes/**/*.ts"
action:
prompt: |
The file {{changed_file} was modified.
Update docs/api.md to reflect any new or changed
endpoints, request shapes, or response formats.❓ What is a Kiro hook?