What you need
- Claude Code with hooks (any recent version).
jqandcurl. Both come with most Macs and Linux systems; otherwisebrew install jqor your package manager.- An Ahem account (the free plan is enough), a project called Agents, and an API key for it.
Step by step
Create the project and key. In Ahem, create a project named “Agents” (its address is
agents) and an API key for it. A new key can send events and create channels. Store it where Claude Code can read it, for example in your shell profile:export AHEM_KEY="ak_live_…"Save this script as
~/.claude/hooks/ahem-notify.shand make it executable withchmod +x ~/.claude/hooks/ahem-notify.sh:#!/bin/sh # Sends a Claude Code hook event to Ahem. Never blocks Claude Code: always exits 0. url="${AHEM_URL:-https://api.useahem.com/v1/channels/agents/claude-code}" input=$(cat) event=$(printf '%s' "$input" | jq -r '.hook_event_name') project=$(basename "$(printf '%s' "$input" | jq -r '.cwd')") if [ "$event" = "Notification" ]; then title="Claude needs you · $project" level="warning"; type="agent.waiting" body=$(printf '%s' "$input" | jq -r '.message // ""') else title="Claude finished · $project" level="success"; type="agent.task_completed" body=$(printf '%s' "$input" | jq -r '(.last_assistant_message // "")[0:2000]') fi printf '%s' "$input" | jq --arg t "$title" --arg b "$body" --arg l "$level" --arg ty "$type" --arg p "$project" \ '{title: $t, body: $b, level: $l, type: $ty, group: .session_id, metadata: ({project: $p, notification: .notification_type} | with_entries(select(.value != null)))}' | curl -sS -m 5 "$url" \ -H "Authorization: Bearer $AHEM_KEY" -H "Content-Type: application/json" \ -d @- >/dev/null 2>&1 exit 0It reads the hook’s JSON from standard input. A
Notificationbecomes a warning with Claude’s message; aStopbecomes a success with the first 2,000 characters of Claude’s last reply. The session id is the event’sgroup, and the folder name goes into the title and metadata.Register the hooks in
~/.claude/settings.json, merged with what’s already there:{ "hooks": { "Notification": [ { "matcher": "permission_prompt|idle_prompt", "hooks": [{ "type": "command", "command": "~/.claude/hooks/ahem-notify.sh", "async": true }] } ], "Stop": [ { "hooks": [{ "type": "command", "command": "~/.claude/hooks/ahem-notify.sh", "async": true }] } ] } }The
Notificationmatcher keeps it to the two moments you care about:permission_prompt(Claude wants to use a tool and the prompt has waited a few seconds) andidle_prompt(Claude finished a while ago and you haven’t typed since).Turn on notifications in the Ahem app or your browser, then ask Claude Code for something that needs a permission. When you step away, your phone shows “Claude needs you · my-repo”.
Make it quieter
- Only buzz when Claude is waiting. Set the
#claude-codechannel’s rule to Warnings and errors. “Finished” events (success) are still stored, so you can scroll through every run later. - One thread per session. The script sends the session id as
group, so each Claude Code session is one thread in the inbox. - Count your agent’s work. Add a counter: count of
agent.task_completed, today. - A channel per machine or per repo. Set
AHEM_URLto another channel address, for examplehttps://api.useahem.com/v1/channels/agents/laptop. New channel names are created on the first event.
Troubleshooting
- Nothing arrives. Run the script by hand, then look in the Ahem inbox:
If the event is there, the hook isn’t registered: runecho '{"hook_event_name":"Stop","cwd":"/tmp/test","session_id":"t1","last_assistant_message":"hi"}' \ | ~/.claude/hooks/ahem-notify.sh/hooksin Claude Code to see what it loaded. AHEM_KEYis empty inside the hook. Claude Code started from an app rather than a terminal may not load your shell profile. Put the key in the script, or in a file the script reads.- Too many “finished” notifications.
Stopfires every time Claude finishes a response, not only at the end of a long task. Use the channel rule above. - A 404 from the API. The project in the address (
agents) must exist; projects are not created automatically. Channels are, as long as the key has thechannels:createscope, which new keys have. - Notifications only when you’re away. That’s Claude Code’s timing, not Ahem’s: in a terminal,
permission_promptwaits until you haven’t typed for a few seconds, andidle_promptabout a minute.
Other ways to do it
- A desktop notification (
osascript -e 'display notification …'on macOS,notify-sendon Linux). Free, but it only reaches the computer you’re sitting at. - A Telegram bot. Works, with MarkdownV2 escaping and one chat for everything. See Ahem vs a Telegram bot.
- Claude Code’s own notification settings. Good for the terminal; they don’t reach your phone.