A hook is a shell command that Claude Code runs at a set point in its work (for example, when a turn ends). You need an alert at two of those points: when Claude finishes, and when Claude is waiting on you. The two events are named Stop and Notification, and you add them to ~/.claude/settings.json.
Which event fires when
Stop runs when Claude finishes responding. It is the right event for "the answer is ready."
Notification runs when Claude is waiting on you. A permission prompt triggers it after the prompt has waited about six seconds. An idle prompt triggers it about 60 seconds after Claude finished, if you have not typed since. The Notification event is therefore slow for a plain finished alert, which is why you use both.
An empty matcher fires the hook for every notification type. To limit it, set the matcher to one type. The two you are most likely to want are permission_prompt and idle_prompt.
The settings.json to paste
Open ~/.claude/settings.json, creating it if it does not exist, and add this. If the file already has a hooks key, add Notification and Stop next to the events already there instead of replacing the whole object.
{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Claude Code finished\" with title \"Claude Code\"'"
}
]
}
]
}
}
osascript -e runs one line of AppleScript. The display notification command shows the text in Notification Center, and with title sets the bold first line. The backslashes before the inner quotes are needed because the whole command sits inside a JSON string.
Add a sound
A notification you can miss is a weak alert. macOS ships short sounds in /System/Library/Sounds, and afplay plays an audio file from the command line. I ran afplay /System/Library/Sounds/Glass.aiff on November 27, 2026 and it played. The folder on that Mac holds Basso, Blow, Bottle, Frog, Funk, Glass, Hero, Morse, Ping, Pop, Purr, Sosumi, Submarine and Tink, each as an .aiff file.
To play a sound when Claude finishes, change the Stop command to this:
"command": "afplay /System/Library/Sounds/Glass.aiff"
To keep the notification and add the sound in one hook, join the two with &&:
"command": "osascript -e 'display notification \"Claude Code finished\" with title \"Claude Code\"' && afplay /System/Library/Sounds/Glass.aiff"
Use a different sound for each event so you can tell them apart without looking. Glass for finished and Basso for needs you is a workable pair. You can also let the notification carry its own sound by adding sound name "Glass" to the AppleScript, as in display notification "done" with title "Claude Code" sound name "Glass". That version still depends on Script Editor being allowed to notify, covered next.
If no notification appears
This is the usual problem. The osascript command sends its notifications through the built-in Script Editor app. If Script Editor has no notification permission, the command fails without an error, and macOS does not ask you to grant it. Claude Code's hooks guide describes the fix.
- Run
osascript -e 'display notification "test"'once in Terminal. Nothing will appear yet. - Open System Settings, then Notifications, and find Script Editor in the list.
- Turn on Allow Notifications.
- Run the command again. The test notification should appear.
If you use a Focus mode, it can also hide the banner. The sound from afplay does not depend on notification permission, so it is a useful check: if the sound plays and the banner does not, the cause is the Script Editor setting or a Focus mode.
Check that the hooks are registered
Type /hooks at the Claude Code prompt. It opens a browser of configured hooks grouped by event, and your two hooks should be listed under Notification and Stop. The hooks guide says the file watcher normally picks up edits to a settings file while Claude Code is running. If a hook does not appear, start a new session and look again.
To test the permission alert, press Shift+Tab until the status bar shows manual mode, ask Claude to do something that needs approval, and switch to another window. The notification arrives after the prompt has waited about six seconds.
If you would rather not edit JSON
An app can do the same job without a settings file. Buddy is a free, open-source (MIT) Mac app that shows your Claude Code sessions in the MacBook notch. It opens with a sound when a session asks for permission, asks a question or has a plan to review, and it plays a chime when a turn finishes. It needs macOS 14 or later on an Apple silicon Mac. I make Buddy, so weigh that when you compare it with the hooks above.
The two approaches overlap rather than compete. Hooks are a few lines you control and can point at any command, such as a message to your phone. Buddy adds a view of every session at once and a click to jump to the chat. Neither needs the other.
Last checked
November 27, 2026. The event names, the osascript example, the matcher values and the Script Editor steps were read from the Claude Code hooks guide on that day. I ran the afplay and osascript commands on a Mac the same day. Hook behavior can change with Claude Code updates, so check the guide before you rely on a detail.
If something here is out of date or wrong, write to ben@purplelink.llc and I will fix it.