New to Kiro CLI V3? This page covers migration from CLI 2.x Hooks. For the current standalone format reference, see Hooks →.
Tip: Run
/upgrade-agentfirst. It converts object-form Hooks to a profile-scoped inline array and reports any triggers or matchers it could not convert safely.
CLI V3 supports two current placements. Agent profiles can keep profile-scoped Hooks in a flat hooks array. For automation that should work independently of a particular profile or across IDE and CLI, place the same Hook definitions in standalone .kiro/hooks/*.json files. The legacy object form remains accepted as compatibility input, but use the current array form when you revise migrated definitions.
CLI 2.x Hooks used an object keyed by camelCase trigger names:
{ "hooks": { "agentSpawn": [{ "command": "echo 'starting'" }], "preToolUse": [{ "command": "npm run lint", "matcher": "fs_read" }] } }
/upgrade-agent flattens the legacy object into an array in the agent profile. It gives each Hook a name and keeps the compatible camelCase trigger alias:
{ "hooks": [ { "name": "agentSpawn-0", "trigger": "agentSpawn", "action": { "type": "command", "command": "echo 'starting'" }, "timeout": 10 }, { "name": "preToolUse-0", "trigger": "preToolUse", "matcher": "read", "action": { "type": "command", "command": "npm run lint" }, "timeout": 10 } ] }
The converter preserves array-form Hooks. It drops a Hook that V3 cannot represent and reports a warning instead of writing an invalid profile.
A standalone .kiro/hooks/*.json file wraps the same Hook definitions in a versioned document. Use PascalCase trigger names when you create or revise a standalone Hook:
{ "version": "v1", "hooks": [ { "name": "lint-before-read", "trigger": "PreToolUse", "matcher": "read", "action": { "type": "command", "command": "npm run lint" }, "timeout": 30, "enabled": true } ] }
In the V2 terminal UI, both the V2 and V3 harnesses can match an exact tool name or a shared tool group. The table uses the V2 names for each tool:
| Matcher | Tools in the V2 group |
|---|---|
read | fs_read, grep, glob, code, introspect, tool_search |
write | fs_write, code |
shell | execute_bash |
web | web_fetch, web_search |
subagent | use_subagent |
The V1 harness treats read, write, shell, and subagent as aliases for one tool. It does not support the @mcp matcher or tag globs.
/upgrade-agent rewrites known CLI 2.x names to shared groups. For example, fs_read becomes read, and execute_cmd becomes shell. It warns when a group covers more tools than the old name. The fs_read rewrite also matches grep, glob, code, introspect, and tool_search.
Array-form matchers that are valid V3 tool IDs stay as authored. Kiro reports matchers that only one harness can evaluate.
Tool Hooks running through the V2 harness receive tool_tags with tool_name and tool_input. Use the tags when a script should treat every tool in a group the same way:
{ "tool_name": "fs_read", "tool_tags": ["read", "@builtin"], "tool_input": {} }
The V1 and V3 harnesses do not send tool_tags.
The triggers CLI V3 supports, what each one matches, and which ones can block are documented once in Hook types.
SessionEnd is a V3-only trigger. In Kiro CLI 3.1.0 or later, PreCompact and PostCompact are also V3-only and have no CLI 2.x equivalent.
In Kiro CLI 3.4.0 or later, PermissionRequest is also V3-only, runs command actions only, and has no CLI 2.x equivalent. A standalone file with "trigger": "permissionRequest" loads under /hooks in a V3 session without a validation error.
CLI 2.x object-form Hooks map onto the shared triggers as follows.
| CLI 2.x trigger | V3 trigger |
|---|---|
agentSpawn | SessionStart |
userPromptSubmit | UserPromptSubmit |
preToolUse | PreToolUse |
postToolUse | PostToolUse |
stop | Stop |
Store workspace Hooks in .kiro/hooks/. To run the same V3 Hook in every workspace, place it in ~/.kiro/hooks/. Global and workspace Hooks run alongside each other. See the full Hooks reference → for schema details, locations, and action types.
Hooks migration