この記事を読むと
Claude Code Hooks を使って、 Claude Code がタスクを完了するなどしたときに WSL から windows に通知を送ることができます!
💥(← Claude のウニのロゴに一番近い絵文字)
環境
- WSL
- Windows
- Claude Code v1.0.43
- go-toast
手順
1. go-toast をダウンロード
windows に通知を送信するのには go-toast を使います。下のリンクから実行ファイルをダウンロードして適当なディレクトリに置きます。
(Download 64bit/32bit を選べばOKです!)
2. hooks の設定
WSL で ~/.claude/settings.json
を開き、以下のように設定を書きます。
(</path/to/toast64.exe>
の部分は適宜変更してください!)
settings.json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "</path/to/toast64.exe> --app-id 'Claude Code' --title 'Command Execution' --message 'Executing bash command...' --audio 'default' --duration 'short'"
}
]
}
],
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "</path/to/toast64.exe> --app-id 'Claude Code' --title 'Notification' --message 'Claude Code has a notification for you.' --audio 'default' --duration 'long'"
}
]
}
],
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "</path/to/toast64.exe> --app-id 'Claude Code' --title 'Task Complete' --message 'Claude Code has finished the task.' --audio 'default' --duration 'long'"
}
]
}
]
}
}
完成です!
カスタマイズしたい方は go-toast のリポジトリや claude のドキュメントを参照してください!
トラブルシューティング
動かない
Claude Code のバージョンが古い可能性が高いです。claude -v
コマンドを実行して Claude Code が v1.0.43 よりも新しいことを確認してください!