Notifications

Get push notifications on your phone when Claude Code finishes a task, or send custom notifications from any script.

Quick Setup for Claude Code

One command installs notification hooks for Claude Code:

afk hooks install

This adds two hooks to ~/.claude/settings.local.json:

  • Stop hook — notifies you when Claude Code finishes, with a preview of the original prompt
  • Notification hook — forwards Claude Code notifications (e.g., permission requests) to your phone

Hooks only fire inside AFK sessions (when AFK_SESSION_ID is set). Outside of afk stream, they silently no-op so they won't interfere with normal Claude Code usage.

Sending Notifications

Send a push notification to all your mobile devices:

# Simple notification

afk notify "Build complete!"

 

# Custom title

afk notify "All tests passed" --title "CI"

 

# Deep-link to a session when tapped

afk notify "Deploy finished" --session-id abc12345-...

The --title flag defaults to "AFK". Use --session-id to open a specific session when the notification is tapped on your phone.

Managing Hooks

# Install hooks

afk hooks install

 

# Check if hooks are installed

afk hooks status

 

# Remove hooks

afk hooks remove

afk hooks install is idempotent — safe to run multiple times. It preserves any existing hooks in your Claude Code settings.

How It Works

When Claude Code triggers a hook, it pipes JSON to stdin containing context about the event. AFK's hook handler reads this JSON, extracts relevant information, and sends a push notification.

1
Hook fires

Claude Code runs afk notify --app claude --event-type stop with JSON on stdin

2
Context extracted

For stop events, AFK reads the transcript and extracts your original prompt

3
Notification sent

A push notification with the prompt preview is delivered to your mobile devices