Guide
Hooks let a script follow every Claude Code session: when a turn starts, when Claude needs you, when it finishes. We built Watchlamp, a status light for Claude Code, entirely on them. This is the map we wish we had had: which events to listen to, what each one tells you, and what none of them will.
| File | Applies to |
|---|---|
~/.claude/settings.json | All your projects |
.claude/settings.json | One project, shared through the repository |
.claude/settings.local.json | One project, just for you (not committed) |
Type /hooks in Claude Code to browse the hooks it has loaded and where each one comes from. Settings files are strict JSON: a comment or a trailing comma is an error.
| Event | Runs when | What it tells you |
|---|---|---|
SessionStart | A session starts or resumes | There is a session to follow |
UserPromptSubmit | A prompt is submitted | A turn has started |
PreToolUse, PostToolUse | Before and after each tool call | Claude is working, and on what (tool_name, tool_input) |
PermissionRequest | A tool call needs your permission, at once | Claude is waiting for you |
Notification | permission_prompt after about 6 s; idle_prompt about 60 s after a turn ends | Someone should look |
Stop | Claude finishes responding | The turn is done |
StopFailure | The turn ends because of an API error | It stopped and needs a look |
SubagentStart, SubagentStop | A subagent starts or finishes | Work goes on in a subagent |
SessionEnd | The session ends | Forget it |
Every event arrives as JSON on standard input with session_id, cwd, transcript_path and hook_event_name, so one script can follow any number of sessions.
PostToolUse, when it finishes, so a long command keeps looking like it is waiting until then.Stop does not run when you stop a turn yourself. Watchlamp notices the interruption at the end of the session's transcript instead.Stop still runs. Its background_tasks field lists what is still in flight, each entry with a type such as shell or subagent, a status, a description and, for shells, the command. That is how a script can tell "done" from "waiting for its tests". A dev server in that list never finishes, so do not count every shell as work in progress.Notification event comes about six seconds after a permission prompt appears. For an immediate signal, listen to PermissionRequest.PreToolUse and PostToolUse run around every tool call, and Claude waits for them. Watchlamp's hook takes about 15 ms; anything slow belongs in a separate process.PreToolUse, and keeps Claude working in Stop.This script keeps the latest event of each session in a small file, a starting point for a status line or a dashboard:
#!/bin/bash
# ~/.claude/status.sh: the latest event of each session, in ~/.claude/status/<session>.json
input=$(cat)
mkdir -p ~/.claude/status
jq -c '{event: .hook_event_name, cwd, at: now}' <<< "$input" > ~/.claude/status/"$(jq -r .session_id <<< "$input")".json
Make it executable (chmod +x ~/.claude/status.sh; jq comes with macOS 15 and later) and register it in ~/.claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "$HOME/.claude/status.sh" }] }],
"PermissionRequest": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "$HOME/.claude/status.sh" }] }],
"PostToolUse": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "$HOME/.claude/status.sh" }] }],
"Stop": [{ "hooks": [{ "type": "command", "command": "$HOME/.claude/status.sh" }] }],
"StopFailure": [{ "hooks": [{ "type": "command", "command": "$HOME/.claude/status.sh" }] }]
}
}
From there it is a matter of turning events into states and handling the gaps above. That is what Watchlamp does, free, with a lamp for every session that you can see from across the room.
No. Stop runs when Claude finishes responding, not when you interrupt a turn. A status script has to notice an interruption some other way, for example in the session's transcript.
No. The next event is the PostToolUse of the approved tool, when it finishes, so a long command still looks like it is waiting until then.
Yes. PreToolUse and PostToolUse hooks run around every tool call, and Claude waits for them. Keep them to a few milliseconds and do slow work elsewhere.
In ~/.claude/settings.json. Hooks in a project's .claude/settings.json apply to that project and can be committed; .claude/settings.local.json is for your own, uncommitted ones.
Watchlamp is a free Mac app that puts one lamp per Claude Code session on your screen: it glows while Claude works, blinks when Claude needs you, and goes dark when the turn is done. For the desktop app and claude in the terminal.