NotRedFox/NotRedFoxs-Claude-skills/tree/main/mods/token-meter
token-meter
在状态行显示实时 token 吞吐量(tok/s、tok/min、tok/hr)的 Claude Code mod,只统计输出 token,并在回复仍在流式传输时提供经过学习的实时估算。
关于这个 mod
Token Meter 是 Claude Code mod(v0.2.0),会在状态行显示 Claude 的输出速度:当前回复速度(tok/s;流式传输期间以 ~ 估算,回复结束后显示精确值)、最近 60 秒写入的 token 数,以及最近 1 小时写入的 token 数。它只统计输出 token,包括思考和工具调用,不统计输入。
实时估算会在回复流式传输时统计字符数,以每个 token 3 个字符为起点,并从本次会话中已完成的回复学习真实比例;包含隐藏思考的回复会跳过实时数值,并在结尾显示精确值。与 API 自身总数进行的测试在所有运行中都完全匹配,实时 ~ 估算与精确速度的偏差保持在约 15% 以内;6 个自动化测试覆盖精确速度、实时估算、比例学习、隐藏思考、每分钟窗口以及清除状态行(使用 claude plugin test mods/token-meter 运行)。
通过 claude plugin marketplace add NotRedFox/NotRedFoxs-Claude-skills,然后执行 claude plugin install token-meter@notredfox 安装;也可以在会话中使用 /plugin 命令,之后执行 /reload-plugins。它会显示在终端和 Claude Desktop Code 标签页中,但不会显示在 VS Code 聊天面板或 claude -p 中。需要 Claude Code v2.1.287 或更高版本。它只读取回复和时钟,并写入状态行。
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add NotRedFox/NotRedFoxs-Claude-skills claude plugin install token-meter
原文 / README
Token Meter
Version 0.2.0. See CHANGELOG.md.
A Claude Code mod that shows how fast Claude is writing, live, in the status line:
~95 tok/s | 1.2k tok/min | 8.4k tok/hr
- tok/s: speed of the current reply, timed from when the request is sent. While Claude is still writing it starts with
~, an estimate from the text so far. When the reply ends it switches to the exact number from the API. - tok/min: tokens Claude wrote in the last 60 seconds.
- tok/hr: tokens Claude wrote in the last hour.
It counts output tokens only (what Claude writes, including thinking and tool calls), not what it reads.
What's a mod?
A mod is a plugin with code that runs inside Claude Code, so it can draw in the interface and react to events like tool calls and replies. Skills are instructions Claude reads; mods change Claude Code itself. They need Claude Code v2.1.287 or later. See Anthropic's mods overview.
How the live estimate works
The API only reports the token count when a reply ends, so while Claude writes, the meter counts characters instead. It starts at 3 characters per token, measured on Claude's replies, then learns the real ratio from each finished reply in your session. When Claude's thinking is hidden it costs tokens but shows no text, so the meter skips the live figure for that reply and shows the exact one when it ends.
Tested
Installed from this repo's marketplace and run in real sessions of three replies each (a story, a command, a story, a command, a story):
| | Result |
|---|---|
| Exact counts | Matched the API's own totals in every run (for example 1,462, 1,567 and 1,471 tokens) |
| Live ~ estimate against the exact speed | Within about 15%: 73 vs 83, 77 vs 90, 84 vs 93, 92 vs 86, 90 vs 80, 104 vs 94 tok/s |
| Before the 0.2.0 fixes | 2.5k tok/s on replies that thought first, and live estimates 30 to 40% low |
6 automated tests cover the exact speed, the live estimate, learning the ratio, hidden thinking, the per-minute window and clearing the status line. Run them with claude plugin test mods/token-meter.
The test sessions ran headless, where the meter writes to the debug log instead of a status line. I couldn't open an interactive terminal on the test machine, so I haven't seen it drawn on screen myself.
Install
In your terminal:
claude plugin marketplace add NotRedFox/NotRedFoxs-Claude-skills
claude plugin install token-meter@notredfox
Or inside a Claude Code session, /plugin marketplace add NotRedFox/NotRedFoxs-Claude-skills then /plugin install token-meter@notredfox, then /reload-plugins.
To check what it does before installing, clone this repo and run claude plugin validate mods/token-meter. It only reads replies and the clock and writes to the status line.
Where it shows
The terminal and the Code tab of the Claude Desktop app. It runs but shows nothing in the VS Code chat panel and claude -p.
To update it: claude plugin update token-meter@notredfox. To remove it: claude plugin uninstall token-meter@notredfox.
