2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Claude Codeの通知フックを設定して快適な通知ライフを送ろう

2
Last updated at Posted at 2026-02-27

こんにちは。KDDIアジャイル開発センターのハットリです。皆さん、Claude Codeを使用していますでしょうか?Claude Codeを使用していると、裏のターミナルで通知が権限設定で止まっていたり、何か許可を求めていて止まっていたり、何なら処理が終わったことに気づかなかったりといった経験はないでしょうか?それらを通知フックを設定することで解決できます。

前提

  • macOS
  • jq インストール済み
  • terminal-notifier インストール済み(brew install terminal-notifier
  • システム設定 → 通知 → terminal-notifier をオンにしておく

設定

1. 通知スクリプトを作成

~/.claude/scripts/hooks/notification.sh を作成:

#!/bin/bash

input=$(cat)

notification_type=$(echo "$input" | jq -r '.notification_type')
message=$(echo "$input" | jq -r '.message')
title=$(echo "$input" | jq -r '.title // "Claude Code"')

case "$notification_type" in
  permission_prompt)
    sound="Ping"
    display_title="⚠️  権限が必要です"
    ;;
  idle_prompt)
    sound="Pop"
    display_title="⏸️  入力待ち中"
    ;;
  auth_success)
    sound="Glass"
    display_title="✓ 認証成功"
    ;;
  elicitation_dialog)
    sound="Submarine"
    display_title="💬 入力が必要です"
    ;;
  *)
    sound="Glass"
    display_title="$title"
    ;;
esac

/opt/homebrew/bin/terminal-notifier \
  -title "$display_title" \
  -message "$message" \
  -sound "$sound" \
  2>/dev/null
chmod +x ~/.claude/scripts/hooks/notification.sh

2. ~/.claude/settings.json にフックを登録

{
  "hooks": {
    "Notification": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/scripts/hooks/notification.sh"
          }
        ]
      }
    ]
  }
}

通知タイプ一覧

notification_type タイミング
permission_prompt ツール実行の権限確認
idle_prompt 入力待ち状態
auth_success 認証成功
elicitation_dialog 追加入力が必要な時

参考

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?