A collection of hooks for Claude Code — the CLI for Claude by Anthropic.
Sends a macOS desktop notification whenever Claude needs your attention. Clicking the notification banner focuses the exact iTerm2 window and tab running that Claude session.
The notification will not fire if that iTerm2 tab is already the active, focused window.
Notification format:
| Field | Content |
|---|---|
| Title | Working directory relative to home (e.g. ~/code/my-project) |
| Message | Notification type (e.g. Claude Code — Waiting for Input) |
Notification types:
| Event | Message |
|---|---|
| Waiting for input | Claude Code — Waiting for Input |
| Needs permission | Claude Code — Needs Permission |
| Authenticated | Claude Code — Authenticated |
| Other | Claude Code |
brew install terminal-notifierWithout terminal-notifier, notifications will still fire via osascript but clicking them won't focus the iTerm2 window — it will jump to front immediately when the hook fires instead.
mkdir -p ~/.claude/hooks
curl -o ~/.claude/hooks/notify.sh https://raw.githubusercontent.com/Neilos/claude-code-hooks/main/hooks/notify.sh
curl -o ~/.claude/hooks/focus-terminal.scpt https://raw.githubusercontent.com/Neilos/claude-code-hooks/main/hooks/focus-terminal.scpt
chmod +x ~/.claude/hooks/notify.shAdd the following to ~/.claude/settings.json (create it if it doesn't exist):
{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "/Users/YOUR_USERNAME/.claude/hooks/notify.sh"
}
]
}
]
}
}Replace YOUR_USERNAME with your macOS username. Use an absolute path — tilde (~) is not expanded in Claude Code settings.
- Open iTerm2 → Settings → General → Magic
- Check Enable Python API (this also enables the AppleScript bridge used by the focus script)
- Open System Settings → Notifications
- Find terminal-notifier in the list
- Set Alert Style to Persistent (stays until dismissed) or Temporary (auto-dismisses)
- Enable Desktop, Notification Centre, and Play sound
echo '{"message": "Test notification", "type": "idle_prompt"}' | ~/.claude/hooks/notify.shYou should see a notification banner. Clicking it will focus the iTerm2 window you ran the command from.
When a Notification event fires, Claude Code runs the hook script and passes a JSON payload on stdin. The script:
- Walks up the process tree to find the TTY of the parent Claude session
- Checks if that iTerm2 tab is already the active, focused window — if so, exits silently
- Resolves the working directory relative to
$HOMEfor the notification title - Calls
terminal-notifierwith-executepointing tofocus-terminal.scpt, passing the TTY as an argument
focus-terminal.scpt is a permanent AppleScript that accepts a TTY argument and focuses the matching iTerm2 window and tab. Because the TTY is passed at click-time rather than baked into a temp file, clicking the notification will focus the correct window no matter when you click it.
- macOS only (uses AppleScript and iTerm2)
- Requires iTerm2 with AppleScript access enabled
- Requires Claude Code
- Requires Homebrew for
terminal-notifier