Claude Code PushNotification tool: what it does and how to use it

Claude Code PushNotification 工具:功能介绍与使用指南

PushNotification is a native Claude Code tool you can call to send PushNotification to your phone or Claude app. The obvious use case is long-running tasks: “Run the full test suite, fix what you can, and notify me using the PushNotification tool when the suite is green or blocked.”

PushNotification 是 Claude Code 的原生工具,你可以调用它向手机或 Claude App 发送推送通知。最显而易见的用途是处理长时间运行的任务,例如:“运行完整的测试套件,修复你能修复的问题,并在测试通过或受阻时使用 PushNotification 工具通知我。”

But the more interesting cases are background workflows: Useful examples: notify when a build finishes, notify when a monitor sees a production-like error in logs, notify when a scheduled task finds something, notify when Claude is blocked on a human decision, notify when a remote/headless session needs attention, notify when a channel integration failed and the agent could not DM you, notify when a morning brief or weekly review is ready. This is especially useful with Monitor Tool, /loop, Crons.

但更有趣的场景是后台工作流。实用的例子包括:构建完成时通知、监控器在日志中发现生产环境类似错误时通知、定时任务发现异常时通知、Claude 等待人工决策时通知、远程/无头会话需要关注时通知、频道集成失败且 Agent 无法私信你时通知,以及晨报或周报准备就绪时通知。这在配合 Monitor Tool、/loop 和 Crons 使用时尤为有效。

How it works: You enable mobile push in /config with “Push when Claude decides.” Activate remote-control for mobile push through the Claude app. Ask for it directly in a prompt or set a rule in CLAUDE.md, for example: “run the tests and notify me with the PushNotification tool when they finish.”

工作原理:你可以在 /config 中通过“Push when Claude decides”(在 Claude 决定时推送)选项启用移动端推送。通过 Claude App 激活移动端推送的远程控制功能。你可以在提示词中直接要求使用该功能,或在 CLAUDE.md 中设置规则,例如:“运行测试,并在完成后使用 PushNotification 工具通知我。”

How I wire it: On my Claude Code Always-on Agents (claude-code-hermit plugin), the notification policy is: if a real two-way channel is reachable, send the message there first; if no channel is configured, use PushNotification; if a configured channel is broken, use PushNotification as fallback; never rely on push as the only record; keep push messages short, one-line, actionable, and low-frequency.

我的配置方式:在我的 Claude Code 常驻 Agent(claude-code-hermit 插件)上,通知策略如下:如果可连接到真正的双向通信频道,优先发送到该频道;如果没有配置频道,则使用 PushNotification;如果已配置的频道故障,则将 PushNotification 作为备选;绝不将推送作为唯一的记录方式;保持推送消息简短、单行、可操作且低频。

That keeps the signal clean. Push should not duplicate every Discord/Telegram message. It should cover the cases where the normal path is absent, broken, or too slow.

这能保持通知信号的纯净。推送不应重复发送 Discord/Telegram 上的每一条消息,它应该只覆盖那些常规路径缺失、中断或响应过慢的情况。

Best practices: Keep the message short: “CI failed on api-tests: 3 auth regressions. Open session for details.” Put the actionable bit first: “Decision needed: choose migration strategy before Claude edits schema.” Do not push for routine progress. Push for state changes: done, blocked, failed, needs decision. If you need to answer Claude, use Remote Control or a two-way channel. Push only gets your attention.

最佳实践:保持消息简短,例如:“CI 在 api-tests 上失败:3 个身份验证回归。打开会话查看详情。”将可操作的内容放在最前面,例如:“需要决策:在 Claude 编辑架构前选择迁移策略。”不要为常规进度推送。仅在状态发生变化时推送:完成、受阻、失败、需要决策。如果你需要回复 Claude,请使用远程控制或双向频道。推送仅用于引起你的注意。

My take: PushNotification is a small tool, but it changes the workflow. Claude Code no longer has to sit silently in a terminal while you periodically check whether it finished. It can now tap you when the work is done, blocked, or worth opening again.

我的看法:PushNotification 是一个小工具,但它改变了工作流。Claude Code 不再需要静默地停留在终端里,等待你定期检查它是否完成。现在,当工作完成、受阻或值得再次查看时,它能主动“拍拍你”。