claude-code-notifier
工作原理 指南 常见问题
◐简体中文
English العربية Deutsch Español Français עברית Italiano 日本語 한국어 Nederlands Polski Português (Brasil) Русский Türkçe Tiếng Việt 简体中文 繁體中文
开始使用
全部指南

在 Windows 上接收 Claude Code 通知(PowerShell 和 WSL)

更新于 2026年10月31日 · 阅读约 6 分钟
本页内容 01原生 Windows 还是 WSL:hook 在哪里运行 02快速测试:terminal 响铃 03用 PowerShell 实现 Notification hook 04用 BurntToast 实现真正的 toast 05在 WSL 中:通过 interop 调用 Windows 06Claude Code Notifier 的定位 07常见问题

在 Windows Terminal、PowerShell 或 VS Code terminal 中,Claude Code 默认不显示桌面通知,所以在 Windows 上需要自己加。在 %USERPROFILE%\.claude\settings.json 中添加一个运行 PowerShell 的 Notification hook(如果想在“完成”时提醒,再加一个 Stop hook):消息框无需安装任何东西,BurntToast 模块则能弹出真正的 toast 通知。如果 Claude Code 运行在 WSL 中,hook 是在 Linux 里执行的,因此必须通过 Windows interop 调用 powershell.exe 才能通知到 Windows 桌面。

01原生 Windows 还是 WSL:hook 在哪里运行

Claude Code 要么原生运行在 Windows 上,要么运行在 WSL 中,这决定了通知 hook 的写法。

  • 原生 Windows。配置文件位于 %USERPROFILE%\.claude\settings.json。根据 Anthropic 的 hooks 参考文档,命令型 hook 默认在 Git Bash 中运行,未安装 Git Bash 时则在 PowerShell 中运行。可以用 "shell": "powershell" 让单个 hook 强制使用 PowerShell;此时 Claude Code 会优先使用 pwsh.exe(PowerShell 7),找不到时再用 powershell.exe(Windows PowerShell 5.1)。
  • WSL。claude 是在 WSL terminal 里安装和运行的,所以配置文件是发行版内 Linux 那份 ~/.claude/settings.json,hook 也在 Linux shell 中运行。在这里用 notify-send 通常到不了 Windows 桌面,应改为调用 Windows 程序。

02快速测试:terminal 响铃

最简单的提醒方式是响铃。在配置文件中加入:

{
  "preferredNotifChannel": "terminal_bell"
}

这样 Claude Code 在完成或等待你操作时会发送响铃字符。在 Windows Terminal 中,响铃的效果由其 settings.json 里每个配置文件的 bellStyle 决定。"bellStyle": ["window", "taskbar"] 会闪烁窗口和任务栏按钮,而不是播放声音。更多内容见 terminal 响铃指南。这种方式只在 terminal 可见时才有用。

03用 PowerShell 实现 Notification hook

这是 Anthropic hooks 指南中的 Windows 示例,无需安装任何东西:

{
  "hooks": {
    "Notification": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "powershell.exe -Command \"[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('Claude Code needs your attention', 'Claude Code')\""
          }
        ]
      }
    ]
  }
}

它弹出的是对话框,而不是屏幕角落的 toast,而且对话框可能出现在 terminal 后面。先在 PowerShell 中测试这条命令,再在 Claude Code 中输入 /hooks 确认 hook 已加载。

空 matcher 会对所有通知类型触发,包括 permission_prompt(某个审批已等待约 6 秒)和 idle_prompt(Claude 已完成约 60 秒)。触发时机详见 Notification hook 指南。

04用 BurntToast 实现真正的 toast

BurntToast 是一个广泛使用、由社区维护的 PowerShell 模块,用于发送 Windows toast 通知。为当前用户安装一次即可:

Install-Module -Name BurntToast -Scope CurrentUser

然后确认它能正常工作:

New-BurntToastNotification -Text 'Claude Code', 'Claude needs your attention'

在 hook 中使用。这个版本以无 profile 方式启动 PowerShell,并仅对本次调用绕过执行策略,因此从 Git Bash 或 PowerShell 运行效果都一样:

{
  "hooks": {
    "Notification": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"New-BurntToastNotification -Text 'Claude Code', 'Claude needs your attention'\""
          }
        ]
      }
    ],
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"New-BurntToastNotification -Text 'Claude Code', 'Claude has finished'\"",
            "async": true
          }
        ]
      }
    ]
  }
}

Stop hook 在每轮结束时运行,任务一完成就能收到提醒,而不用等一分钟;参见 Stop hook 指南。"async": true 让 hook 在后台运行,这样 PowerShell 启动慢也不会拖住 Claude Code。

如果始终不出现 toast,检查 设置 > 系统 > 通知:通知必须开启,“请勿打扰”必须关闭。BurntToast 的通知通常显示在 Windows PowerShell 名下,它的通知也需要允许。

05在 WSL 中:通过 interop 调用 Windows

在 WSL 中 hook 运行在 Linux 里,但 WSL 可以通过 .exe 文件名启动 Windows 程序。Anthropic 的指南指出,powershell.exe 必须通过 Windows interop 出现在你的 PATH 中。这是默认行为,由 /etc/wsl.conf 中 [interop] 部分的 appendWindowsPath 控制。在 WSL shell 中检查:

