![]() |
VOOZH | about |
Agent hooks are automated triggers that execute agent prompts or shell commands when specific events occur in your IDE. Rather than manually asking for routine tasks, hooks handle them automatically.
Agent hooks set up automated responses to events such as:
By setting up hooks for common tasks, you can:
The agent hook system follows a two-step process:
You can create hooks in three ways: describe what you want in natural language, manually fill out a form, or write a JSON file directly.
Hooks are JSON files stored in .kiro/hooks/ (workspace-level) or ~/.kiro/hooks/ (user-level):
{ "version": "v1", "hooks": [ { "name": "lint-on-save", "trigger": "PostFileSave", "matcher": "\\.ts$", "action": { "type": "command", "command": "npm run lint" }, "timeout": 30, "enabled": true } ] }
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | Yes | Identifier shown in telemetry | |
description | string | No | Documentation only | |
trigger | string | Yes | When the hook fires | |
matcher | regex string | No | always-match | Filters by tool name or file path |
action | object | Yes | { type: "command", command: "..." } or { type: "agent", prompt: "..." } | |
timeout | integer (seconds) | No | 60 | 0 disables timeout. Ignored for agent actions |
enabled | boolean | No | true | Set false to skip without deleting |
You can also open the Hook UI from the Command Palette with Cmd + Shift + P (Mac) or Ctrl + Shift + P (Windows/Linux) and typing Kiro: Open Kiro Hook UI.
| Trigger | Fires when | Matcher matches | Can block? |
|---|---|---|---|
SessionStart | Session begins | No | |
Stop | Agent completes its turn | No | |
PreToolUse | Before tool executes | Tool name (regex) | Yes |
PostToolUse | After tool executes | Tool name (regex) | No |
PreTaskExec | Before a spec task starts | Yes | |
PostTaskExec | After a spec task finishes | No | |
UserPromptSubmit | User submits a prompt | Yes | |
PostFileCreate | After a file is created by the agent | File path (regex) | No |
PostFileSave | After a file is saved by the agent | File path (regex) | No |
PostFileDelete | After a file is deleted by the agent | File path (regex) | No |
For command actions:
| Exit code | Behavior |
|---|---|
0 | Success. STDOUT added to context (SessionStart, UserPromptSubmit) or ignored (others) |
2 | Block execution (PreToolUse, UserPromptSubmit, PreTaskExec only). STDERR returned to the agent |
| Other | Warning shown to user. Tool execution proceeds |
Now that you have created a hook file, you can further learn about hooks here: