# claude-code-slack-stop-hook.json

> Source: <https://gist.github.com/xinyadu/a6a1c77e4c657632c94ee9f965c8537b>
> Published: 2026-10-16 22:46:58+00:00

A [Claude Code](https://docs.claude.com/en/docs/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.

1. Save `1-notify-long-turn.sh` to`~/.claude/hooks/notify-long-turn.sh` , then`chmod +x` it.
2. Create a Slack [incoming webhook](https://api.slack.com/messaging/webhooks) and export the URL as`SLACK_WEBHOOK_URL` .
3. Set `MENTION` in 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.
4. Merge `2-settings-snippet.json` into`~/.claude/settings.json` , replacing the
paths with absolute ones.`settings.json` does 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 a`Stop` leaves one behind. Harmless, but`rm /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.
