Claude Code notifications: know when it finishes or needs you

Get a sound or a desktop alert when Claude Code finishes or waits for you: the built-in setting, Notification and Stop hooks, and how to keep it quiet.

· 6 min read

You give Claude Code a task, switch to your browser, and come back twenty minutes later. Either it finished nineteen minutes ago, or it stopped after ten seconds on a permission prompt and has been waiting for you ever since. Both cost you the same thing: time Claude could have spent working. The fix is a notification that fires on the two moments that matter, it needs you and it's done, and stays silent the rest of the time.

#Does Claude Code send notifications on its own?

Yes, in some terminals. Claude Code has a setting, preferredNotifChannel, that decides how it alerts you. Its default, "auto", picks the best channel your terminal supports:

TerminalWhat you get with the default
Ghostty, Kitty, iTerm2A desktop notification (iTerm2 only once its alert settings are on)
Apple TerminalThe terminal bell, which you hear only if "Audible bell" is on
Warp, the VS Code terminal, othersNothing

To change it, set the key in ~/.claude/settings.json:

{
  "preferredNotifChannel": "terminal_bell"
}

The values are "auto", "terminal_bell", "iterm2", "kitty", "ghostty" and "notifications_disabled". In iTerm2, the desktop notification needs two switches: Settings › Profiles › Terminal, tick "Notification Center Alerts", then Filter Alerts and enable "Send escape sequence-generated alerts". In Apple Terminal, turn on "Audible bell" under Settings › Profiles › Advanced if you want the bell to make a sound.

#How do you get notifications inside tmux or over SSH?

By default, tmux swallows them before they reach the terminal around it. Add this to ~/.tmux.conf, run tmux source-file ~/.tmux.conf, and restart Claude Code:

set -g allow-passthrough on
set -g focus-events on
set -s extended-keys on
set -as terminal-features 'xterm*:extkeys'

Over SSH, outside tmux, keep "auto" on recent versions; on older ones, set the channel to your local terminal ("iterm2", "kitty" or "ghostty") on the machine that runs Claude Code.

If your terminal gets nothing, or you want more than one generic alert, use a hook.

#Which hook should fire the notification?

Hooks are commands Claude Code runs at fixed points. Three events cover notifications:

EventFires whenUse it for
NotificationClaude Code sends a notification"It needs you"
StopClaude finishes responding"It's done"
StopFailureA turn ends on an API error"It broke"

The Notification event carries a notification_type, and you can match on it. The two you'll use most:

  • permission_prompt: Claude needs you to approve a tool call, and the prompt has waited about six seconds.
  • idle_prompt: Claude finished about 60 seconds ago and you haven't typed since.

Others exist, for login, for questions an MCP server asks, and for the automatic continue after a usage limit; the hooks reference lists them. The hook receives JSON on stdin with message (the notification's text), an optional title, notification_type, and the usual session_id, transcript_path and cwd. A Notification hook can't block or change the notification. It runs even when preferredNotifChannel is "notifications_disabled", which only turns off the built-in alert.

Stop doesn't fire when you interrupt Claude yourself, and on an API error StopFailure fires instead, with an error field such as rate_limit, authentication_failed or server_error.

#How do you set up a desktop notification on a Mac?

The shortest version, in ~/.claude/settings.json:

{
  "hooks": {
    "Notification": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
          }
        ]
      }
    ]
  }
}

An empty matcher catches every notification type. On macOS, osascript notifications are shown as coming from Script Editor, so allow Script Editor in System Settings › Notifications the first time.

A fixed text gets old once you run two sessions: you want to know which project is waiting and why. Save this as ~/.claude/hooks/notify.sh and chmod +x it:

#!/bin/bash
# Reads the hook's JSON and shows the project and Claude Code's own message.
input=$(cat)
msg=$(jq -r '.message // "Claude Code needs you"' <<<"$input")
project=$(basename "$(jq -r '.cwd' <<<"$input")")
osascript -e 'on run argv' \
  -e 'display notification (item 1 of argv) with title (item 2 of argv)' \
  -e 'end run' "$msg" "Claude Code · $project"

