discord-notifications — Claude Code hook: Discord alerts on finish
Posts a Discord message when Claude stops working or a subagent finishes. Useful when you step away from the terminal and want a ping on completion.
npx claude-code-templates@latest --hook automation/discord-notificationsWhat discord-notifications does
The hook listens to two events: Stop and SubagentStop. The first fires when Claude finishes its turn, the second when a subagent completes a task. Each message includes the current timestamp from date.
Under the hood it is a curl POST to your webhook with a JSON body. If DISCORD_WEBHOOK_URL is empty, nothing is sent and the hook prints a warning instead. So a missing variable will not break your session, it just makes the hook useless.
Grab the webhook URL in Discord under Server Settings -> Integrations -> Webhooks. Set DISCORD_WEBHOOK_URL in your environment before starting Claude, otherwise every notification is skipped silently.
What it helps with
- know when a long Claude run ends without watching the terminal
- ping a shared channel when a subagent completes its task
- track agent progress from a phone through Discord
- log the finish time of an agent run without writing it down
Example prompts for the agent
- set up the discord-notifications hook and ping me in Discord when you finish
- check that DISCORD_WEBHOOK_URL is set before the hook runs
How to install discord-notifications
1claude-code-templates
npx claude-code-templates@latest --hook automation/discord-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 discord-notifications
How do I install discord-notifications in Claude?
Run npx claude-code-templates@latest --hook automation/discord-notifications, then check .claude/settings.json — the hook is written there.
What does discord-notifications do?
It sends a Discord message through a webhook when Claude finishes working or a subagent completes a task. The text includes the event time.
What does the hook need to work?
The DISCORD_WEBHOOK_URL environment variable holding a webhook from Discord Server Settings -> Integrations -> Webhooks. Without it notifications are skipped.
Source text
discord-notifications.json · MIT
{
"description": "Send Discord notifications when Claude Code finishes working. Requires DISCORD_WEBHOOK_URL environment variable. Get webhook URL from Discord Server Settings -> Integrations -> Webhooks.",
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "if [[ -n \"$DISCORD_WEBHOOK_URL\" ]]; then MESSAGE='{\"content\":\"🤖 Claude Code finished working at $(date '+%Y-%m-%d %H:%M:%S')\"}'; curl -s -X POST \"$DISCORD_WEBHOOK_URL\" -H \"Content-Type: application/json\" -d \"$MESSAGE\" >/dev/null 2>&1 || echo \"Failed to send Discord notification\"; else echo \"⚠️ Discord notification skipped: Set DISCORD_WEBHOOK_URL environment variable\"; fi"
}
]
}
],
"SubagentStop": [
{
"hooks": [
{
"type": "command",
"command": "if [[ -n \"$DISCORD_WEBHOOK_URL\" ]]; then MESSAGE='{\"content\":\"🎯 Claude Code subagent completed task at $(date '+%Y-%m-%d %H:%M:%S')\"}'; curl -s -X POST \"$DISCORD_WEBHOOK_URL\" -H \"Content-Type: application/json\" -d \"$MESSAGE\" >/dev/null 2>&1 || echo \"Failed to send Discord notification\"; else echo \"⚠️ Discord notification skipped: Set DISCORD_WEBHOOK_URL environment variable\"; fi"
}
]
}
]
}
}
© davila7 · MIT · davila7/claude-code-templates