You start a long task, switch to your browser, and come back ten minutes later to find Claude has been sitting on a permission prompt the whole time. A notification fixes that. Claude Code has a little built in, and hooks cover the rest. This guide covers both, then what changes once you run several sessions at once.
What does Claude Code do on its own?
When Claude finishes a task or pauses on a permission prompt, and you appear to be away from the terminal, Claude Code fires a notification event. What you see depends on your terminal, per Anthropic’s terminal configuration docs:
| Terminal | What Claude Code does by default |
|---|---|
| iTerm2, Ghostty, Kitty | Sends a desktop notification. iTerm2 shows it only after you turn on its alerts. |
| Apple Terminal | No sound. A silent bell character if the profile’s Audible bell is off, which can flash the window or bounce the Dock icon. |
| Other terminals | Nothing. |
The preferredNotifChannel setting changes this. It appears in /config as Local notifications, and takes auto (the default), terminal_bell, iterm2, iterm2_with_bell, kitty, ghostty or notifications_disabled. To ring the bell in any terminal, add this to ~/.claude/settings.json:
{
"preferredNotifChannel": "terminal_bell"
}
In Apple Terminal, also turn on Audible bell under Settings > Profiles > Advanced, or you won’t hear it.
In iTerm2, turn the alerts on once: go to Settings > Profiles > Terminal, check Notification Center Alerts, click Filter Alerts and enable Send escape sequence-generated alerts. If you run Claude Code inside tmux, add set -g allow-passthrough on to ~/.tmux.conf and restart Claude Code, or the notification never reaches your terminal.
How do I get a macOS notification with a hook?
Hooks are shell commands Claude Code runs at fixed points in a session. They work in every terminal, and they run alongside the built-in notification rather than replacing it. Two events matter here:
Notificationruns when Claude Code sends a notification. Its matcher filters by notification type.Stopruns when Claude has finished responding. It has no matcher and fires every time. It doesn’t run when you interrupt Claude, and a turn that ends on an API error firesStopFailureinstead.
This is Anthropic’s own macOS example. Open ~/.claude/settings.json, create it if it doesn’t exist, and add:
{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
}
]
}
]
}
}
If the file already has a hooks key, add Notification next to the events already in it instead of replacing the whole object. Type /hooks in Claude Code to confirm the hook is listed under Notification. To test it, ask Claude for something that needs permission, then switch to another app. The banner should appear after about six seconds.
If no banner appears, Script Editor probably lacks permission. osascript routes notifications through Script Editor, and without permission it fails silently. Run this once in Terminal:
osascript -e 'display notification "test"'
Then open System Settings > Notifications, find Script Editor, turn on Allow Notifications, and run the command again.
For a sound instead of a banner, use afplay:
{
"hooks": {
"Notification": [
{
"hooks": [{ "type": "command", "command": "afplay /System/Library/Sounds/Glass.aiff" }]
}
]
}
}
Any file in /System/Library/Sounds works, like Ping.aiff or Submarine.aiff.
Which notification types can you match?
An empty matcher fires on every type. These are the ones you’ll use most, from the hooks reference:
| Matcher | Fires when |
|---|---|
permission_prompt |
A permission prompt has waited about six seconds |
idle_prompt |
Claude finished about 60 seconds ago and you haven’t typed since |
elicitation_dialog |
An MCP server opened an input form and you haven’t typed for about six seconds |
agent_needs_input |
A background session starts waiting on you while agent view is open |
agent_completed |
A background session finishes or fails while agent view is open |
auth_success |
Sign-in completes |
To match several, separate them with |, as in "permission_prompt|idle_prompt".
Two details catch people out. In a terminal session, permission_prompt, idle_prompt and the elicitation types share the timing of desktop notifications, so they only fire when you seem to be away: every keystroke pushes the six-second timer back. And if you want a signal the instant Claude asks for permission, use a PermissionRequest hook instead. One that prints nothing and exits 0 makes no decision, so the normal prompt still asks you.
How do I get notified when Claude Code is done?
Use the Stop hook. It fires at the end of every turn, including short replies and turns you watched happen. If that’s too often, use the idle_prompt notification type instead: it waits about 60 seconds and fires only if you haven’t typed since.
A notification script should always exit 0. On a Stop hook, exit code 2 blocks the stop and keeps Claude working, which is the opposite of what you want here.
A script that names the project
A fixed message gets old quickly. Each hook receives JSON on stdin with session_id, transcript_path, cwd and hook_event_name. Notification hooks also get message, notification_type and an optional title, and Stop hooks get last_assistant_message. This script uses cwd to put the project folder in the banner.
Save it as ~/.claude/hooks/notify.sh:
#!/bin/bash
# Shows a macOS notification naming the project and what Claude Code wants.
input=$(cat)
event=$(jq -r '.hook_event_name' <<<"$input")
project=$(basename "$(jq -r '.cwd' <<<"$input")")
if [ "$event" = "Stop" ]; then
message="Finished"
else
message=$(jq -r '.message // "Needs your attention"' <<<"$input")
fi
osascript \
-e 'on run argv' \
-e 'display notification (item 2 of argv) with title "Claude Code" subtitle (item 1 of argv)' \
-e 'end run' \
"$project" "$message"
exit 0
Passing the text as arguments to osascript means quotes in a message can’t break the AppleScript. The script uses jq; if command -v jq prints nothing, install it with brew install jq. Make the script executable with chmod +x ~/.claude/hooks/notify.sh, then point both events at it:
{
"hooks": {
"Notification": [
{
"matcher": "permission_prompt|elicitation_dialog",
"hooks": [{ "type": "command", "command": "~/.claude/hooks/notify.sh" }]
}
],
"Stop": [
{
"hooks": [{ "type": "command", "command": "~/.claude/hooks/notify.sh" }]
}
]
}
}
The matcher leaves out idle_prompt on purpose: with a Stop hook you already hear when Claude finishes, and idle_prompt would repeat it a minute later.
Where does the hook config go?
Where you put a hook decides who gets it. From the hooks guide:
| File | Applies to | Shared |
|---|---|---|
~/.claude/settings.json |
Every project on your Mac | No |
.claude/settings.json |
One project | Yes, you can commit it |
.claude/settings.local.json |
One project | No, kept out of git when Claude Code creates it |
Notifications are a personal preference, so ~/.claude/settings.json is usually right. Hooks from different files add up rather than replace each other, so a project’s hooks don’t remove yours. Claude Code normally picks up edits to these files while it runs. One more thing: it holds back hooks, including your own, until you accept the workspace trust dialog for a folder.
Why notifications break down with many sessions
One session and one banner works well. Five sessions in five terminal tabs don’t. The banner says something needs you, not which tab. Even with the project name in it, two sessions in the same repository look identical. And a banner can’t take your answer: you still have to find the right tab, read the prompt and reply there. By the time you’ve done that, another one is waiting.
Claude Code has a few tools that help:
- Name your sessions. Start with
claude -n auth-refactor, or run/rename auth-refactormid-session. The terminal tab shows the name. - Use a terminal that shows session state. If your terminal implements the OSC 7501 Program Status Protocol, it can show whether each session is working, waiting on you or done. This needs Claude Code v2.1.295 or later.
- Run background sessions in agent view.
claude agentsopens one screen for your background sessions, grouped under Needs input, Working and Completed. You can peek at a session and reply without attaching. It’s in research preview.
How Tenfold handles it
Tenfold, the Mac app I make for running many Claude Code agents side by side, takes a different approach. It doesn’t send notification banners, play sounds or set a Dock badge. When an agent stops for a permission or a question, its buddy hangs under the Mac notch and knocks. Hover the notch and the prompt slides out, so you can answer it right there without switching windows. In the notch panel, ⌘J jumps to the next session that needs you. On a Mac without a notch, Tenfold draws one.
In the Workspace window, the Inbox layout (⌥⌘4) collects every permission prompt and question from every session, one at a time. A digit picks an answer, ↩ gives the default, Esc denies a permission and O opens the session.
It uses the same hooks this guide describes. Tenfold adds its own Notification and PermissionRequest hook groups to ~/.claude/settings.json, they only report from agents started in Tenfold, and your own hooks stay as they are. So a banner or sound you set up keeps working if you want both. See the Claude Code notch for how it looks, and What Tenfold changes for every hook it adds.