Loading image...Kiro

Product

  • About Kiro
  • IDE
  • CLI
  • Web
  • Mobile
  • Crew
  • 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
Loading image...Kiro
  • Enterprise
  • Pricing
  • Docs
SIGN INDOWNLOADS
Loading image...Kiro

Get Started

InstallationAuthenticationYour first project

Models

OverviewAvailable modelsReasoning effort

Features

How Kiro works
Specs
Steering
Hooks
Hook triggers
Hook actions
Examples
Management
Best practices
Troubleshooting
MCP
Permissions
Custom agents
Agent Skills
Powers
CompactionKiroignoreCheckpoints and rewind
Built-in tools
Configuration scopes

IDE 1.x

What's new in 1.0
Setup & First Run
Editor
Chat
Experimental
Troubleshooting0.x reference

CLI

What's new in 3.0
Setup & First Run
Terminal UI
Chat
Headless modeACPAuto complete
Experimental
2.x reference

Crew

Quick startInstallationRunning 24/7
Chat
Agent Capabilities
Features
Interfaces
Apps
ConfigurationSecurityTroubleshooting

Web - Preview

Setup & First RunIdentity Center
Connect your repositories
Working with the agent
Autonomous modeAutomations
Sandbox

Mobile - Preview

Overview

Commands and Reference

CLI commandsSlash commandsBuilt-in toolsExit codesSettings

Billing

OverviewManaging your subscriptionUpgrading your planDowngrading your planCancelling your planPurchasing add-on creditsManaging your paymentsManaging usage notificationsManaging your taxesContacting billing supportDeleting your accountRelated questions

Enterprise

ConceptsOnboarding quickstart
Connecting your identity provider
Subscribe your teamManage subscriptions
Governance
Monitor and track
SettingsManaged updatesBillingIAMSupported regions

Privacy and Security

OverviewData protectionCode referencesCompliance validationInfrastructure securityIAM permissionsFirewalls, proxies, and data perimetersVPC endpoints (AWS PrivateLink)

Guides

Overview
Language support
Learn by playing

Migration

Migrating from Q DeveloperMigrating from VSCodeUpgrading from Q CLI
  1. Docs
  2. Features
  3. Hooks

Hooks


Hooks run shell commands or agent prompts automatically when specific events happen in your session - a file is saved, a tool is invoked, or a task completes. You define the trigger and the action; Kiro handles the execution.

CapabilityIDECLIWebMobile
Event-driven hooks✓✓——
Shell command actions✓✓——
Agent prompt actions✓✓——
Hook creation via chat✓✓——

What you can do with hooks

  • Enforce standards - run linters, formatters, or type checks automatically on file save
  • Gate dangerous operations - block tool execution unless preconditions are met (PreToolUse)
  • Generate companion files - auto-create tests, docs, or translations when new source files appear
  • Validate before commit - check code quality before the agent finalizes changes
  • Inject context - feed the agent additional instructions based on what it's doing

Quick example

A PostFileSave hook that runs ESLint whenever you save a TypeScript file:

json
{ "version": "v1", "hooks": [{ "name": "Lint on save", "trigger": "PostFileSave", "matcher": "\\.(ts|tsx)$", "action": { "type": "command", "command": "npx eslint --fix" } }] }

This file lives at .kiro/hooks/lint-on-save.json and activates automatically - no manual prompting needed. The hook receives the saved file path and session context via STDIN. See Hook Actions for details on how commands receive event data.

How hooks work

Hook configurations are JSON files stored in .kiro/hooks/. Each file defines one or more hooks with a trigger event, an optional matcher pattern, and an action.

When the trigger event fires, Kiro checks the matcher. If it matches (or no matcher is specified), the action executes:

  • Command actions run a shell command in your project root. The command receives session context as JSON on STDIN.
  • Agent actions inject a prompt into the current conversation, steering the agent's behavior.

Available triggers

TriggerWhen it firesCan block?
PostFileSaveAfter a file is savedNo
PostFileCreateAfter a new file is createdNo
PostFileDeleteAfter a file is deletedNo
PreToolUseBefore a tool is about to executeYes
PostToolUseAfter a tool has executedNo
UserPromptSubmitWhen a message is sent to the agentYes
SessionStartWhen a new session beginsNo
StopWhen the agent finishes respondingNo
PreTaskExecBefore a spec task startsYes
PostTaskExecAfter a spec task completesNo
Info

