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

相关推荐
逻辑06 分钟前
安装 Claude Code 完整指南(用户级 Node.js 环境)
node.js·claude code
ddshub_cc1 天前
Claude Fable 5.1 Prompt Engineering:长程任务与编程 Agent 怎么写提示
ai·prompt·api·ai编程·claude·claude code·fable 5.1
知了一笑2 天前
Codex堪称Claude Code最严的父亲
ai·codex·claude code
Steve__evetS2 天前
Claude Code记忆机制
agent·记忆·claude code
码哥字节3 天前
Token Saver 省 99% token 是真的,但有个前提没人告诉你
mcp·claude code·token saver
Orange_sparkle6 天前
从 Docker 到 Doris:建立后端基础设施全景图
运维·docker·ai·容器·claude code
Akiyama_Mio-Kon6 天前
计算机每日时报(2026-08-29):AI 开始碰现实机器,编码助手先补数据与账单边界
github copilot·claude code·aws drs·chatgpt images
Akiyama_Mio-Kon6 天前
Claude Code 修复凭据文件云上传:给 AI 编程工具补一张“工作区出境”门禁
devsecops·terraform·ai 编程·claude code·凭据安全·ai agent 安全·云会话
乱世刀疤7 天前
Claude Code系统级命令全解析
人工智能·claude code
StarRocks_labs7 天前
从 6000+ Commit 中识别升级风险:一个 StarRocks AI 升级扫描工具的实现
starrocks·ai·commit·分析·claude code