{"slug": "claude-code-slack-stop-hook-json", "title": "claude-code-slack-stop-hook.json", "summary": "A developer published a Claude Code hook that posts a Slack notification when an agent turn runs longer than two minutes, letting users step away from long runs and be pulled back when they finish. The hook uses UserPromptSubmit to stamp a turn's start time to /tmp and a Stop hook to read it back, firing a Slack incoming webhook with a member mention when the elapsed time meets a configurable threshold (default 120 seconds). The Stop hook runs async so it adds no latency, and missing stamp files from /clear, resume, or compact cause it to exit quietly.", "body_md": "A [Claude Code](https://docs.claude.com/en/docs/claude-code) hook that posts to\nSlack when a turn takes longer than two minutes, so you can walk away from long\nagent runs and get pulled back when they're done.\n\n1. Save `1-notify-long-turn.sh` to`~/.claude/hooks/notify-long-turn.sh` , then`chmod +x` it.\n2. Create a Slack [incoming webhook](https://api.slack.com/messaging/webhooks) and export the URL as`SLACK_WEBHOOK_URL` .\n3. Set `MENTION` in the script to your own Slack member ID\n(Slack profile -> More -> Copy member ID). Without the mention the message\nis silent -- the mention is what makes Slack actually notify you.\n4. Merge `2-settings-snippet.json` into`~/.claude/settings.json` , replacing the\npaths with absolute ones.`settings.json` does not expand`$HOME` .\n\nRequires `jq` and `curl`.\n\n`UserPromptSubmit` stamps the turn's start time to `/tmp`. `Stop` reads it back,\nand if the turn ran `>= THRESHOLD_SECS` (default 120) it posts to the webhook.\n\nA missing stamp file means the `Stop` came from `/clear`, a resume, or a compact,\nso there's nothing to time and the hook exits quietly.\n\nThe `Stop` hook is `async`, so it never adds latency to your turn.\n\n- `THRESHOLD_SECS` -- raise it if you get pinged too often.\n- Stamp files are per-session in `/tmp` ; a session that dies without a`Stop` leaves one behind. Harmless, but`rm /tmp/claude-turn-start-*` clears them.\n\nThe 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.", "url": "https://wpnews.pro/news/claude-code-slack-stop-hook-json", "canonical_source": "https://gist.github.com/xinyadu/a6a1c77e4c657632c94ee9f965c8537b", "published_at": "2026-10-16 22:46:58+00:00", "updated_at": "2026-10-16 23:57:32.579447+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools"], "entities": ["Claude Code", "Slack", "Anthropic"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/claude-code-slack-stop-hook-json", "markdown": "https://wpnews.pro/news/claude-code-slack-stop-hook-json.md", "text": "https://wpnews.pro/news/claude-code-slack-stop-hook-json.txt", "jsonld": "https://wpnews.pro/news/claude-code-slack-stop-hook-json.jsonld"}}