Passing the text as arguments (argv) instead of pasting it into the script means a quote in the message can't break it. Point the hook's command at ~/.claude/hooks/notify.sh.

#What about Linux and Windows?

Same structure, different command. On Linux, notify-send 'Claude Code' 'Claude Code needs your attention'; it needs a notification daemon, and on Debian or Ubuntu the libnotify-bin package. On Windows, the docs' example uses PowerShell to open a message box, which is a dialog rather than a toast in the corner of the screen:

powershell.exe -Command "[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('Claude Code needs your attention', 'Claude Code')"

#How do you get notified when Claude finishes?

The obvious answer is a Stop hook:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          { "type": "command", "command": "afplay /System/Library/Sounds/Glass.aiff", "async": true }
        ]
      }
    ]
  }
}

async: true runs it in the background, so the sound never holds up the end of the turn. But Stop fires at the end of every turn, including the ones you watched happen. When you're working in the same window, that's a sound every thirty seconds.

The quieter option is idle_prompt. It fires only when Claude finished a minute ago and you haven't typed since, which is a good definition of "it's done and you're not looking". It skips turns where a background task is still running, and the wait for a usage-limit reset.

#How do you avoid notification noise?

Notifications you learn to ignore are worse than none. A few rules keep them useful:

  1. Notify on waiting, not on working. permission_prompt and idle_prompt are the two signals worth an interruption. Tool calls, subagent stops and every Stop are not.
  2. Give each kind its own sound. One for "waiting", one for "done", one for "failed". You learn them in a day and stop looking at the screen to know which it was:
{
  "hooks": {
    "Notification": [
      { "matcher": "permission_prompt", "hooks": [{ "type": "command", "command": "afplay /System/Library/Sounds/Ping.aiff" }] },
      { "matcher": "idle_prompt", "hooks": [{ "type": "command", "command": "afplay /System/Library/Sounds/Glass.aiff" }] }
    ],
    "StopFailure": [
      { "hooks": [{ "type": "command", "command": "afplay /System/Library/Sounds/Basso.aiff" }] }
    ]
  }
}
  1. Say which project. With several sessions, "Claude needs you" is useless; "Claude Code · billing-api" is not. The script above does it.
  2. Ask less. Most permission prompts are for things you always approve. Allow them with rules and the remaining prompts mean something. The permission modes article shows how.
  3. Keep hooks fast. A notification command should take milliseconds. Anything slower belongs in the background.

#How do you test a notification hook?

Feed it a sample payload by hand:

echo '{"message":"Claude needs your permission","notification_type":"permission_prompt","cwd":"/Users/ada/larkspur-web"}' \
  | ~/.claude/hooks/notify.sh

If nothing shows, check that the script is executable, that jq is installed, and that the app sending the notification (Script Editor, your terminal) is allowed in your system's notification settings. Inside a session, /hooks lists every hook Claude Code loaded and the file each came from, so you can see whether yours is there at all.

#In Relais

Relais is built around this problem, without hooks to write. Every conversation in the sidebar shows its state: blue while it works, orange when it waits for you, red on an error. Each turn ends with a one-line status that says whether it needs you, so a turn that finished with nothing to ask stays out of your way. Everything that waits, across every project, is gathered in Needs you: ⌘J opens the next one, and queue mode (⇧⌘J) takes you through them one after another. Relais plays soft sounds of its own (two notes going up when a session is done, a double knock when it waits, a lower cue on an error) and sends a notification that opens the conversation when Relais isn't in front. Focus mode holds notifications back and gives them to you in one. Your Claude Code hooks still run, since these are real Claude Code sessions. See Needs you, and running several sessions at once.

Your AI team,
on your Claude plan.

$14.99 a month, everything included. On your Mac or on Linux, on your Claude Pro or Max plan. Cancel any time.