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

相关推荐
余槐i7 小时前
Skills 增至 30 个,Claude Code 反而变慢:token 与加载实测
性能优化·开发工具·ai agent·claude code·agent skills
码哥字节1 天前
185,000 星的 Superpowers 插件,90% 的人只用了它 10% 的功能
claude code·superpowers
VIP_CQCRE6 天前
Claude Code 接入 NanoBanana MCP:用 Ace Data Cloud 在开发对话里生成与编辑图片
ai绘画·mcp·claude code·nanobanana·ace data cloud
范中勤6 天前
Agent IDE 双层异步调用机制:前端流式与后端多分支调度,到底各自解决什么问题
llm·agent·claude code·subagent·异步架构
浩风祭月6 天前
Claude Haiku 5.5来了:适合哪些任务?“便宜75%”为什么不是会员降价
claude·ai模型·claude code·claude haiku
Maynor9968 天前
让 AI 编程助手学会做视频、做 PPT:Agent Skills 入门与安装全指南
人工智能·aigc·ai编程·效率工具·cursor·claude code
Maynor9969 天前
开源12个电商出图Agent Skills:GPT Image 2.5一键出图
gpt·ai绘画·跨境电商·claude code·agent skills·gpt image
️公子10 天前
Claude Code 2.1.289 补上四个 deny 缺口:Agent 权限匹配器的规范化、分层裁决与回归语料
软件工程·ai agent·权限控制·claude code·安全工程