gmorubio/claude-mods/tree/main/turn-usage
关于这个 mod
每条 Claude 回复下方都有一行浅色文字,显示当前工作階段用量限制的使用比例,以及刚结束的一轮消耗的比例:
Session: 39% used · this turn: <1%
「current session」数值指 5 小时用量窗口,也就是 Claude 用量设置中称为「Current session」的同一个窗口。
按量付费(API key、Bedrock 或 Vertex)没有用量窗口,因此这一行改为按照 /cost 的统计方式,以美元显示工作階段和这一轮的费用:
Session: $1.84 · this turn: $0.12
如何读取
订阅方案中:
| 显示内容 | 含义 |
| --- | --- |
| this turn: +2% | 这一轮期间工作階段数值上升了 2 个百分点 |
| this turn: <1% | 这一轮没有让工作階段数值完整上升 1 个百分点 |
| this turn: — | 没有可比较的数值:工作階段的第一轮在任何读数到达前就结束了 |
订阅窗口(5 小时或每周窗口)用完后,仍然完成的一轮使用了额外用量,因此这一行显示该轮费用,而不是百分点:
Session: 100% used · this turn: $0.12 (extra usage)
跨过 100% 的那一轮仍以百分点计量;从下一轮开始显示费用。
按量付费和额外用量中,不足 1 美分的一轮显示 <$0.01。费用是 Claude Code 根据令牌和公开 API 价格估算的数值,无论账单使用什么货币都始终以美元显示,不是发票金额。
工作階段的第一轮之前没有读数,因为该数值只有在 API 响应中才会到达。如果 5 小时窗口正好由这一轮开始,这一轮会从 0% 开始;否则使用这一轮第一次请求附带的读数,因此只缺少那一个请求。
用量数值来自 API 的速率限制标头,它们报告完整百分点,所以一轮的比例也只能精确到这个程度:+1% 可能只是较小的一轮碰巧跨过了一个百分点。这个数值属于你的账号,因此同时运行的其他 Claude 工作階段也会计入其中。
语言
这一行使用英文;当 Claude Code 的 language 设置为西班牙语(~/.claude/settings.json 中为 "language": "spanish")时,则使用西班牙语:
Sesión: 39% usado · este turno: <1%
要求
- 桌面应用或终端中的 Claude Code,使用 Claude 订阅或按量付费。
- 带 function-hook mods 的 Claude Code 构建版本(
hooks/hooks.json中包含modules)。
安装
在 shell 中:
claude plugin marketplace add gmorubio/claude-mods
claude plugin install turn-usage@claude-mods
或者在 Claude Code 工作階段中一次执行:
/plugin install turn-usage --marketplace gmorubio/claude-mods
或者在一个工作階段中从本地 checkout 加载:
claude --plugin-dir /path/to/claude-mods/turn-usage
构建方式
hooks/register.tsx 就是整个 mod。它在一轮开始和完成时读取 5 小时窗口(没有窗口时读取工作階段费用),把回复最终文字和用量行一起保存;当桌面应用或终端绘制回复文字区块时,在结束该回复的区块下方加入这一行。
隐私
turn-usage 不发送网络请求,也不会把任何内容传到别处。参见隐私政策。
许可证
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add gmorubio/claude-mods claude plugin install turn-usage
原文 / README
turn-usage
A dim line under each Claude reply that shows how much of your current session's usage limit is used, and how much the turn that just ended spent:
Session: 39% used · this turn: <1%
The "current session" figure is the five-hour usage window, the same one Claude's usage settings call "Current session".
On pay as you go (an API key, Bedrock or Vertex) there is no usage window, so the line shows what the session and the turn cost instead, in US dollars, as /cost counts it:
Session: $1.84 · this turn: $0.12
How it reads
On a subscription:
| Shown | Meaning |
| --- | --- |
| this turn: +2% | The session figure rose 2 points during the turn |
| this turn: <1% | The turn didn't move the session figure a whole point |
| this turn: — | Nothing to compare against: the session's first turn ended before any reading came |
Once a subscription window (the five-hour or the weekly one) is used up, a turn that still completes ran on extra usage, so the line shows that turn's cost instead of its points:
Session: 100% used · this turn: $0.12 (extra usage)
The turn that crosses 100% is still measured in points; the cost shows from the next one.
On pay as you go and extra usage, a turn under a cent shows <$0.01. The cost is Claude Code's estimate from the tokens and the public API prices, always in dollars whatever your billing currency, not your invoice.
A session's first turn has no reading from before it, since the figure only arrives with an API response. If the five-hour window began with that turn, the turn started it at 0%; otherwise the reading that came with the turn's first request stands in, which leaves out only that one request.
The usage figure comes from the API's rate-limit headers, which report whole percentage points, so a turn's share is only as precise as that: a +1% can be a smaller turn that happened to cross a point. The figure is your account's, so other Claude sessions running at the same time count towards it too.
Language
The line is in English, or in Spanish when Claude Code's language setting is Spanish ("language": "spanish" in ~/.claude/settings.json):
Sesión: 39% usado · este turno: <1%
Requirements
- Claude Code in the desktop app or the terminal, on a Claude subscription or pay as you go.
- A Claude Code build with function-hook mods (
hooks/hooks.jsonwithmodules).
Install
In your shell:
claude plugin marketplace add gmorubio/claude-mods
claude plugin install turn-usage@claude-mods
Or both at once from inside a Claude Code session:
/plugin install turn-usage --marketplace gmorubio/claude-mods
Or load it from a local checkout for one session:
claude --plugin-dir /path/to/claude-mods/turn-usage
How it's built
hooks/register.tsx is the whole mod. It reads the five-hour window (or, with none, the session's cost) when a turn starts and again when it completes, keeps the reply's final text with its usage line, and when the desktop or the terminal draws a reply's text block, adds the line under the block that ends that reply.
Privacy
turn-usage makes no network requests and sends nothing anywhere. See the privacy policy.
