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

相关推荐
张彦峰ZYF8 小时前
从 Claude 到 Mythos:Anthropic 模型体系、对齐路线与企业级智能体实践分享
人工智能·claude·ai 安全·claude code·fable 5·mythos 5·企业级 ai
cooldream20093 天前
AI 编程系列之 11:AI Coding 工程师的能力模型——5 年后的护城河
ai编程·vibe coding·claude code
无风听海4 天前
Skills 的工程学:把经典软件工程搬进一个概率型运行时
软件工程·claude code
码哥字节5 天前
从聊天框到 Agent:Claude Code 真正的提效方式
claude code·ai编程工具
老谷子.AI原始技术5 天前
《Claude Code工程化实践》加课4-Claude Code 的底层内功:Prompt Engineering
prompt·claude code
码哥字节6 天前
Claude Code 新手必问的 10 个问题,一次答清楚
claude code
林小果16 天前
用 Codex 做一个 API 地址诊断器:Claude Code、Codex、Gemini CLI 的 /v1 排错实战
api·ai编程·codex·claude code·gemini cli·base url·linkagi
HYDtomako7 天前
Claude Code学习
学习·ai·agent·claude code