Oualid0/claude-mods/tree/main/plugins/usage-ring
关于这个 mod
claude-mods
面向 Claude Code 终端的外掛:提示列上方有一排环形指标,显示你的限制、本次对话的用量和提示缓存,旁边还有运行中 Claude 工作階段的看板。
快速安装
将这段提示复制到 Claude Code:
Install the Claude Code plugins from https://github.com/Oualid0/claude-mods:
add the repo as a plugin marketplace, then install every plugin listed in its
.claude-plugin/marketplace.json, and tell me to run /reload-plugins when done.
手动安装
claude plugin marketplace add Oualid0/claude-mods
claude plugin install usage-ring@claude-mods
claude plugin install session-board@claude-mods
然后在 Claude Code 中运行 /reload-plugins,或启动新的工作階段。从本地克隆的副本运行 ./install.sh 也会执行相同操作(需要 python3),而且可以安全地重复运行。
更新
自动更新默认关闭。在工作階段中用 /plugin marketplace update claude-mods 手动更新,或者在 shell 中运行 claude plugin update usage-ring@claude-mods 和 claude plugin update session-board@claude-mods。也可以在 /plugin 的 Marketplaces 下为该 marketplace 开启 Enable auto-update。
外掛
| 外掛 | 功能 |
|---|---|
| usage-ring | 提示列正上方的两个芯片:limits 和 chat。旁边有一个像素 Claude,执行一轮时会敲打,其他时候会睡觉;它旁边以灰色显示模型,例如 Opus 5.5 (mid)(effort 为 low、mid、high、xhigh 或 max,从第一次请求开始就已知)。 |
| session-board | 当这台机器上有其他 Claude 工作階段运行时,在上方显示 sessions 芯片:每个工作階段一行(● 运行中,结束后 60 s 内为 ✓ 已完成),再加上标记 ← 的本工作階段一行(○ 就绪或 ● 运行中)。没有其他工作階段运行时,看板会隐藏。 |
标签含义
| 标签 | 芯片 | 含义 |
|---|---|---|
| Wk | limits | 已使用的每周限制,以百分比表示。 |
| Se | limits | 已使用的工作階段限制(5 小时窗口),以及距离重置的时间:4:50h,或不足 1 小时时显示 33m。窗口结束后,在下一次读取前会显示 0% 5:00h。 |
| Cx | chat | 已使用的上下文窗口,以百分比表示。 |
| Td | chat | 已完成的待办事项数/总数,例如 3/5。仅在对话有待办列表时显示。 |
| Tk | chat | 自工作階段开始以来本次对话使用的令牌(包括输入、输出、缓存读取和写入,以及子代理)。每次模型请求后都会增加。 |
| Co | chat | 到目前为止本工作階段的费用,单位为美元。 |
| Ca | chat | 提示缓存剩余时间(33m);过期后显示 expired。 |
终端较窄时,优先移除不重要的内容:模型标签、limits 和 chat 文字、Ca、Co、Tk、Td、Wk、像素 Claude,最后才是 Cx。Se 会尽量保留;连它也放不下时,整排会隐藏。不会挤压或换行。
限制
- 需要带 mods(function-hook 外掛)的 Claude Code 版本;已在 Claude Code 2.1.288 上测试。mod API 仍处于早期阶段,版本之间可能变化。
- 环形指标在 kitty 和 Ghostty 中使用像素图;其他终端会显示字形。
- 每周、工作階段和上下文指标达到 95% 后变红,缓存时间
Ca在最后 3 分钟变红。 Ca是估算值。Claude Code 不会告诉外掛缓存能存活多久(5 分钟或 1 小时),所以看板先假设为 1 小时,再根据每次请求从缓存读取的内容学习:暂停超过 5 分钟后命中表示为 1 小时,未命中表示为 5 分钟。系统提示改变也可能导致未命中,而看板无法看到这一点。- 工作階段开始或恢复时,
Tk从 0 开始;恢复的工作階段之前使用的令牌不可用。Co从工作階段费用开始计算。 Td统计TaskCreate/TaskUpdate/TaskList和TodoWrite。较新的模型只有在CLAUDE_CODE_ENABLE_TODO_TOOLS=1时才有这些工具(文档)。- 看板只能知道其他工作階段忙碌或空闲;无法知道它们是否「需要输入」。没有名称的工作階段会隐藏。
- 看板每 5 s 从
ListAgents工具读取工作階段列表。它的输出是给模型看的文字,不是固定格式:如果 Claude Code 更新了输出,看板会保持空白,而不是显示错误。
选项
usage-ring 有一个默认关闭的选项:
| 选项 | 含义 |
|---|---|
| limitsFile | 将工作階段和每周限制写入 $CLAUDE_CONFIG_DIR/usage-limits.json(默认 ~/.claude),供其他工具读取。 |
在 Claude Code 中运行 /plugin configure usage-ring@claude-mods 设置,或运行:
echo '{"limitsFile":"true"}' | claude plugin configure usage-ring@claude-mods --values-stdin
开发
- 每个外掛位于
plugins/<name>/:.claude-plugin/plugin.json、hooks/hooks.json、包含 hooks 的hooks/register.tsx、旁边的纯逻辑文件、types/index.d.ts(状态契约)以及tests/。 - 检查:先运行
claude plugin validate .,再运行claude plugin validate plugins/<name>和claude plugin test plugins/<name>。 - 从本地副本安装时,Claude Code 会直接读取原位置的文件:变更会在
/reload-plugins或下一次工作階段生效。 - 两个 mod 都绘制在提示列上方的同一排;每个渲染 hook 都会调用
next(e),并保留下方的内容(session-board在上方,usage-ring紧挨提示列)。
许可证
MIT,参见 LICENSE。
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add Oualid0/claude-mods claude plugin install usage-ring
原文 / README
claude-mods
Mods for the Claude Code terminal: a band of rings above the prompt that shows your limits, this chat's usage and the prompt cache, plus a board of your running Claude sessions.
Quick install
Copy this prompt into Claude Code:
Install the Claude Code plugins from https://github.com/Oualid0/claude-mods:
add the repo as a plugin marketplace, then install every plugin listed in its
.claude-plugin/marketplace.json, and tell me to run /reload-plugins when done.
Manual install
claude plugin marketplace add Oualid0/claude-mods
claude plugin install usage-ring@claude-mods
claude plugin install session-board@claude-mods
Then run /reload-plugins in Claude Code, or start a new session. From a local clone,
./install.sh does the same (it needs python3) and is safe to run again.
Update
Auto-update is off by default. Update by hand with /plugin marketplace update claude-mods
in a session, or claude plugin update usage-ring@claude-mods and
claude plugin update session-board@claude-mods in the shell. You can also turn on
Enable auto-update for the marketplace under Marketplaces in /plugin.
Mods
| Plugin | What it does |
|---|---|
| usage-ring | Two chips right above the prompt: limits and chat, with a pixel Claude beside them that hammers while a turn runs and sleeps otherwise, and the model in grey next to it, e.g. Opus 5.5 (mid) (effort low, mid, high, xhigh or max, known from the first request on). |
| session-board | A sessions chip above that while other Claude sessions on this machine are running: one row each (● running, ✓ done for 60 s after it finished), plus your own row (○ ready or ● running) marked ←. With no other session running, the board is hidden. |
What the labels mean
| Label | Chip | Meaning |
|---|---|---|
| Wk | limits | Weekly limit used, in percent. |
| Se | limits | Session limit (the 5-hour window) used, and the time until it resets: 4:50h, or 33m under an hour. Once the window is over it shows 0% 5:00h until the next reading. |
| Cx | chat | Context window used, in percent. |
| Td | chat | Todos done out of all, e.g. 3/5. Only while the chat has a todo list. |
| Tk | chat | Tokens this chat used since the session started (input, output, cache reads and writes, subagents included). Grows after every model request. |
| Co | chat | What the session cost so far, in US dollars. |
| Ca | chat | Time left on the prompt cache (33m), expired once it lapsed. |
When the terminal is narrow, the least important goes first: the model label, the words limits and chat, Ca, Co, Tk, Td, Wk, the pixel Claude, then Cx. Se stays longest; if not even it fits, the band is hidden. Nothing is squeezed or wrapped.
Limits
- Needs a Claude Code version with mods (function-hook plugins); tested with Claude Code 2.1.288. The mod API is early access and may change between versions.
- Rings are pixel images in kitty and Ghostty; other terminals show a glyph instead.
- Rings for the week, session and context turn red from 95%, and the cache time
Caturns red in its last 3 minutes. Cais an estimate. Claude Code does not tell plugins how long the cache lives (5 minutes or 1 hour), so the band assumes 1 hour and learns from what each request read from the cache: a hit after a pause of more than 5 minutes means 1 hour, a miss means 5 minutes. A miss can also come from a changed system prompt, which the band cannot see.Tkstarts at 0 when a session starts or resumes; earlier tokens of a resumed session are not available.Costarts with the session's cost.TdcountsTaskCreate/TaskUpdate/TaskListandTodoWrite. Newer models only have these tools withCLAUDE_CODE_ENABLE_TODO_TOOLS=1(docs).- The board knows other sessions only as busy or idle; "needs input" is not available. Sessions without a name are hidden.
- The board reads the session list from the
ListAgentstool every 5 s. Its output is text for the model, not a fixed format: if a Claude Code update changes it, the board stays empty instead of showing an error.
Options
usage-ring has one option, off by default:
| Option | Meaning |
|---|---|
| limitsFile | Write the session and weekly limits to $CLAUDE_CONFIG_DIR/usage-limits.json (default ~/.claude) for other tools to read. |
Set it with /plugin configure usage-ring@claude-mods in Claude Code, or:
echo '{"limitsFile":"true"}' | claude plugin configure usage-ring@claude-mods --values-stdin
Development
- Each plugin lives in
plugins/<name>/:.claude-plugin/plugin.json,hooks/hooks.json,hooks/register.tsxwith the hooks, pure logic in files beside it,types/index.d.ts(the state contract) andtests/. - Check:
claude plugin validate ., thenclaude plugin validate plugins/<name>andclaude plugin test plugins/<name>. - Installed from a local clone, Claude Code reads the files in place: changes apply with
/reload-pluginsor the next session. - Both mods draw into the same band above the prompt; each render hook calls
next(e)and keeps what is beneath (session-boardon top,usage-ringnext to the prompt).
License
MIT, see LICENSE.

