我如何用 Hook 构建监控 Claude Code 会话的插件,以及踩过的 Windows 坑
Original title: What I learned building a Claude Code plugin to monitor all your sessions.
The title and summary in the selected language are awaiting translation.
作者开发了 PeakOS,一个展示所有 Claude Code 会话、花费和休息提醒的桌面应用,核心逻辑放在 Hook 里,插件只发布一个 Rust 可执行文件,无参数时从 stdin 读取一条 Hook 事件 JSON,带 record 时由 Skill 写入数据,带 statusline 时输出状态栏。
| I built PeakOS, a desktop app that shows all my Claude Code sessions, what they cost and when I need a break. Most of the work was in the hook, so here's how it's built and what went wrong, in case you're writing your own. The plugin ships one Rust executable. With no arguments, it reads one hook event as JSON on stdin. With `record`, skills pipe data to it. With `statusline`, it prints Claude Code's status line. One binary meant one build and one place to fix bugs. Hooks can do more than log:
Windows problems I hit:
How Claude Code helped: it wrote most of the hook and the app. I made the product calls and kept a numbered decision log that every session read first. That log did more for consistency than any prompt trick. 319 Rust tests so far. The app is free, Windows only for now: https://github.com/maybeanns/peakos-releases. Happy to go deeper on any of the hook design. submitted by /u/NaivePresentation449 to r/ClaudeCode[link] [留言] |
Source: Reddit · ClaudeCode / Codex / VibeCoding · reddit.com