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,发个消息验证

相关推荐
梦想的初衷~8 小时前
【科研自动化实战】Codex × Claude Code × OpenClaw × Hermes:四位AI研究员的科研协作流水线搭建指南
人工智能·codex·claude code·openclaw·科研自动化·agent协作·ai科研助手
lincats11 小时前
5个Claude Code Skill,把产品经理的反馈分析从45分钟压到了10分钟
claude code·skills
星云_byto12 小时前
五分钟从零配置好VSCode + Claude Code + DeepSeek V4 Pro
ide·vscode·编辑器·cursor·codex·claude code·deepseekv4
月♡下ღchase梦1 天前
Claude Code安装教程
经验分享·codex·claude code
Briwisdom1 天前
Agent 不是工具调用器——理解 Agent 的工作机制
人工智能·codex·ai-agent·claude code·opencode·agent机制
菜地里的小菜鸟1 天前
vscode接入claudecode
vscode·claude code·vscode接入claudecode
码哥字节3 天前
AI Agent 替你写代码没问题,但这 3 类后端任务让它当场翻车
claude code·ai编程工具·ai agent 记忆
码哥字节5 天前
213000星的Superpowers,90%的人只用了它10%的功能
claude code·ai编程工具·claude code技巧
lincats6 天前
Claude Code项目越写越乱?这套清理流程能救你
ai·ai agent·claude code