Claude Code — Slack Notification Hook
Sends a Slack message when Claude Code finishes a task (Stop event), using incoming webhooks.
Why / When to Use
Use when you want a real-time Slack ping every time Claude Code completes a turn — useful for long-running autonomous sessions where you’re not watching the terminal.
Core Concept / Commands
Step 1 — Create Slack Incoming Webhook
- Go to
api.slack.com/apps→ Create New App → From scratch - Add Incoming Webhooks, enable it → Add New Webhook to Workspace
- Pick a channel → copy the webhook URL:
https://hooks.slack.com/services/...
Step 2 — Create hook script
mkdir -p ~/.claude/hooks
nano ~/.claude/hooks/notify-slack.sh#!/bin/bash
# ~/.claude/hooks/notify-slack.sh
SLACK_WEBHOOK_URL="${SLACK_WEBHOOK_URL}"
if [ -z "$SLACK_WEBHOOK_URL" ]; then
exit 0
fi
input=$(cat)
session_id=$(echo "$input" | jq -r '.session_id // "unknown"')
project=$(echo "$input" | jq -r '.cwd // "unknown"' | xargs basename)
curl -s -X POST "$SLACK_WEBHOOK_URL" \
-H 'Content-type: application/json' \
--data "{\"text\": \"✅ Claude Code done — project: \`${project}\` (session: \`${session_id}\`)\"}"chmod +x ~/.claude/hooks/notify-slack.shStep 3 — Set webhook URL in environment
# Add to ~/.zshrc or ~/.bashrc
export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/WEBHOOK/URL"Step 4 — Register in Claude Code settings
Edit ~/.claude/settings.json (global) or .claude/settings.local.json (per-project):
{
"hooks": {
"Stop": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/notify-slack.sh"
}
]
}
]
}
}Key Options / Variants
- Notification hook (fires when Claude needs input): add same pattern under
"Notification"key with a"⚠️ Claude needs attention"message - Per-project scope: put in
.claude/settings.local.jsoninside the project folder - Global scope:
~/.claude/settings.json
The hook reads JSON from stdin (including session_id, cwd, etc.) and posts to Slack via curl.
Gotchas
- The
SLACK_WEBHOOK_URLenv var must be set in the shell that launches Claude Code - Script reads stdin — don’t forget
input=$(cat)before parsing - Uses
jq— ensure it’s installed (brew install jq/apt install jq)
Source
Conversation: “Integrating Claude with Slack notifications” — 2026-05-18