claude code使用技巧-完成通知

目的

windows环境下,claude code使用技巧笔记

背景

claude code完成任务,没有通知,不够友好,这里借助Hook机制实现完成通知

步骤

1、编写system-toast.sh,放到~/.claude/hooks目录下,脚本内容如下:

bash 复制代码
#! /bin/bash
title="${2:-Claude Code}"
body="$1"
powershell.exe -Command "
    [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
    \$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
    \$nodes = \$template.GetElementsByTagName('text')
    \$null = \$nodes.Item(0).AppendChild(\$template.CreateTextNode('$body'))
    \$toast = [Windows.UI.Notifications.ToastNotification]::new(\$template)
    [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('$title').Show(\$toast)
  "

2、编辑~/.claude/settings.json,添加hooks:

json 复制代码
{
  "model": "opus",
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/hooks/system-toast.sh '任务完成'"
          }
        ]
      }
    ]
  },
  ...
}

3、重启claude code,发个消息验证

相关推荐
xing-xing5 小时前
Mac 安装 Claude Code
claude code
悟空码字5 小时前
把 Claude Code 变成你的架构顾问:如何用“隐式重构模式”自动消除代码坏味道
ai·大模型·agent·智能体·claude code
辞忧九千七5 小时前
解锁Claude Code超强能力:DeepSeek V4无缝接入指南
ai·deepseek·claude code
赛博李同学AI手记16 小时前
不是 Premiere,不是剪映——我用 Claude Code 做了一条视频
claude code·hyperframes
HelloFYW21 小时前
Superpowers 5.1.0 技能使用手册(中文版)
开发工具·ai开发·claude code·superpowers·技能手册
SmartManWind1 天前
vscode中claude-code插件wsl中开启自动模式
ide·vscode·编辑器·claude code
码哥字节1 天前
装了 30 个 Skills 之后,我才搞清楚哪些是在白浪费 context
claude code·agent skills
MuGuiLin1 天前
在VS Code 中安装 Claude Code 并接入 DeepSeek 模型和 Skills 的使用
ai编程·claude code·ai coding·skills·cc-switch·omc·claude code cli