Use Claude Code hooks to know what an agent is doing
Reading a terminal to guess whether an agent is busy is fragile. Claude Code runs hooks at fixed points of a session, and they say exactly when a turn starts, when a tool runs, when a permission is needed and when the turn ends.
Checked 29 November 2026
The events that matter
| Hook event | What it tells you |
|---|---|
SessionStart | A session started, resumed or was cleared; it carries the session id early. |
UserPromptSubmit | A turn began: the agent is working. |
PreToolUse, PostToolUse | A tool started or ended: reading, editing, running a command. |
PermissionRequest | The agent stopped for your permission: it needs you. |
Stop | The turn ended normally: done. |
StopFailure | The turn ended on an error, such as a rate limit or an unknown model: failed, not done. |
SubagentStart, SubagentStop | A subagent began or finished, so the turn is not over yet. |
SessionEnd | The session closed. |
StopFailure matters: without it, a turn that died on an API error looks like a finished one. A connection that keeps failing can retry for about three minutes before it arrives, and the agent looks busy all that time.
Where to install them
Put hooks in .claude/settings.local.json in the worktree, not in the committed .claude/settings.json: the local file is per checkout and is not meant to be shared. Add it to .git/info/exclude so it is never committed by accident. A hook entry looks like this:
{
"hooks": {
"Stop": [
{ "hooks": [ { "type": "command", "command": "my-notifier stop" } ] }
],
"PermissionRequest": [
{ "hooks": [ { "type": "command", "command": "my-notifier permission" } ] }
]
}
}The hook receives the event as JSON on standard input. Keep the command fast and make it exit 0 even when your notifier is not running, so a hook can never slow down or break the agent.
How Ourkite Bot does it
- Install hooks writes the entries into the worktree's
.claude/settings.local.jsonand adds it to.git/info/exclude, only after you click. Hooks other people wrote are kept. - The hooks call
ourkite notify <event>from a stable copy in%APPDATA%\Ourkite\bin, so moving or updating the app does not break them. It always exits 0 and prints nothing. - The event travels as one JSON line over a loopback connection with a token that only the app's terminals receive.
ourkite hooks uninstallremoves exactly what was installed.
The state rules were checked against recordings of real Claude Code sessions (versions 2.1.330 to 2.1.332), including an API error and a refused connection.
Try the preview
The preview is shared by email while the signed installer is prepared. Tell us how many agents you run and what you would want first.
- Windows 10 or 11, 64-bit
- Claude Code, signed in
- git
Windows 10 and 11 · Claude Code · early preview