Manual hooks from earlier IDE versions have been replaced by manual steering files. See Steering for details.

See Hook Triggers for detailed descriptions, matcher patterns, and use cases for each trigger type.

Hook file schema

Each hook file is a standalone JSON file at .kiro/hooks/<id>.json. The full schema:

json
{ "version": "v1", "hooks": [ { "name": "example-hook", "trigger": "PostFileSave", "matcher": "\\.(ts|tsx)$", "action": { "type": "command", "command": "npx eslint --fix" } } ] }

Field reference

FieldRequiredDescription
versionYesSchema version - currently "v1"
hooksYesArray of hook definitions
hooks[].nameYesHuman-readable identifier for the hook
hooks[].descriptionNoDocumentation only
hooks[].triggerYesEvent that fires the hook (PascalCase - see triggers table)
hooks[].matcherNoRegex pattern to filter which events fire this hook. For PreToolUse/PostToolUse, matches tool name. For file events, matches file path. Defaults to always-match.
hooks[].action.typeYes"command" (shell command) or "agent" (inject prompt)
hooks[].action.commandCond.Shell command to run (required when type is "command")
hooks[].action.promptCond.Prompt text to inject (required when type is "agent")
hooks[].timeoutNoTimeout in seconds for command actions (default: 60). 0 disables the timeout. Ignored for agent actions.
hooks[].enabledNoSet false to skip the hook without deleting it (default: true)
hooks[].confirmNoAsk for confirmation before a Stop command hook runs. See Confirmation prompts.

Confirmation prompts

A command hook on the Stop trigger can ask before it runs. Add a confirm block with the question to ask and the options to present:

json
{ "version": "v1", "hooks": [ { "name": "Submit session results", "trigger": "Stop", "action": { "type": "command", "command": "./submit.sh" }, "confirm": { "question": "Submit this session's results?", "options": [ { "id": "submit", "label": "Yes, submit", "run": true }, { "id": "dismiss", "label": "Not this time", "run": false } ] } } ] }

Each option has an id, a label shown on the button, and a run flag that controls whether the hook's command executes when that option is chosen.

Dynamic confirm options with confirmCommand

To decide at run time whether and what to ask, add an optional confirmCommand to the confirm block. The command runs before the prompt appears, and its stdout controls the prompt as JSON:

  • { "skip": true } suppresses the prompt and skips the hook for this turn
  • { "question": "...", "options": [...] } replaces the static question and options
json
{ "confirm": { "question": "Submit this session's results?", "confirmCommand": "./confirm-options.sh", "options": [ { "id": "submit", "label": "Yes, submit", "run": true }, { "id": "dismiss", "label": "Not this time", "run": false } ] } }

If confirmCommand exits non-zero, times out, or prints invalid JSON, the static question and options are used as a fallback. This makes it useful for prompts that should only appear under certain conditions - for example, a "don't ask again this session" option that writes a marker file and returns { "skip": true } on later turns.

File naming and location

  • Location: .kiro/hooks/ in your project root
  • Naming: Any .json filename works - use descriptive kebab-case names (e.g., lint-on-save.json, guard-writes.json)
  • Multiple hooks per file: A single file can define multiple hooks in the hooks array
  • Activation: Hooks activate automatically when a session starts - no manual registration needed

Setting up hooks

Click the + button in the Agent Hooks section of the Kiro panel and select Ask Kiro to create a hook. Describe what you want in natural language - for example, "run tests after every file save" - and Kiro generates the hook configuration through conversation.

The resulting hook is saved as a JSON file in .kiro/hooks/.

Previous versions

The .kiro/hooks/*.json format was introduced in IDE 1.0 and CLI 3.0. If you're upgrading from an earlier version:

  • From IDE 0.x - Hooks moved from the previous format to standalone JSON files with PascalCase trigger names. See What's new in IDE 1.0: Hooks for the trigger mapping.
  • From CLI 2.x - Hooks moved from embedded fields in agent config to standalone files. Run kiro-cli agent migrate to auto-convert, or see CLI 3.0 Hooks migration for the manual mapping.

Next steps

  • Hook Triggers - Trigger types and their use cases
  • Hook Actions - Command and agent action details
  • Management - Organize, edit, and maintain hooks
  • Best Practices - Patterns for effective hook design
  • Examples - Templates you can use
  • Troubleshooting - Common issues and solutions
Page updated: August 6, 2026
Steering
Hook triggers