Sends a push notification when a Claude Code session finishes — but only if it ran longer than 30 seconds.
When Claude is doing a long agentic task (running tests, implementing a feature, exploring a codebase), you often switch context and forget to check back. Short sessions don't need a ping — you're still watching. Long ones do — you've moved on.
This hook solves that by tracking session duration and only notifying when Claude actually did meaningful work.
This is an extension from idea here.
Two hooks wire together:
session-start.sh — runs on SessionStart. Writes the current Unix timestamp to /tmp/claude_session_<session_id>.
push-notify.sh — runs on Stop. Reads the timestamp, computes elapsed time, and exits silently if under 30 seconds. Otherwise sends a message to ntfy.sh with the project directory, current git branch, and stop reason.
-
Copy both scripts to
~/.claude/hooks/and make them executable:chmod +x ~/.claude/hooks/session-start.sh chmod +x ~/.claude/hooks/push-notify.sh
-
Generate a unique private topic:
openssl rand -hex 16
-
Set
NTFY_TOPICin your environment (e.g. in~/.zshrcor~/.claude/settings.jsonenv block):export NTFY_TOPIC=your_hex_topic_here -
Add to
~/.claude/settings.json:{ "hooks": { "SessionStart": [{ "hooks": [{ "type": "command", "command": "bash ~/.claude/hooks/session-start.sh" }] }], "Stop": [{ "hooks": [{ "type": "command", "command": "bash ~/.claude/hooks/push-notify.sh" }] }] } } -
Install ntfy on your phone/desktop and subscribe to your topic.
jq— parse hook JSON inputcurl— send ntfy requestgit— optional, for branch name in message