Skip to main content

Hooks migration

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-agent first. 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.

Legacy object format

CLI 2.x Hooks used an object keyed by camelCase trigger names:

json
{ "hooks": { "agentSpawn": [{ "command": "echo 'starting'" }], "preToolUse": [{ "command": "npm run lint", "matcher": "fs_read" }] } }

Current profile-scoped format

/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:

json
{ "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.

Current standalone file format

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:

json
{ "version": "v1", "hooks": [ { "name": "lint-before-read", "trigger": "PreToolUse", "matcher": "read", "action": { "type": "command", "command": "npm run lint" }, "timeout": 30, "enabled": true } ] }

Migrate tool matchers

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:

MatcherTools in the V2 group
readfs_read, grep, glob, code, introspect, tool_search
writefs_write, code
shellexecute_bash
webweb_fetch, web_search
subagentuse_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 Hook input in the V2 harness

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:

json
{ "tool_name": "fs_read", "tool_tags": ["read", "@builtin"], "tool_input": {} }

The V1 and V3 harnesses do not send tool_tags.

Trigger reference

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.

Trigger name changes

CLI 2.x triggerV3 trigger
agentSpawnSessionStart
userPromptSubmitUserPromptSubmit
preToolUsePreToolUse
postToolUsePostToolUse
stopStop

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.

Page updated: November 17, 2026