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

相关推荐
ArkAPI9 小时前
Claude Code 连发安全修复:AI 编程 Agent 的权限,正在成为新的“安全事故高发区”
人工智能·大模型·api·codex·ai工具·claude code·arkapi
peijiping18 小时前
大模型 API 缓存命中率深度解析:OpenAI / DeepSeek / Anthropic 三家机制对比与智能体端实践 (学习笔记)
ai agent·claude code·缓存命中
TonyLee01720 小时前
Claude Code + DeepSeek:服务器安装与使用笔记
linux·服务器·deepseek·claude code
peijiping21 小时前
Agent 工具执行:并行(parallel_tool_calls)和后台(run_in_background)到底有什么区别? (学习笔记)
笔记·学习·ai agent·claude code
__zRainy__2 天前
ClaudeCode 源码深度剖析:从零读懂 Agent 架构与 MVP 最小骨架实现
架构·agent·源码解读·claude code
迷路爸爸1803 天前
Claude Code 核心设计学习记录
学习·microsoft·agent·智能体·multi-agent·claude code
笑小枫4 天前
告别电脑终端,使用飞书接管你的Claude Code
人工智能·ai编程·claude code·飞书连接claude code·手机操作claude code
hust_wangyajun5 天前
我用 Agent Reach 生成了 Claude Code 年度生态报告:一篇实战演练
ai·agent·claude code
码哥字节5 天前
17万star的招牌skill,Matt自己把它撤了
claude code·ai编程工具·mattpocock/skills
ze_sir1235 天前
Impeccable 下载安装及使用
claude code·skills·impeccable