🚀
Claude Code の notifications hook で作業内容を良い感じに slack に送信する
python とか node を使わず shell のワンライナーで送信する方法です。
jq
や curl
は使えるようにしておいてください。
-
以下を参考に incoming webhooks の設定をして webhook の URL をコピーする
https://api.slack.com/messaging/webhooks -
~/.claude/settings.json に以下の設定をする
{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "transcript_path=$(jq -r '.transcript_path') && jq -s '.[-3:]' \"$transcript_path\" | claude -p 'この会話の内容を日本語で簡潔に要約してください' | jq -Rs '{\"text\": .}' | curl -X POST -H 'Content-type: application/json' -d @- https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXXXX"
}
]
}
]
}
}
-
CLAUDE_CONFIG_DIR
を設定している方はファイルパスを読み替えてください - webhook の URL は実際のものに置き換えてください
Discussion