logo
Claude 使用指南
Vibe Coding

Claude 使用指南

Claude 是 Anthropic 开发的先进 AI 助手,以安全、有帮助和诚实著称。本指南帮助你充分发挥 Claude 的能力。

Claude 使用指南通知 Hook

Simple Notifications Hook(Claude Code)

Notifications Hook Cover
Notifications Hook Cover

Simple Notifications Hook 会在 Claude Code 完成工具执行后发送桌面通知,适合处理长任务时的提醒与节奏管理。

#主要功能(Key Capabilities)

  • Instant Notifications(操作完成立即提醒)
  • Cross-Platform(macOS / Linux)
  • PostToolUse Hook(自动触发)
  • Universal Matcher(默认覆盖所有工具)
  • Lightweight(零负担)

#安装(Installation)

bash
npx claude-code-templates@latest --hook automation/simple-notifications

安装路径:

bash
your-project/ ├── .claude/ │ └── hooks/ │ └── simple-notifications.json

#使用方式(How to Use)

Hook 会自动生效,无需显式调用:

bash
claude > Read the package.json file > Edit src/index.js and add a console.log > Run npm test

#系统要求

  • macOS:使用 osascript(系统自带)
  • Linux:使用 notify-send(常见发行版自带或可安装)
bash
# Debian/Ubuntu sudo apt-get install libnotify-bin

#自定义示例

json
{ "description": "Send desktop notifications with custom messages", "hooks": { "PostToolUse": [ { "matcher": "Read|Write|Edit", "hooks": [ { "type": "command", "command": "notify-send 'Custom Title' 'File operation: $CLAUDE_TOOL_NAME done!'" } ] } ] } }

#排障(Troubleshooting)

  • macOS:检查终端通知权限
  • Linux:确认 notify-send 是否安装
bash
which notify-send notify-send "Test" "This is a test notification"

#参考链接