MohabYasser2/claude-code-mods/tree/main/cache-band
Claude Code模组
Claude Code的三个模组。我让 Claude 审核我上次的 30 Claude Code 会话,并告诉我的时间都花在哪里了。每个模组都会回答它发现的一件事。 |模组 |它有什么作用 |审计发现了什么 | |---|---|---| |缓存带|显示提示缓存的温暖程度,在您离开时保持温暖,并以 400K 令牌压缩长对话 |我的缓存变冷了 91 次 | | Git 同步带 |分支、ahead/behind 和在提示上方更改的文件,带有“拉取”、“文件”和“提交”按钮 | 1,660 手动完成 git 检查 | |侦察路由器|运行仅探索、阅读或研究 Sonnet 的子代理 | 309 子代理的 243 在 Opus 上运行 |它们在 Claude Code 的函数钩子上运行。这些都处于早期访问阶段,因此 API 可能会在版本之间发生变化。我在 Claude Code 2.1.286 和 2.1.287 上构建并测试了它们。
关于这个 mod
Claude Code模组
Claude Code的三个模组。我让 Claude 审核我上次的 30 Claude Code 会话,并告诉我的时间都花在哪里了。每个模组都会回答它发现的一件事。
|模组 |它有什么作用 |审计发现了什么 | |---|---|---| | [缓存带](缓存带)|显示提示缓存的温暖程度,在您离开时保持温暖,并以 400K 令牌压缩长对话 |我的缓存变冷了 91 次 | | Git 同步带 |分支、ahead/behind 和在提示上方更改的文件,带有“拉取”、“文件”和“提交”按钮 | 1,660 手动完成 git 检查 | | 侦察路由器 |运行仅探索、阅读或研究 Sonnet 的子代理程式 | 309 子代理程式的 243 在 Opus 上运行 |
它们在 Claude Code 的函数钩子上运行。这些都处于早期访问阶段,因此 API 可能会在版本之间发生变化。我在 Claude Code 2.1.286 和 2.1.287 上构建并测试了它们。
安装
1。将 mod 的文件夹复制到 ~/.claude/skills/ 中,例如 ~/.claude/skills/cache-band。
2。新会话加载它。在已打开的会话中,运行 /reload-plugins。
要在加载 mod 之前检查它或运行其测试:
claude plugin validate ~/.claude/skills/cache-band
claude plugin test ~/.claude/skills/cache-band
当 Claude Code 加载 mod 时,它会将 claude-code 类型声明写入 tsconfig.json 指向的 mod 的 .claude-plugin/types 文件夹中。该文件夹在这里被 git 忽略。
缓存带
每条消息都会重读整个对话。提示缓存保持便宜:缓存读取成本约为正常输入价格的十分之一。根据我的计划,缓存条目在上次读取后会保留一个小时。一旦变冷,下一条消息就会再次将整个对话写入缓存,一小时的缓存写入成本是输入价格的两倍。在 400K 对话中,这一点加起来。
乐队位于提示上方:随着小时和分钟的流逝,火焰冷却成雪花,两个切换按钮和一个紧凑按钮。
自动缓存。 在缓存变冷之前十分钟,它会对它执行 ping 操作。 ping 会通过 $.model.fork,它会从后台副本再次发送对话的最后一个请求,最后有一行保持活动状态。该副本是同一对话的逐字逐句,因此 API 从同一缓存中提供服务,并且该读取将缓存再保留一个小时。回复将被删除,并且您的聊天中不会添加任何内容。在聊天中输入“hi”也会让缓存保持温暖,但它会永远保留在对话中,Claude可能会对其采取行动。
它在 20 连续 ping 后停止。 ping 会读取缓存 (0.1x),冷重启会写入缓存 (2x),因此 20 ping 的成本约为它们阻止的重新启动的成本,大约在 16 小时内。您的下一条消息会再次启动它。如果 ping 发现缓存已消失,自动缓存将暂停,而不是每小时支付全价。自动压缩。 一旦对话传递 400K 令牌,即在 Claude 回复之后,并且缓存仍处于热状态,它就会进行压缩,因此读取对话以获取摘要的成本很低。
紧凑。 该按钮运行 /compact 就像您键入它一样。桌面应用程序拒绝 mod 的直接压缩调用,因此这是在那里工作的路线。
28 测试涵盖仪表、ping 和自动紧凑型。
Git 同步带
提示上方的条带包含分支、领先或落后的距离、更改的文件以及上次推送的时间。它每分钟读取一次 git status 并每五次获取一次,没有凭据提示,也没有获取 git 的索引锁。
在提示之前,当不会丢失任何东西时,它会用 --ff-only 拉取,并告诉 Claude 进来了什么,或者为什么没有任何反应。直接从 band 拉取、文件和提交并推送运行 git。它不会提交看起来像秘密的文件。
5 测试涵盖乐队的布局和提交流程。
侦察路由器
当 Claude 启动子代理程式时,Scout Router 会读取其类型和描述。探索代理和通用代理,其描述是关于探索、阅读、搜索或研究,在 Sonnet 上运行。任何有关计划、审核、审查或评分的内容都保留在主模型上。每次重新路由都会被记录。
许可证
麻省理工学院
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add MohabYasser2/claude-code-mods claude plugin install cache-band
原文 / README
Claude Code mods
Three mods for Claude Code. I asked Claude to audit my last 30 Claude Code sessions and tell me where my time went. Each mod answers one thing it found.
| Mod | What it does | What the audit found | |---|---|---| | Cache Band | Shows how warm the prompt cache is, keeps it warm while you're away, and compacts long conversations at 400K tokens | My cache went cold 91 times | | Git Sync Band | Branch, ahead/behind and changed files above the prompt, with Pull, Files and Commit & push buttons | 1,660 git checks done by hand | | Scout Router | Runs subagents that only explore, read or research on Sonnet | 243 of 309 subagents ran on Opus |
They run on Claude Code's function hooks. Those are in early access, so the API can change between releases. I built and tested these on Claude Code 2.1.286 and 2.1.287.
Install
- Copy a mod's folder into
~/.claude/skills/, for example~/.claude/skills/cache-band. - New sessions load it. In a session that was already open, run
/reload-plugins.
To check a mod before you load it, or to run its tests:
claude plugin validate ~/.claude/skills/cache-band
claude plugin test ~/.claude/skills/cache-band
When Claude Code loads a mod, it writes the claude-code type declarations into the mod's .claude-plugin/types folder, which tsconfig.json points at. That folder is git-ignored here.
Cache Band
Every message re-reads the whole conversation. The prompt cache keeps that cheap: a cache read costs about a tenth of the normal input price. On my plan a cache entry lives for an hour after it was last read. Once it goes cold, the next message writes the whole conversation into the cache again, and a one-hour cache write costs twice the input price. On a 400K conversation, that adds up.
The band sits above the prompt: a flame that cools into a snowflake as the hour runs out, the minutes left, two toggles and a Compact button.
Auto cache. Ten minutes before the cache would go cold, it pings it. The ping goes through $.model.fork, which sends the conversation's last request again from a background copy, with a one-line keep-alive at the end. The copy is word for word the same conversation, so the API serves it from the same cache, and that read keeps the cache for another hour. The reply is dropped and nothing is added to your chat. A "hi" typed into the chat would keep the cache warm too, but it stays in the conversation for good, and Claude might act on it.
It stops after 20 pings in a row. A ping reads the cache (0.1x) and a cold restart writes it (2x), so 20 pings cost about what the restart they prevent would, around 16 hours in. Your next message starts it again. If a ping finds the cache already gone, Auto cache pauses instead of paying full price every hour.
Auto compact. It compacts once the conversation passes 400K tokens, right after Claude's reply, while the cache is still warm, so reading the conversation for the summary is cheap. Why 400K:
- Every message re-reads the whole conversation, so at 830K each message costs about twice what it does at 400K.
- The longer the conversation, the more Claude misses (Chroma's context rot study).
- Compacting too early summarizes a long task halfway through, and details get lost. Anthropic's API compaction defaults to 150K (docs). Claude Code's own auto-compact waits until about 83% of the window, around 830K on a 1M window.
- 400K is twice the old 200K window, so a long task fits in one go, at under half the per-message cost of 830K.
Compact. The button runs /compact as if you typed it. The desktop app refuses a mod's direct compaction call, so this is the route that works there.
28 tests cover the gauge, the pings and Auto compact.
Git Sync Band
A band above the prompt with the branch, how far ahead or behind it is, the changed files and when you last pushed. It reads git status every minute and fetches every five, with no credential prompts and without taking git's index lock, so it never gets in the way of Claude's own git.
Before your prompt, it pulls with --ff-only when that can't lose anything, and tells Claude what came in, or why nothing did. Pull, Files and Commit & push run git straight from the band, without a turn in the chat. Commit & push writes the message with one small model call and shows it to you before anything runs. It won't commit files that look like secrets (.env files, keys, credentials).
5 tests cover the band's layouts and the commit flow.
Scout Router
When Claude starts a subagent, Scout Router reads its type and description. Explore agents, and general-purpose agents whose description is about exploring, reading, searching or researching, run on Sonnet. Anything about planning, auditing, reviewing or grading stays on the main model. Agents that write code stay there too, unless you set the plugin's builders option to sonnet. Haiku requests are left alone, since Haiku is already cheaper. Each reroute is logged.
License
MIT
