diff --git a/README.md b/README.md index 00848d3..7fa1d63 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,42 @@ cp claudeplus/commands/* ~/.claude/commands/ 重启 Claude Code 后即可使用。 +### 安装 Stop Hook(token 用量自动备份) + +需要先安装 Go: + +```bash +sudo apt install golang-go -y +``` + +编译并配置: + +```bash +cd claudeplus/hooks/token-stats-hook +go build -o ~/.claude/token-stats-hook-bin . +``` + +在 `~/.claude/settings.json` 中加入以下配置(如已有其他 hooks 注意合并): + +```json +{ + "hooks": { + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "~/.claude/token-stats-hook-bin 2>/dev/null || true" + } + ] + } + ] + } +} +``` + +重启 Claude Code 后,每次会话结束时会自动将 token 用量追加到 `~/.claude/token-stats-backup.jsonl`。 + ## 模块列表 | 模块 | 路径 | 说明 |