Claude Code Notifications Setup
Set up native macOS notifications for Claude Code — works both locally and on remote devpods via SSH reverse tunnel. Get alerts with sound whenever Claude needs permission, is waiting for input, or requires MCP interaction.
What It Does
- - Local: Uses
terminal-notifier for native macOS notifications when Claude needs permission, goes idle, or requires MCP input - Devpod: Routes notifications from remote devpods through an SSH reverse tunnel to the local
terminal-notifier, with OSC 9 fallback - Hooks: Configures Claude Code
Notification hooks for permission_prompt, idle_prompt, and INLINECODE5
Platform
macOS only. The setup script will exit with a clear error if run on Linux/devpod. It uses brew, launchctl, and terminal-notifier — all macOS-only. The script SSHs into devpods to configure them remotely, so devpod setup is also done from your Mac.
Important: Run on Local Mac Only
Always confirm the user is running this on their local Mac, NOT on a devpod. The entire setup — including devpod configuration — is done from the local machine via SSH. The script SSHs into devpods to configure them remotely. If the user is on a devpod, ask them to switch to their local Mac terminal first.
Setup Workflow
1. Ask for devpod SSH hosts
Ask the user which devpod(s) to configure. Example hosts: username.devpod-ind, username-web.devpod-ind. If local-only setup, skip devpod args.
2. Run the setup script
CODEBLOCK0
Run from the skill's directory: INLINECODE11
The script handles:
- - Installs
terminal-notifier via brew if missing - Copies
notify.py to INLINECODE14 - Creates and starts the reverse tunnel listener (
notify-listener.py) via launchd - Adds
RemoteForward 19876 to ~/.ssh/config for each devpod - Copies
notify.py to each devpod and configures Claude Code hooks there - Adds
set -g allow-passthrough on to each devpod's INLINECODE20 - Configures Claude Code notification hooks in INLINECODE21
- Sends a test notification
3. Remind user of manual steps
After the script completes, always tell the user these required manual steps:
- 1. Enable notifications for your terminal in System Settings > Notifications > [Warp / iTerm / Terminal]. Ensure "Allow Notifications" is ON and alert style is "Alerts" or "Banners".
- Enable notifications for Script Editor in System Settings > Notifications > Script Editor (terminal-notifier routes through it).
- Turn off Do Not Disturb or add "Script Editor" and your terminal app to Focus exceptions.
- Reconnect SSH sessions to devpods — existing sessions don't have the reverse tunnel. New sessions get it automatically.
Architecture
CODEBLOCK1
Troubleshooting
- - No notifications showing: Check System Settings > Notifications for both your terminal app AND "Script Editor" — both must have notifications enabled
- Do Not Disturb blocking: Add "Script Editor" to Focus exceptions, or disable DND
- Listener not running:
launchctl list | grep claude and INLINECODE23 - Restart listener: INLINECODE24
- Listener logs: INLINECODE25
- Test locally: INLINECODE26
- Test devpod tunnel: From devpod tmux session: INLINECODE27
- Debug mode: INLINECODE28
Claude Code 通知设置
为 Claude Code 设置原生 macOS 通知 — 既支持本地使用,也支持通过 SSH 反向隧道在远程开发容器上使用。当 Claude 需要权限、等待输入或需要 MCP 交互时,会发出带声音的提醒。
功能说明
- - 本地:当 Claude 需要权限、进入空闲状态或需要 MCP 输入时,使用 terminal-notifier 发送原生 macOS 通知
- 开发容器:通过 SSH 反向隧道将远程开发容器的通知路由到本地的 terminal-notifier,并支持 OSC 9 回退方案
- 钩子:为 permissionprompt、idleprompt 和 elicitation_dialog 配置 Claude Code 通知钩子
平台
仅限 macOS。 如果在 Linux/开发容器上运行,设置脚本将显示明确错误并退出。它使用 brew、launchctl 和 terminal-notifier — 均为 macOS 专属。脚本通过 SSH 进入开发容器进行远程配置,因此开发容器设置也是在 Mac 上完成的。
重要提示:仅在本地 Mac 上运行
请务必确认用户在本地 Mac 上运行此程序,而不是在开发容器中。 整个设置过程(包括开发容器配置)都是从本地机器通过 SSH 完成的。脚本通过 SSH 进入开发容器进行远程配置。如果用户在开发容器中,请要求他们先切换到本地 Mac 终端。
设置流程
1. 询问开发容器 SSH 主机
询问用户要配置哪些开发容器。示例主机:username.devpod-ind、username-web.devpod-ind。如果仅本地设置,则跳过开发容器参数。
2. 运行设置脚本
bash
仅本地
python3 scripts/setup_notifications.py
本地 + 开发容器
python3 scripts/setup_notifications.py --devpod
--devpod
从技能目录运行:~/.claude/skills/claude-notifications/
脚本处理以下事项:
- - 如果缺少 terminal-notifier,通过 brew 安装
- 将 notify.py 复制到 ~/.claude/scripts/
- 通过 launchd 创建并启动反向隧道监听器(notify-listener.py)
- 为每个开发容器在 ~/.ssh/config 中添加 RemoteForward 19876
- 将 notify.py 复制到每个开发容器并配置 Claude Code 钩子
- 在每个开发容器的 ~/.tmux.conf 中添加 set -g allow-passthrough on
- 在 ~/.claude/settings.json 中配置 Claude Code 通知钩子
- 发送测试通知
3. 提醒用户手动步骤
脚本完成后,务必告知用户以下必需的手动步骤:
- 1. 为终端启用通知:系统设置 > 通知 > [Warp / iTerm / 终端]。确保允许通知已开启,提醒样式设置为提醒或横幅。
- 为脚本编辑器启用通知:系统设置 > 通知 > 脚本编辑器(terminal-notifier 通过它路由)。
- 关闭勿扰模式或将脚本编辑器和终端应用添加到专注例外。
- 重新连接开发容器的 SSH 会话 — 现有会话没有反向隧道。新会话会自动获取。
架构
┌─────────────────────────────────────────────────┐
│ 开发容器(远程) │
│ │
│ Claude Code 钩子 → notify.py │
│ → curl localhost:19876(反向隧道) │
│ → 回退方案:OSC 9 转义序列 │
└──────────────────┬──────────────────────────────┘
│ SSH RemoteForward 19876
┌──────────────────▼──────────────────────────────┐
│ 本地 Mac │
│ │
│ notify-listener.py(launchd,端口 19876) │
│ → terminal-notifier → macOS 通知中心 │
└─────────────────────────────────────────────────┘
故障排除
- - 没有显示通知:检查系统设置 > 通知,确保终端应用和脚本编辑器的通知都已启用
- 勿扰模式阻止:将脚本编辑器添加到专注例外,或关闭勿扰模式
- 监听器未运行:launchctl list | grep claude 和 lsof -i :19876
- 重启监听器:launchctl unload ~/Library/LaunchAgents/com.claude.notify-listener.plist && launchctl load ~/Library/LaunchAgents/com.claude.notify-listener.plist
- 监听器日志:cat ~/.claude/logs/notify-listener.log
- 本地测试:python3 ~/.claude/scripts/notify.py test --title Claude Code --sound Glass
- 测试开发容器隧道:在开发容器的 tmux 会话中:python3 ~/.claude/scripts/notify.py test --title Claude Code --sound Glass
- 调试模式:DEBUG=1 python3 ~/.claude/scripts/notify.py test