Note
Claude Codeを利用する際に、タスクの完了などに合わせて通知をさせたい。
Claude CodeのHooksの設定を使えば実装ができる。 Hooks reference - Anthropic
Notification
やSTOP
など事前に用意されているEventに合わせて特定のコマンドを実行できる。
この機能を利用してterminal-notifierを実行することでタイミングに合わせて通知が可能
以下のような設定を ~/.claude/settings.json
に記述する
{
"hooks": {
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "terminal-notifier -title 'Claude Code' -message 'タスクが完了しました、確認をしてください👌' -sound default -contentImage '画像のpath'"
}
]
}
],
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "terminal-notifier -title 'Claude Code' -message 'ユーザー確認待ちです👀' -sound default -contentImage '画像のpath'"
}
]
}
]
}
}
こちらの設定を行うことで、タスクが完了したタイミングと内容の確認のタイミングで通知が飛んでくるよう。