command -v powershell.exe

在 Windows 端装好 BurntToast 后,WSL 中 ~/.claude/settings.json 里的 hook 用的是同一条命令:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"New-BurntToastNotification -Text 'Claude Code', 'Claude has finished'\"",
            "async": true
          }
        ]
      }
    ]
  }
}

从 WSL 启动 Windows PowerShell 可能要一秒甚至更久,这也是要加 "async": true 的另一个原因。

06Claude Code Notifier 的定位

人在电脑前时,上面这些 hook 都够用。但一旦离开座位就没用了,而且 toast 也没法替 Claude 批准命令。

Claude Code Notifier 是一个基于 Claude Code hooks 的独立工具(由 TouchTap 开发,并非 Anthropic 出品)。它的免费命令行工具 ccn 支持 Mac、Windows 和 Linux,其中 Windows 支持处于 beta 阶段。在原生 Windows 上,在 PowerShell 中安装:

irm https://claudecodenotifier.com/install.ps1 | iex

它会把自己的 hook 条目加到 Claude Code 配置中,不改动文件其他内容,并保留一份备份。装好后立刻生效:Claude 完成、需要权限或提出问题时,会弹出 Windows toast,不需要手机,也不需要联网。因为它挂接的是 Claude Code 而不是 terminal,所以在 Windows Terminal、PowerShell 和 IDE terminal 中表现一致。

如果 Claude Code 运行在 WSL 中,就用 Linux 的安装命令在 WSL 内安装 ccn,因为 Claude Code 及其配置都在那里:

curl -fsSL https://claudecodenotifier.com/install.sh | sh

然后运行 ccn test。WSL 内的桌面通知能否到达 Windows 桌面取决于你的 WSL 配置,所以在 WSL 下用手机接收更可靠。配对手机后,事件会以 push 通知送达,你可以在手机上对权限请求选择允许一次、本次会话内允许或拒绝,回答 Claude 的问题,并发送下一条指令。手机 App 相关内容见配对手机、ccn 页面和价格。

如果装了 ccn,记得删掉自己配置的 toast hook,免得收到重复通知。

07常见问题

为什么我的 PowerShell hook 在 Windows 上没反应?

先在 PowerShell 里直接运行同一条命令。如果能正常运行,再检查 /hooks 里有没有列出这个 hook,以及 JSON 转义是否正确(里面的每个 " 都要加反斜杠)。如果用的是 BurntToast,确认模块是为运行 Claude Code 的同一个用户安装的,并且勿扰模式已关闭。

Windows 上的 Claude Code 运行 hook 需要 Git Bash 吗?

不需要。装了 Git for Windows 时 hook 在 Git Bash 里运行,没装就在 PowerShell 里运行。也可以给单个 hook 设置 "shell": "powershell"。

notify-send 在 WSL 里能用吗?

通常没法把通知发到 Windows 桌面。可靠的做法是像上面那样,在 hook 里通过 WSL interop 调用 powershell.exe。

Windows Terminal 自己能显示 Claude Code 通知吗?

默认不能。可以把 preferredNotifChannel 设为 terminal_bell,再选一个会闪烁窗口或任务栏的 bellStyle;或者用 hook 弹出 toast。

有免费的方式收到 Windows 通知吗?

有。上面的 PowerShell hook 和 ccn 的桌面通知都是免费的,只有手机 App 需要订阅或买断。

Claude Code Notifier Claude Code 完成任务或需要你介入时,手机会收到 push,你可以直接在手机上批准、拒绝或回复。ccn 命令行工具在 Mac、Windows 和 Linux 上均可免费使用。
下载 iOS 版 下载 Android 版 安装 ccn

相关指南

  • Claude Code hook 详解:每个事件及其用途介绍 Claude Code hook 是什么、在 settings.json 中放在哪里、matcher、输入和退出码如何工作,以及每个 hook 事件的用途。
  • Claude Code Notification hook:何时触发、如何使用Claude Code 的 Notification hook 何时触发,permission_prompt 和 idle_prompt 的含义,它接收的输入,以及为什么会延迟触发。
  • Linux 上的 Claude Code 通知在 Claude Code 完成任务或需要输入时收到 Linux 桌面通知:notify-send hook、提示音、终端转义序列,或者 ccn。
  • 在 VS Code、Cursor 和 JetBrains 终端中接收 Claude Code 通知为什么 Claude Code 完成后 IDE 终端毫无动静,以及如何通过设置或 hook 在 VS Code、Cursor 和 JetBrains 中收到提醒。
claude-code-notifier

Claude Code Notifier 是一款独立的第三方应用,与 Anthropic, PBC 无关联,亦未获其认可或赞助。“Claude”和“Claude Code”是 Anthropic, PBC 的商标。

应用 iOS 应用 Android 应用 适用于 macOS、Windows 和 Linux 的 ccn 全部指南
法律信息 隐私政策 服务条款 其他语言 © 2026 touchtap。保留所有权利。 TouchTap Ltd 注册于英格兰和威尔士,公司编号 13942589。