Blog / Sessions
Claude Code Notification Hook: Get Pinged When It Waits
Set up a Claude Code Notification hook on macOS, Linux or Windows, filter it to permission or idle prompts, and get alerts when the session runs on a server.

Add a
Notificationhook to~/.claude/settings.jsonand Claude Code runs your command whenever it is waiting for input or permission. Anthropic's docs give a ready config for each OS:osascripton macOS,notify-sendon Linux and a PowerShell dialog on Windows. Set thematchertopermission_promptoridle_promptto fire only on those. Desktop commands fail on a headless server or over SSH, so for remote sessions use a terminal escape sequence or post to a URL instead.
Table of contents
- The short answer
- Why this hook earns its place
- How the Notification event works
- Step by step: your first notification hook
- Filter by notification type
- Notification vs Stop vs PermissionRequest
- When Claude Code runs on a server
- Common problems
- Pick this setup if
- FAQ
- Conclusion
The short answer
| Question | Answer from the docs | Source |
|---|---|---|
| Which event? | Notification, which fires "when Claude is waiting for input or permission" |
Hooks guide |
| Where does the config go? | ~/.claude/settings.json for all projects, .claude/settings.json for one project |
Hooks guide |
| Which matcher? | Empty "" fires on all notification types; permission_prompt and idle_prompt are the two most people want |
Hooks guide |
| How fast? | permission_prompt after the prompt has waited about six seconds; idle_prompt about 60 seconds after Claude finishes |
Hooks reference |
| What does the hook receive? | JSON on stdin with message, an optional title and notification_type |
Hooks reference |
| Can it block anything? | No. "Notification hooks can't block or modify notifications." | Hooks reference |
| How to check it loaded? | Type /hooks and look under Notification |
Hooks guide |
I read Anthropic's hooks guide and hooks reference on 2026-11-24. Claude Code ships often, so field names and timings may change. Check the pages before you copy anything into a team config.
Why this hook earns its place
If you run Claude Code for more than a few minutes at a time, you know the pattern. You give it a task, switch to email, come back twenty minutes later and find it stopped on minute two, asking whether it may run npm install. The session sat idle the whole time.
A notification hook fixes that one problem. It does not make Claude smarter or faster. It tells you the moment the session needs a human, so the wait is measured in seconds instead of however long it takes you to remember to check.
It matters more the more sessions you run. With one session you can glance at the terminal. With four sessions across three projects, you cannot watch them all. If you are at that stage, how to run multiple Claude Code sessions covers the rest of the setup.
The hook below is free, built into Claude Code, and takes five minutes. I will point out where a server setup changes things, because that is where most guides stop.
How the Notification event works
Hooks, in Anthropic's words, "are user-defined shell commands. Claude Code runs them at specific points in its lifecycle." For a deeper comparison of hooks with skills and MCP servers, see Claude Code hooks vs skills vs MCP.
The hooks reference describes the Notification event as running "when Claude Code sends notifications." Each notification has a type, and the matcher filters on that type. The two types that matter for this post:
permission_prompt: Claude needs you to approve a tool use or a sandboxed command's network request, "and the prompt has waited about six seconds."idle_prompt: "Claude finished responding about 60 seconds ago and you haven't typed since."
The reference adds detail on both timers. For permission_prompt in a terminal, "The timer starts when the permission prompt appears, and each keystroke defers it." For idle_prompt, it fires only if no background agent, such as a background subagent, is still running, and Claude Code does not send it while it waits for a claude.ai usage limit to reset.
There are other types too: auth_success, elicitation_dialog when an MCP server opens a form, agent_needs_input and agent_completed for background sessions while agent view is open, and three quota_auto_resume_* types around usage limits. The empty matcher catches all of them.
One detail that surprises people: the docs say "You receive these hook events even with desktop notifications turned off." Claude Code's own notification setting changes how Claude Code alerts you. It does not stop your hook.
When the hook runs, it gets JSON on stdin. The reference's example:
{
"session_id": "abc123",
"transcript_path": "/Users/.../.claude/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
"cwd": "/Users/...",
"hook_event_name": "Notification",
"message": "Claude needs your permission",
"notification_type": "permission_prompt"
}
cwd is useful when you run several projects. It tells you which session is asking.
Step by step: your first notification hook
Step 1: Open your user settings file
The hooks guide says: "Open ~/.claude/settings.json and add a Notification hook. If the file doesn't exist, create it." The user file applies to every project on the machine, which is what you want for an alert.
Step 2: Add the config for your OS
These three blocks are copied from Anthropic's hooks guide. Use the one for your system.
macOS:
{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
}
]
}
]
}
}
Linux:
{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "notify-send 'Claude Code' 'Claude Code needs your attention'"
}
]
}
]
}
}
Windows (PowerShell):
{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "powershell.exe -Command \"[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('Claude Code needs your attention', 'Claude Code')\""
}
]
}
]
}
}
If your settings file already has a hooks key, do not paste a second one. The guide says to "add Notification as a sibling of the existing event keys rather than replacing the whole object." Every event name is a key inside the one hooks object.
Step 3: Confirm Claude Code sees it
"Type /hooks at the Claude Code prompt to open the hooks browser." Your hook should be listed under Notification. If it is missing, the JSON is probably invalid or in the wrong file.
Step 4: Trigger it on purpose
The guide's test: press Shift+Tab until the status bar shows manual mode, ask Claude to do something that needs permission, then switch away from the terminal. Wait a few seconds. You should get the alert.
Step 5: Fix the OS quirks
Each platform has one known trap, and the docs name them:
- macOS:
osascriptsends notifications through Script Editor. If Script Editor has no notification permission, "the command fails silently." Runosascript -e 'display notification "test"'once in Terminal, then turn on Allow Notifications for Script Editor in System Settings > Notifications. - Linux:
notify-sendneeds a notification daemon. On Debian and Ubuntu installlibnotify-binif the command is missing. - Windows: the PowerShell command opens a dialog box, not a toast, so it "can open behind your terminal window." Under WSL,
powershell.exehas to be on yourPATH.
Filter by notification type
The empty matcher fires on everything, including auth_success. Most people end up wanting two different alerts: an urgent one when Claude is blocked on a permission and a softer one when it has gone idle.
The hooks reference shows that pattern with two matcher groups:
{
"hooks": {
"Notification": [
{
"matcher": "permission_prompt",
"hooks": [
{
"type": "command",
"command": "/path/to/permission-alert.sh"
}
]
},
{
"matcher": "idle_prompt",
"hooks": [
{
"type": "command",
"command": "/path/to/idle-notification.sh"
}
]
}
]
}
}
Replace the paths with your own scripts. Each script reads the JSON from stdin, so it can include cwd or message in the alert. A small Linux example of permission-alert.sh, my own and not from the docs, that names the project folder:
#!/bin/bash
input=$(cat)
project=$(jq -r '.cwd' <<<"$input" | xargs basename)
msg=$(jq -r '.message // "Needs your attention"' <<<"$input")
notify-send "Claude Code: $project" "$msg"
Make it executable with chmod +x. It needs jq.
A note on timing in other hosts. The reference says Claude Desktop and the VS Code extension handle permission requests through the Agent SDK, and there permission_prompt fires "about six seconds after Claude asks for permission" without being deferred while you type. Before v2.1.233 it did not fire in those sessions at all. If your hook works in the terminal but not in VS Code, check your version.
Notification vs Stop vs PermissionRequest
Three events get confused in forum threads about this. Here is how the docs separate them.
| Event | When it fires (docs) | Use it for | Source |
|---|---|---|---|
Notification |
"When Claude Code sends a notification" | Alerts when Claude waits for you | Hooks guide |
Stop |
"When Claude finishes responding" | Acting on every finished turn | Hooks guide |
PermissionRequest |
"When a tool call needs a permission decision" | Running something the instant a permission ask appears, or deciding it | Hooks guide |
StopFailure |
"When the turn ends due to an API error" | Alerts when a turn dies on an error | Hooks guide |
Stop for "tell me when it's done." A lot of guides use a Stop hook as the "done" alert. It works, with a caveat from the guide: "Stop hooks fire whenever Claude finishes responding, not only at task completion. They don't fire on user interrupts." So you get pinged after every reply, including short ones. The Stop input carries last_assistant_message, and the reference recommends that field over reading the transcript for "read-aloud or notification hooks." If you want the final text in the alert, that is where it comes from.
PermissionRequest for zero delay. The reference says that to run a hook immediately when Claude asks for permission, use PermissionRequest instead of waiting for the six-second permission_prompt. That event can also make the permission decision, which is a bigger step than an alert. I would keep alerts on Notification and use PermissionRequest only when you mean to automate the answer.
Notification for "it needs me." For most people this is the right one. It covers permission prompts and idle sessions with built-in delays, so you are not pinged for something you were about to answer anyway.
When Claude Code runs on a server
This is the gap I see in most write-ups. The desktop commands above run on the machine where Claude Code runs. If that machine is a VPS, a container or a box you reach over SSH, the alert fires there, where nobody is looking.
The docs are direct about Linux: notify-send "needs a desktop notification daemon, which headless servers, SSH sessions, and most containers don't have." There are three ways around it in the docs.
Option 1: Terminal escape sequences
Hooks can return a terminalSequence field, and Claude Code writes it to the terminal for you. The reference explains why: "Hooks run without a controlling terminal, so writing escape sequences directly to /dev/tty fails." The allowlist includes OSC 9 (iTerm2, ConEmu, Windows Terminal, WezTerm), OSC 99 (Kitty), OSC 777 (urxvt, Ghostty, Warp) and a bare BEL.
Claude Code writes the sequence into its own terminal output, so when you run it over SSH the sequence goes down the same connection to your local terminal. The docs do not discuss SSH directly, so test it with your terminal before you rely on it. The reference's example script, for a terminal that reads OSC 777:
#!/bin/bash
# Notification hook: ping the desktop when Claude Code needs attention.
input=$(cat)
title="Claude Code"
body=$(jq -r '.message // "Needs your attention"' <<<"$input")
seq=$(printf '\033]777;notify;%s;%s\007' "$title" "$body")
jq -nc --arg seq "$seq" '{terminalSequence: $seq}'
Limits from the docs: it works only in an interactive session while the interface is open. It is ignored with -p and in hooks that run with async. If you use tmux or GNU screen, the reference has a separate setup step for them.
Option 2: An HTTP hook
A hook can have "type": "http" and POST the event JSON to a URL. "The endpoint receives the same JSON that a command hook would receive on stdin." The guide's example uses PostToolUse, but the same fields work on any event. A Notification version, using only the documented fields:
{
"hooks": {
"Notification": [
{
"matcher": "permission_prompt",
"hooks": [
{
"type": "http",
"url": "https://example.com/claude-alert",
"headers": {
"Authorization": "Bearer $ALERT_TOKEN"
},
"allowedEnvVars": ["ALERT_TOKEN"]
}
]
}
]
}
}
The endpoint can be anything you control that turns a POST into a phone push or a chat message. Only variables listed in allowedEnvVars are expanded in headers, which keeps other secrets out. Keep the token in the server's environment and out of committed files. Keeping secrets safe on an agent server covers that part.
Option 3: A command hook that calls out
The same idea with a shell script: read the JSON, call curl against whatever push service you use. The docs have no example of this, but it is an ordinary command hook, so the usual rules apply. Command hooks default to a ten-minute timeout, so set timeout in seconds if the network call might hang.
Where Code Tycoon fits
If your sessions already live on a server, Code Tycoon covers this case. It puts your Claude Code setup on a dedicated server, hooks included, and alerts you in the browser on any device when a session needs an answer or when two sessions edit the same file. Self-hosting is free and open source; see the self-host option. If you only run one local session, the desktop hook above is all you need. More on running agents remotely is in Claude Code on a dedicated server.
Common problems
Nothing happens and there is no error. The guide notes that you do not see the usual non-blocking error notice "when a command hook on an event such as Notification fails." So a broken notification hook is silent. Run the command by hand in a terminal first. On macOS, check Script Editor's notification permission.
The hook is not in /hooks. Check the JSON is valid and that you edited the right file. A second top-level hooks key or a typo in the event name are the usual causes.
Idle alerts never arrive. idle_prompt waits about 60 seconds and skips while a background agent is running or while Claude Code waits for a usage limit reset. Give it a full minute with nothing in flight.
Too many alerts. The empty matcher catches every type. Switch to permission_prompt and idle_prompt only. If you used a Stop hook, remember it fires after every response.
Hooks stopped working everywhere. Look for "disableAllHooks": true in a settings file. The guide notes a project's settings can override yours.
Teammates get your alert script. If you put the hook in .claude/settings.json it can be committed and shared. Personal alerts belong in ~/.claude/settings.json or .claude/settings.local.json, which the guide describes as gitignored when Claude Code saves a setting to it.
Pick this setup if
- One local session, one machine: the OS config from Step 2 with the empty matcher. Done in five minutes.
- Several sessions, one machine: two matcher groups, with a script that puts
cwdin the title so you know which project is asking. Your CLAUDE.md can stay out of it; this belongs in settings. - Sessions on a server over SSH:
terminalSequenceif your terminal supports it, otherwise an HTTP hook to an endpoint that pushes to your phone. - Sessions on a server you want to leave running with the laptop closed: an HTTP hook, or a tool that does the alerting for you. Compare options in Claude Code Remote Control vs Happy vs Code Tycoon.
FAQ
How do I get a notification when Claude Code needs input?
Add a Notification hook to ~/.claude/settings.json with a command that shows a desktop alert: osascript on macOS, notify-send on Linux or a PowerShell dialog on Windows. Anthropic's hooks guide has a ready config for each. Type /hooks to confirm it loaded.
What is the difference between permission_prompt and idle_prompt?
permission_prompt fires when Claude needs you to approve a tool use and the prompt has waited about six seconds. idle_prompt fires when Claude finished responding about 60 seconds ago and you have not typed since.
Should I use a Stop hook or a Notification hook?
Use Notification for alerts when Claude is waiting on you. A Stop hook fires whenever Claude finishes responding, not only at task completion, so it pings you after every reply. Stop hooks receive last_assistant_message if you want the reply text in the alert.
Why does my notification hook do nothing?
A failing Notification command hook shows no error notice. Run the command by hand first. On macOS, Script Editor needs notification permission. On Linux, notify-send needs a notification daemon, which servers, SSH sessions and most containers lack.
Can I get Claude Code notifications on my phone?
Not with the built-in desktop commands. Use an HTTP hook, which POSTs the event JSON to a URL you control, or a command hook that calls a push service. Point either at an endpoint that sends the push.
Does a Notification hook work over SSH?
Desktop commands run on the remote machine, so you will not see them. A hook can return a terminalSequence field with an allowlisted escape sequence, such as OSC 9 or OSC 777, which Claude Code writes to its terminal output. A local terminal that supports the sequence may show it as a notification; the docs do not cover SSH directly, so test it.
Can a Notification hook block or change what Claude does?
No. The hooks reference says Notification hooks cannot block or modify notifications. To make a permission decision automatically, use a PermissionRequest hook instead.
Conclusion
The Notification hook is the cheapest fix for idle Claude Code sessions: one JSON block in ~/.claude/settings.json, copied from Anthropic's guide, and you stop losing twenty minutes to a permission prompt. Split it into permission_prompt and idle_prompt once you run more than one session. When the sessions move to a server, desktop commands stop reaching you, so switch to a terminal sequence or an HTTP hook. If you want the server, the sessions and the alerts handled in one place, get your server.
Related articles
- Claude Code hooks vs skills vs MCP: what goes where
- Write a CLAUDE.md that stops repeated corrections: instructions Claude reads every session
- How to run multiple Claude Code sessions: the setup this hook supports
About this research
Anton Goldshtein is a two-time founder who previously bootstrapped a company to $100M in revenue. His team runs its own products on Code Tycoon every day.
Every event name, matcher, timing and config block here comes from Anthropic's hooks guide and hooks reference, read on 2026-11-24, with quotes and URLs recorded in our source notes. The JSON configs in Step 2 and the two-matcher example are copied from those pages; the HTTP example uses only documented fields; the permission-alert.sh script is our own illustration. We did not measure notification delays ourselves.
Content reviewed and updated: 2026-11-26
Keep reading
Sculptor vs Claude Squad: Desktop App or tmux (2026)
Sculptor vs Claude Squad for parallel Claude Code: why Sculptor dropped per-agent containers, worktrees, setup, platforms, review flow and laptop vs server use.
Superset Review: What Paradev Gets Right and Wrong (2026)
Superset, now Paradev, reviewed from its docs and pricing: worktrees, 20+ agents, the skip-permissions default, Usage page, cloud hours and who should use it.
Vibe Kanban Alternatives After the Shutdown (2026)
Bloop shut down and Vibe Kanban's hosted board is gone. Eight places to move, from Nimbalyst and Paradev to Backlog.md, and what staying on it now takes.