Agent hooks support various trigger types, each designed for specific automation scenarios. Understanding these types helps you choose the right approach for your workflow needs.
This page describes standalone Hook definitions stored in .kiro/hooks/*.json. Inline profile Hooks have separate current and legacy forms; see the agent configuration reference.
File and task triggers are available in the IDE and CLI V3. Web can store Hook configuration for later local use, but Web sessions do not run these triggers. The table below shows what's supported where.
| Trigger | IDE | CLI | Web |
|---|---|---|---|
| Prompt Submit | ✓ | ✓ | — |
| Agent Stop | ✓ | ✓ | — |
| Session Start | ✓ | V3 | — |
| Agent Spawn | — | 2.x / V3 alias | — |
| Session End | — | V3 | — |
| Pre Tool Use | ✓ | ✓ | — |
| Post Tool Use | ✓ | ✓ | — |
| File Create | ✓ | V3 | — |
| File Save | ✓ | V3 | — |
| File Delete | ✓ | V3 | — |
| Pre Task Execution | ✓ | V3 | — |
| Post Task Execution | ✓ | V3 | — |
| Manual | — | Listed in V3 | — |
| Legacy Manual Hook | Legacy only | — | — |
Triggers when the user submits a prompt.
When using the shell command action, the user prompt can be accessed via the USER_PROMPT environment variable.
Use Cases:
Triggers when the agent has completed its turn and finished responding to the user.
This is useful for running post-processing tasks like code compilation, testing, formatting, or cleanup after the agent's response.
Use Cases:
Triggers when a new chat session starts in the IDE or CLI V3.
Use Cases:
CLI 2.x used agentSpawn when the agent was first activated. CLI V3 uses SessionStart as the canonical trigger but accepts AgentSpawn and agentSpawn for compatibility. The event provides no tool context.
{ "hook_event_name": "agentSpawn", "cwd": "/current/working/directory", "session_id": "abc123-def456-789" }
Exit Code Behavior:
Use Cases:
The SessionEnd trigger fires when a CLI V3 session is torn down.
Triggers when the agent is about to invoke a tool. Can validate and block tool usage.
In the Tool name pattern field, provide an exact tool ID, a built-in category, a source selector, or a regular expression. You can specify multiple entries. The following built-in categories are supported:
You can also use source selectors:
@<server> - all tools from one MCP server, for example @postgres@<server>/<tool> - one tool from one MCP server, for example @postgres/queryThe editor checks each entry as a regular expression matched against tool IDs. A plain name such as read can therefore match any tool ID containing that text. Leave the field blank to match every tool.
Hook JSON files also accept wildcard patterns. Use * to match any number of characters and ? to match a single character. Edit the Hook JSON file directly to use these patterns because the IDE editor rejects them as invalid regular expressions.
You can ask Kiro for the names of the available tools.
Use Cases:
Triggers after the agent has invoked a tool, with access to tool results.
For details on the Tool name field, refer to the Pre Tool Use section above.
Use Cases:
Triggers when the agent creates new files matching specific patterns in your workspace.
Use Cases:
Triggers when the agent saves or modifies files matching specific patterns.
Use Cases:
Triggers when the agent deletes files matching specific patterns.
Use Cases:
Triggers before a spec task begins execution.
Use Cases:
Triggers after a spec task completes execution.
Use Cases:
CLI V3 recognizes and lists Manual Hook definitions, but /hooks doesn't provide an action to invoke them.
Manual Hooks created in IDE 0.x continue to appear in the Agent Hooks panel with a legacy label. Enabled legacy manual Hooks remain runnable using the play button next to the Hook name or Start Hook in the Hook view.
IDE 0.x userTriggered Hooks don't have a v1 IDE trigger equivalent, and you can't create a new Manual-trigger Hook in the IDE. For a new IDE on-demand workflow, create a manually included Steering file; it runs as a /<filename> slash command.
For MCP tools, V3 Hook events use the sanitized internal tool ID mcp_<server>_<tool>, not the @server/tool display name:
{ "hook_event_name": "PreToolUse", "cwd": "/current/working/directory", "session_id": "abc123-def456-789", "tool_name": "mcp_postgres_query", "tool_input": { "sql": "SELECT * FROM orders LIMIT 10;" } }
This applies to both Pre Tool Use and Post Tool Use Hooks when targeting MCP server tools. In the Hook's matcher, use either the @<server> or @<server>/<tool> selector or a regex against the internal ID.
Hook types