Skip to content

Rendann/cc-notifier

Repository files navigation

cc-notifier πŸ””

Smart Notifications for Claude Code on Desktop and Mobile

Click notifications to instantly restore your exact Claude Code window across macOS Spacesβ€”not just the app, but your specific terminal or IDE window.

Also enables seamless πŸ“± mobile development via push notifications.

Features

  • 🎯 Click-to-Focus - Restore exact window across Spaces, not just the app. When you have multiple terminal or IDE windows open, cc-notifier brings you back to the specific window where Claude Code is running.
  • 🧠 Intelligent Detection - πŸ’» Desktop: notifies when you switch windows | 🌐 Remote: notifies when idle
  • ⚑ Fast & Async - Runs in background, never blocks Claude Code
  • πŸ“² Push Notifications - Desktop: optional idle alerts | Remote: primary notification method (Pushover)
  • πŸ“± Mobile Handoff - (Optional) Desktopβ†’phone workflow via Blink Shell

Quick Start

Desktop Mode

# Install dependencies
brew install --cask hammerspoon terminal-notifier

# Configure Hammerspoon (~/.hammerspoon/init.lua)
require("hs.ipc")
require("hs.window")
require("hs.window.filter")
require("hs.timer")

# Reload: hs -c "hs.reload()"

# Install cc-notifier
git clone https://github.com/Rendann/cc-notifier.git
cd cc-notifier
./install.sh

Add hooks to ~/.claude/settings.json (see Configuration below).

Configuration

Add to ~/.claude/settings.json:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "$HOME/.cc-notifier/cc-notifier init"
          }
        ]
      }
    ],
    "Stop": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "$HOME/.cc-notifier/cc-notifier notify"
          }
        ]
      }
    ],
    "Notification": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "$HOME/.cc-notifier/cc-notifier notify"
          }
        ]
      }
    ],
    "SessionEnd": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "$HOME/.cc-notifier/cc-notifier cleanup"
          }
        ]
      }
    ]
  },
  // Optional: Push notifications (requires Pushover account)
  "env": {
    "PUSHOVER_API_TOKEN": "your_pushover_app_token",
    "PUSHOVER_USER_KEY": "your_pushover_user_key"
  }
}

How It Works

πŸ’» Desktop Mode

  1. Session Start β†’ Captures your focused window ID
  2. Task Completion β†’ Compares current window vs original window
  3. Smart Notification:
    • πŸͺŸ Switched windows? β†’ Local notification with click-to-focus
    • πŸ’€ Idle at desk? β†’ Optional push notification via Pushover
  4. Click Notification β†’ Hammerspoon instantly restores your exact window across Spaces

🌐 Remote Mode (SSH)

  1. Auto-Detection β†’ Detects SSH via SSH_CONNECTION environment variable
  2. Session Start β†’ Skips window tracking (uses placeholder)
  3. Task Completion β†’ Checks TTY idle time (st_atime)
  4. Smart Notification:
    • πŸ’€ User idle? β†’ Push notification with resume URL
    • ⚑ User active? β†’ No notification
  5. Tap Notification β†’ Pushover opens β†’ Tap URL β†’ Blink Shell auto-resumes session

πŸ”§ Tested Stack: Tailscale + mosh + tmux + Blink Shell


Desktop notification

Mobile notification


πŸ“± Mobile Development

Start coding on your desktop, continue seamlessly on your phone.

When Claude Code completes a task and you're away from your desk, you'll get a push notification. Tap it to instantly resume your exact conversation in Blink Shell.

Workflow

  1. πŸ’» Start coding task on desktop
  2. 🚢 Walk away from computer
  3. πŸ“² Push notification arrives on your phone
  4. πŸ‘† Tap notification β†’ Pushover opens
  5. πŸ”— Tap URL β†’ Blink Shell opens
  6. ⚑ Auto-resumes exact Claude Code session

πŸ“– Complete Setup Guide: Mobile workflow documentation β†’

Configuration Example

Add to ~/.claude/settings.json (extends the Configuration section above):

{
  "env": {
    "PUSHOVER_API_TOKEN": "your_token",
    "PUSHOVER_USER_KEY": "your_key",
    "CC_NOTIFIER_PUSH_URL": "blinkshell://run?key=YOUR_KEY&cmd=mosh mbp -- ~/bin/mosh-cc-resume.sh {session_id} {cwd}"
  }
}

Placeholders (auto-replaced at runtime):

  • {session_id} β†’ Claude Code session ID
  • {cwd} β†’ Current working directory

Troubleshooting

Debug Mode:

Enable detailed logging for troubleshooting:

{
  "hooks": {
    "SessionStart": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "$HOME/.cc-notifier/cc-notifier --debug init"
      }]
    }]
    // Add --debug to all other hooks (notify, cleanup)
  }
}

Debug mode features:

  • File logging with timestamps: ~/.cc-notifier/cc-notifier.log
  • Desktop: "[DEBUG]" prefix on notifications
  • Remote: Precise timestamps on push notifications
  • Logs: Hook events, window IDs, idle checks, notification sends

View logs:

tail -f ~/.cc-notifier/cc-notifier.log  # Follow in real-time
cat ~/.cc-notifier/cc-notifier.log      # View entire log

Disable: Remove --debug flag from hook commands in settings.json


Wrong window focused:

  • Window ID captured at session start
  • Solution: Restart Claude Code or clear/resume session
  • Prevention: Keep Claude focused when starting sessions

Mac sleep interrupts tasks:

sudo pmset -g                # Check settings
sudo pmset -c sleep 0        # Disable while plugged in
caffeinate -i                # Temporary prevention

Hammerspoon window discovery:

  • Visit Spaces and click windows after Hammerspoon restart
  • Auto-populates during normal use

Window focus issues:

  • Try closing and re-opening the terminal/IDE window
  • Apps can get into states where Hammerspoon can't focus them

Development

python3 -m venv .venv
source .venv/bin/activate
make install
pre-commit install
make check  # format, lint, typecheck, test

Contributing: Fork, make check, test, PR.

Project structure:

~/.cc-notifier/         # Installation
β”œβ”€β”€ cc-notifier         # Entry point
└── cc_notifier.py      # Implementation

mobile/                 # Mobile workflow
β”œβ”€β”€ README.md
β”œβ”€β”€ mosh-cc-resume.sh
└── tmux-idle-cleanup.sh

License

MIT