Hooks let you automate reactions to events in Crew. When a tool fires, a session starts, or a file changes, a hook can run a script, inject context, or gate the action.
Open Agent Capabilities → Hooks. You can view, create, edit, and delete hooks from the browser. Each hook shows its trigger, action, and optional matcher pattern.
Hooks are JSON files at ~/.kiro/crew/hooks/ (or project-level at .kiro/hooks/). Each file can define one or more hooks.
A hook has three parts:
| Trigger | Fires when |
|---|---|
SessionStart | A new session begins |
PreToolUse | Before a tool is about to execute |
PostToolUse | After a tool has executed |
PreTaskExec | Before a spec task status is set to in_progress |
PostTaskExec | After a spec task status is set to completed |
PostFileSave | A file is saved |
PostFileCreate | A file is created |
PostFileDelete | A file is deleted |
UserPromptSubmit | A message is sent to the agent |
Stop | An agent execution completes |
Runs a shell command. The command receives session context as JSON on stdin.
Use for: running linters, triggering builds, sending notifications, validating changes.
Exit codes matter:
0 — success (output forwarded for some triggers)2 — block the action (for PreToolUse, UserPromptSubmit)Injects a static prompt into the model context.
Use for: adding reminders, enforcing patterns, injecting context about the current state.
A hook that runs the linter whenever a TypeScript file is saved:
PostFileSave\.(ts|tsx)$npm run lintA hook that adds a reminder before any file write:
PreToolUsefs_write|str_replacePostTaskExecnpm run testPreToolUse hooks can block a tool call by exiting with code 2. This is how you add custom deny rules beyond the built-in 137 patterns. The agent sees the block and tries a different approach.
The hook is active immediately — no restart needed.
Hooks