A Claude Code hook that posts to Slack when a turn takes longer than two minutes, so you can walk away from long agent runs and get pulled back when they're done.
- Save
1-notify-long-turn.shto~/.claude/hooks/notify-long-turn.sh, thenchmod +xit. - Create a Slack incoming webhook and export the URL as
SLACK_WEBHOOK_URL. - Set
MENTIONin the script to your own Slack member ID (Slack profile -> More -> Copy member ID). Without the mention the message is silent -- the mention is what makes Slack actually notify you. - Merge
2-settings-snippet.jsoninto~/.claude/settings.json, replacing the paths with absolute ones.settings.jsondoes not expand$HOME.
Requires jq and curl.
UserPromptSubmit stamps the turn's start time to /tmp. Stop reads it back,
and if the turn ran >= THRESHOLD_SECS (default 120) it posts to the webhook.
A missing stamp file means the Stop came from /clear, a resume, or a compact,
so there's nothing to time and the hook exits quietly.
The Stop hook is async, so it never adds latency to your turn.
THRESHOLD_SECS-- raise it if you get pinged too often.- Stamp files are per-session in
/tmp; a session that dies without aStopleaves one behind. Harmless, butrm /tmp/claude-turn-start-*clears them.
The webhook call is fire-and-forget: output is discarded, so the hook reports success whether or not Slack accepted the post. Fine for a personal nudge, but don't debug Slack delivery by trusting that message.