Loading image...Kiro
  • CLI
  • Web
  • Enterprise
  • Pricing
  • Docs
SIGN INDOWNLOADS
Loading image...Kiro
Loading image...Kiro
Product
  • About Kiro
  • CLI
  • Web
  • Pricing
  • Downloads
For
  • Enterprise
  • Startups
  • Students
Community
  • Overview
  • Ambassadors
  • Discord
  • Events
  • Powers
  • Shop
  • Showcase
Resources
  • Docs
  • Blog
  • Changelog
  • FAQs
  • Report a bug
  • Suggest an idea
  • Billing support
Social
Site TermsLicenseResponsible AI PolicyLegalPrivacy PolicyCookie Preferences
  1. Docs
  2. CLI
  3. V3
  4. Hooks

Hooks


Overview

Hooks in v3 are standalone files with a versioned schema, two action types (shell commands and agent prompts), and new lifecycle triggers for specs, file deletion, and manual invocation. You define them once in .kiro/hooks/ and they apply across all agents in the workspace.

Existing embedded hooks in agent configs still work during the transition. Run kiro-cli agent migrate to auto-convert them to the new format.

The new format

Each hooks file is a standalone .kiro/hooks/<name>.json:

json
{ "version": "v1", "hooks": [ { "name": "lint-on-save", "trigger": "PostFileSave", "matcher": "\\.ts$", "action": { "type": "command", "command": "npm run lint" }, "timeout": 30, "enabled": true }, { "name": "remind-tests", "trigger": "PreToolUse", "matcher": "fs_write|str_replace", "action": { "type": "agent", "prompt": "Ensure tests are updated for this change" } } ] }

Two action types:

  • Command -- runs a shell command. Receives hook context as JSON on stdin. Exit code determines behavior (0 = success, 2 = block for PreToolUse/UserPromptSubmit).
  • Agent -- appends a prompt string to the model context. No subprocess spawned. Use for lightweight steering and guardrails.

Trigger reference

TriggerFires whenMatcher matchesCan block?
SessionStartSession begins--No
StopSession ends--No
PreToolUseBefore tool executesTool name (regex)Yes
PostToolUseAfter tool executesTool name (regex)No
PreTaskExecBefore a spec task starts--Yes
PostTaskExecAfter a spec task finishes--No
UserPromptSubmitUser submits a prompt--Yes
PostFileCreateAfter a file is createdFile path (regex)No
PostFileSaveAfter a file is savedFile path (regex)No
PostFileDeleteAfter a file is deletedFile path (regex)No
ManualUser-triggered on demand--No

Trigger name mapping (2.x to 3.0)

Old triggerNew triggerNotes
agentSpawnSessionStartFires when a new session begins
userPromptSubmitUserPromptSubmitCase change only
preToolUsePreToolUseCase change only
postToolUsePostToolUseCase change only
fileEditedPostFileSaveRenamed for clarity
fileCreatedPostFileCreateRenamed for clarity
stopStopCase change only

New in 3.0: PreTaskExec, PostTaskExec, PostFileDelete, Manual

Matcher semantics

The matcher field is a regex pattern. What it matches depends on the trigger:

TriggerMatcher evaluates against
PostFileSave, PostFileCreate, PostFileDeleteFile path
PreToolUse, PostToolUseTool name
UserPromptSubmitPrompt text
SessionStart, Stop, PreTaskExec, PostTaskExec, ManualNot evaluated -- hook always fires

Regex patterns from 2.x transfer directly. The {{filePath}} template variable is available in command actions for file-related triggers.

Hook fields

FieldTypeRequiredDefaultDescription
namestringYes--Identifier shown in telemetry
descriptionstringNo--Documentation only
triggerstringYes--When the hook fires
matcherregex stringNoalways-matchFilters by tool name or file path
actionobjectYes--{ type: "command", command: "..." } or { type: "agent", prompt: "..." }
timeoutinteger (seconds)No600 disables timeout. Ignored for agent actions
enabledbooleanNotrueSet false to skip without deleting

Exit code behavior

For command actions:

Exit codeBehavior
0Success. STDOUT added to context (SessionStart, UserPromptSubmit) or ignored (others)
2Block execution (PreToolUse, UserPromptSubmit only). STDERR returned to LLM
OtherWarning shown to user. Tool execution proceeds

Next steps

  • Agent config -- agent profile format and tags
  • Permissions -- capability-based permission model
Page updated: June 17, 2026
Permissions
Agent config