Send Discord notifications for long-running operations and important events
BashAdd to your .claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"hooks": [
{
"type": "command",
"command": ".claude/hooks/discord-error-notifications.sh"
}
],
"matcher": "Bash"
}
]
}
}This hook includes a script file. Download the ZIP bundle for complete installation with script and instructions.
Send Discord notifications for long-running operations and important events
#!/bin/bash
if [[ -z "$DISCORD_WEBHOOK_URL" ]]; then
exit 0
fi
tool_result=$(jq -r '.tool_result // empty')
if echo "$tool_result" | grep -qi "error\|failed\|exception"; then
command=$(jq -r '.tool_input.command // "unknown"' | head -c 100)
payload=$(jq -n --arg msg "Command failed: $command" '{"content": $msg}')
curl -s -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d "$payload" >/dev/null 2>&1
fi
PostToolUse hooks run after a tool completes execution. They can modify the result or trigger additional actions.