Kiro Hooks Guide
They enable developers to streamline workflows by responding in real time to changes like file edits, builds, or test runs. By linking events to intelligent automation, Kiro hooks help reduce manual steps, enforce consistency, and accelerate development.
Event Types
Hooks support a range of event types. File-based events — fileEdited, fileCreated, and fileDeleted — fire when a user saves, creates, or removes a file, and can be scoped to specific paths using glob patterns. Prompt-based events like promptSubmit and agentStop fire around agent interactions. Tool-based events like preToolUse and postToolUse let you intercept agent tool calls before or after they execute. Lifecycle events like preTaskExecution and postTaskExecution integrate with Kiro's spec system.
Hook Actions
Each hook maps its event to one of two actions. askAgent sends a prompt to the agent — useful for code review, documentation updates, or enforcing standards. runCommand executes a shell command — useful for running linters, tests, or build steps automatically.
Practical Examples
A common use case is running a linter whenever a TypeScript file is saved. Set the event to fileEdited with a pattern of *.ts, the action to runCommand, and the command to npm run lint. The hook fires automatically on every save with no manual intervention.
Another pattern is using preToolUse with askAgent to review write operations before they happen. This is useful for teams that want a lightweight guardrail: the agent checks the proposed change against coding standards before it's applied. If the hook output indicates the operation should be blocked, the tool call is cancelled.
You can explore more configurations in the official examples at https://kiro.dev/docs/hooks/examples/.