slack-notifications — Claude Code hook: Slack pings when work ends
Posts a Slack message when Claude finishes working or a subagent completes its task. Useful when you step away from the terminal and want to know the run is done.
npx claude-code-templates@latest --hook automation/slack-notificationsWhat slack-notifications does
The hook listens to two events: Stop and SubagentStop. The first sends a note that Claude finished working, the second reports that a subagent completed its task. Each message includes the date and time in %Y-%m-%d %H:%M:%S format.
Under the hood it is a shell command. It checks the SLACK_WEBHOOK_URL environment variable and POSTs through curl with a Content-type: application/json header. If the variable is empty, the notification is skipped and a warning is printed. If curl fails, you get an error line instead.
Grab the webhook URL in your Slack app settings under Incoming Webhooks. Without it the hook stays silent, so verify the variable before you rely on these pings.
What it helps with
- know when a long Claude run has finished
- get a signal that a subagent wrapped up
- track runs while away from the terminal
- timestamp task completion in a team channel
Example prompts for the agent
- set up the slack-notifications hook so I get Slack pings
- add a Stop hook to settings.json that posts to Slack
- check that SLACK_WEBHOOK_URL is set and notifications are going out
How to install slack-notifications
1claude-code-templates
npx claude-code-templates@latest --hook automation/slack-notifications2Manually: put the files in place
.claude/settings.jsonThe hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json
Step by step, with commands for each platform: Claude Code hooks: what they are, where to configure them, how to block a risky command
Questions about slack-notifications
How do I install slack-notifications in Claude?
Run npx claude-code-templates@latest --hook automation/slack-notifications, then check .claude/settings.json — the hook should be registered there.
What does slack-notifications do?
It posts a Slack message through your webhook when Claude finishes working or when a subagent completes a task.
What does the hook need to work?
The SLACK_WEBHOOK_URL environment variable holding an incoming webhook URL from your Slack app settings. Without it, sending is skipped.
Source text
slack-notifications.json · MIT
{
"description": "Send Slack notifications when Claude Code finishes working. Requires SLACK_WEBHOOK_URL environment variable. Get webhook URL from Slack App settings -> Incoming Webhooks.",
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "if [[ -n \"$SLACK_WEBHOOK_URL\" ]]; then MESSAGE='{\"text\":\"🤖 Claude Code finished working at $(date '+%Y-%m-%d %H:%M:%S')\"}'; curl -s -X POST \"$SLACK_WEBHOOK_URL\" -H \"Content-type: application/json\" -d \"$MESSAGE\" >/dev/null 2>&1 || echo \"Failed to send Slack notification\"; else echo \"⚠️ Slack notification skipped: Set SLACK_WEBHOOK_URL environment variable\"; fi"
}
]
}
],
"SubagentStop": [
{
"hooks": [
{
"type": "command",
"command": "if [[ -n \"$SLACK_WEBHOOK_URL\" ]]; then MESSAGE='{\"text\":\"🎯 Claude Code subagent completed task at $(date '+%Y-%m-%d %H:%M:%S')\"}'; curl -s -X POST \"$SLACK_WEBHOOK_URL\" -H \"Content-type: application/json\" -d \"$MESSAGE\" >/dev/null 2>&1 || echo \"Failed to send Slack notification\"; else echo \"⚠️ Slack notification skipped: Set SLACK_WEBHOOK_URL environment variable\"; fi"
}
]
}
]
}
}
© davila7 · MIT · davila7/claude-code-templates