Skip to content

Instantly share code, notes, and snippets.

@andrewvaughan
Last active February 25, 2026 03:34
Show Gist options
  • Select an option

  • Save andrewvaughan/40f267e3161c5a7c10f3efec4d02bcdf to your computer and use it in GitHub Desktop.

Select an option

Save andrewvaughan/40f267e3161c5a7c10f3efec4d02bcdf to your computer and use it in GitHub Desktop.
Claude Code macOS notifications via hooks (permission prompts, questions, and completion)
#!/bin/bash
set -euo pipefail
INPUT="$(cat)"
# Skip if this is a subagent stopping, not the main agent
AGENT_ID="$(echo "$INPUT" | jq -r '.agent_id // empty')"
if [[ -n "$AGENT_ID" ]]; then
exit 0
fi
CWD="$(echo "$INPUT" | jq -r '.cwd // ""')"
PROJECT="$(basename "$CWD")"
terminal-notifier \
-title "Claude Code — $PROJECT" \
-message "Done" \
-sound Glass >/dev/null 2>&1
#!/bin/bash
set -eo pipefail
INPUT="$(cat)"
CWD="$(echo "$INPUT" | jq -r '.cwd // ""')"
PROJECT="$(basename "$CWD")"
terminal-notifier \
-title "Claude Code — $PROJECT" \
-message "Claude is asking a question" \
-sound Glass >/dev/null 2>&1
#!/bin/bash
set -eo pipefail
INPUT="$(cat)"
CWD="$(echo "$INPUT" | jq -r '.cwd // ""')"
PROJECT="$(basename "$CWD")"
MESSAGE="$(echo "$INPUT" | jq -r '.message // "Waiting for permission"')"
terminal-notifier \
-title "Claude Code — $PROJECT" \
-message "$MESSAGE" \
-sound Glass >/dev/null 2>&1
{
"permissions": {
"allow": []
},
"hooks": {
"PreToolUse": [
{
"matcher": "AskUserQuestion",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/notify-needs-attention.sh"
}
]
}
],
"Notification": [
{
"matcher": "permission_prompt",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/notify-permission.sh"
}
]
}
],
"PermissionRequest": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/notify-permission.sh"
}
]
}
],
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/notify-done.sh"
}
]
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment