Claude Codeの通知設定メモ
2026/01/11
Claude Codeで作業してると、入力待ちとかタスク完了のタイミングがわからなくて困ることがあったので、音とデスクトップ通知が出るようにした。
やったこと
~/.claude/settings.json にhookを設定して、~/.claude/hooks/notification.sh で通知を出すようにしてる。LinuxとmacOS両方に対応。
通知の種類
- タスク完了したとき (Stop) → 完了音 + 「タスク完了」
- 許可待ち (PermissionRequest) → 警告音 + 「許可待ち」
- 入力待ち (Notification) → 通知音 + 「入力待ち」
設定ファイル
~/.claude/settings.json
{ "hooks": { "Notification": [ { "matcher": "", "hooks": [ { "type": "command", "command": "bash ~/.claude/hooks/notification.sh general", "timeout": 5 } ] } ], "PermissionRequest": [ { "matcher": "", "hooks": [ { "type": "command", "command": "bash ~/.claude/hooks/notification.sh permission", "timeout": 5 } ] } ], "Stop": [ { "matcher": "", "hooks": [ { "type": "command", "command": "bash ~/.claude/hooks/notification.sh stop", "timeout": 5 } ] } ] }}~/.claude/hooks/notification.sh
#!/bin/bash# Claude Code notification hook# Works on both host and devcontainer environments
# Read stdin (required by hook)cat > /dev/null
# Notification type is passed as first argumentNOTIFICATION_TYPE="${1:-general}"
# Select sound and message based on typecase "$NOTIFICATION_TYPE" in "stop") SOUND_LINUX="/usr/share/sounds/freedesktop/stereo/dialog-information.oga" SOUND_MAC="/System/Library/Sounds/Glass.aiff" MESSAGE="タスク完了" ;; "permission") SOUND_LINUX="/usr/share/sounds/freedesktop/stereo/dialog-warning.oga" SOUND_MAC="/System/Library/Sounds/Purr.aiff" MESSAGE="許可待ち" ;; *) SOUND_LINUX="/usr/share/sounds/freedesktop/stereo/message-new-instant.oga" SOUND_MAC="/System/Library/Sounds/Blow.aiff" MESSAGE="入力待ち" ;;esac
# Detect OS and play sound + notificationif [[ "$OSTYPE" == "darwin"* ]]; then # macOS afplay "$SOUND_MAC" 2>/dev/null & osascript -e "display notification \"$MESSAGE\" with title \"Claude Code\"" 2>/dev/null &else # Linux (host or devcontainer) pw-play --volume=1.5 "$SOUND_LINUX" 2>/dev/null & notify-send -u normal "Claude Code" "$MESSAGE" 2>/dev/null &fi
exit 0動かすのに必要なもの
Linux
pipewire(pw-playコマンド)libnotify-bin(notify-sendコマンド)
devcontainerで使う場合は、ホストのPulseAudioとD-Busに繋がってないと音もデスクトップ通知も出ない。devcontainer.jsonでソケットをマウントする必要あり。
macOS
特に追加インストールは不要。afplayとosascriptは標準で入ってる。
注意事項
VSCode拡張版について
この設定はCLI版(claudeコマンド)で動作確認済み。VSCode拡張版のClaude CodeではPermissionRequestフックが発火しない可能性がある。VSCode拡張を使っている場合、許可待ちの通知は期待通り動かないかもしれない。
トラブルシューティング
hooksが動かない場合:
- 新規セッションを開始する(設定は起動時に読み込まれる)
- スクリプトに実行権限があるか確認:
chmod +x ~/.claude/hooks/notification.sh /hooksコマンドで登録状況を確認(CLI版のみ)claude --debugでhook実行ログを確認(CLI版のみ)