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

相关推荐
鸽芷咕3 天前
Claude Code 报 429 “Rate limit reached“?先分清是限速还是额度用完,对症下药
人工智能·报错解决·编程工具·claude code
BryceBorder3 天前
Agent Memory 不只是聊天记录:手搓三大记忆系统
后端·agent·面经·codex·claude code·agent memory
youcans_3 天前
【嵌入式软件AI编程】16. Claude Code 与 VS Code 的协同开发
stm32·mcu·嵌入式·ai编程·claude code
向上的车轮6 天前
Claude Code辅助遗留系统重构:可行性评估、小步落地与多仓WMS整合建议
claude code
小静AI工程实验室7 天前
Claude Code 实用教程:Windows、macOS、Linux 从安装到项目调试与验收
人工智能·python·开发工具·claude code
VIP_CQCRE8 天前
Claude Code 接入 Nano Banana MCP:在终端里完成 AI 图片生成、编辑与多图合成
ai·图像生成·mcp·claude code·ace data cloud
码哥字节8 天前
30K Star 神器,给 Claude Code 装上代码地图,Token 中位数省 65 倍
mcp·claude code
带电的小王8 天前
Claude Code + Agnes:接入无限期免费文本、图片、视频模型,告别 Token 焦虑
claude code·agnes
Byron07078 天前
Skill-First 懒加载方案:无向量库的200+ Skill生产级落地方案
skill·claude code