contextburn

ai.arsentev由 arsentev.ai 发布v0.2.1更新于 Oct 24, 2026

Run efficiency for coding agents: share of paid tokens that became output, not context re-reading.

已验证STDIO仅桌面开发者工具数据与分析

概览

AI 生成的概览

让编程助手从本地 Claude Code 记录中读取自身的 token 运行效率,显示付费上下文中转化为输出的比例。

可以做什么
该软件包附带一个无依赖的 stdio MCP 服务器,提供两个工具:run_efficiency 以结构化数据返回 token 与成本加权占比,spend_breakdown 返回完整报告。它解析机器上已有的 Claude Code 记录,按消息 id 去重使用记录,并用脚本中保存的各模型价格计算成本占比。数据不会离开本机。
适用场景
适合让助手在会话中途查看有多少付费上下文被重复读取而非转化为输出,也适合跨会话、模型和工作方式比较运行效率。主要面向已有本地记录的 Claude Code 用户。
运行要求
通过 stdio 在本地运行,例如用 uvx 从 PyPI 包 contextburn 启动。需要 Python 3,并读取 ~/.claude/projects 下的本地 Claude Code 记录。未声明需要账户、API 密钥或网络访问。可选设置包括 CONTEXTBURN_LANG、CONTEXTBURN_DAY_START、CONTEXTBURN_WARN 和 CONTEXTBURN_ALARM。
安装前请注意
它会读取本地 Claude Code 记录文件,其中可能包含对话内容,不过 README 称数据不会离开本机且没有任何网络调用。成本加权占比依赖脚本中保存的价格表,价格变化后可能过时。目前仅支持 Claude Code 记录。

安装

在 SourceWeft 中

  1. 打开 控制台中的 contextburn,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[contextburn: real output over 24 hours — useful work 0.18% of tokens, context re-reading 98.4%, cost-weighted useful work 6.7%, one useful token costs 555 paid tokens]

[DOI 10.5281/zenodo.22712985]

contextburn reads the transcripts Claude Code already writes on your machine and tells you what share of the tokens you paid for became model output — and how much was the agent re-reading context it had already sent.

Token counters answer "how much did I spend?". This answers "how much of it was work?" — a normalised share, so it can be compared across sessions, models and ways of working.

Try it

bash
cp bin/contextburn ~/bin/contextburn && chmod +x ~/bin/contextburn   # python3 only, no dependenciescontextburn detail 24

Demo

[contextburn detail 72 over the 36 experiment runs: 168 sessions, useful work 1.44% of tokens, context re-reading 94.4%, cost-weighted 28.8%]

Real output over the session logs of the 36 runs behind the U-curve report — nothing else on the machine. Video with DOI: 10.5281/zenodo.22713920. The runs themselves are open: Hugging Face (DOI 10.57967/hf/10366) · Kaggle · OSF (DOI 10.17605/OSF.IO/5QTWY).

Why two numbers

[Same 12 tasks, one long session versus twelve short, 3 runs each: token efficiency 1.11% vs 1.12%, no difference; cost-weighted efficiency 31.6% vs 24.6%, seven points apart]

  • By tokens the share barely moves. Every agent step resends the accumulated context, so re-reading dominates whatever you do — it describes the agent.
  • Cost-weighted the share does move, because cached reads are priced far below fresh input and output. It depends on how you run sessions — it describes you.

The comparison above comes from a controlled experiment with its dataset and analysis scripts: Clear Every Third Task: A Measured U-Curve in the Context Economy of Coding Agents.

How it counts

  • Reads local Claude Code transcripts (~/.claude/projects/**/*.jsonl). Nothing leaves the machine — no network calls at all.
  • Deduplicates usage records by message id and keeps the element-wise maximum. A streaming runtime writes an early snapshot and a final record for the same call: counting both double-counts it, keeping only the first halves the output.
  • Weights the cost share with per-model prices kept at the top of bin/contextburn. Update them there when they change.

Commands

commandwhat it shows
contextburnwhat is burning tokens right now
contextburn detail [hours]run efficiency, sessions, and what specifically inflated the context
contextburn windowthe current 5-hour subscription window
contextburn --jsonmachine-readable state (used by the menu-bar app)
contextburn --probe <hours>raw JSON dump of the parsed sessions
contextburn --efficiency [hours]run efficiency as JSON
contextburn mcpstart the MCP server

Configuration

settingdefaultmeaning
CONTEXTBURN_LANG or ~/.config/contextburn/langeninterface language: en or ru
CONTEXTBURN_DAY_START6hour your day starts — the daily total resets here
CONTEXTBURN_WARN30000000tokens/hour that turns the menu-bar counter yellow
CONTEXTBURN_ALARM90000000tokens/hour that turns it red

The language file exists because the menu-bar app is launched from Finder, where environment variables never reach it: echo ru > ~/.config/contextburn/lang switches both the app and the CLI.

MCP server

Let the agent read its own run efficiency mid-session. The package ships a dependency-free MCP server (stdio) with two tools: run_efficiency returns the shares as structured data, and spend_breakdown returns the full report.

bash
claude mcp add contextburn -- uvx contextburn mcp

Or install it as a Claude Code plugin, which registers the same server:

text
/plugin marketplace add arsentev-ai/contextburn/plugin install contextburn@contextburn

Editor extensions

Menu-bar app (macOS)

app/main.swift is a small status-bar app. It polls contextburn --json once a minute and shows the current burn rate with an hourly graph; click a bar to see that hour's breakdown.

bash
swiftc -O -o ContextBurn app/main.swift

Set CONTEXTBURN_BIN=/path/to/contextburn if the CLI is not in ~/bin or the usual Homebrew paths.

Limits

  • Claude Code transcripts only, for now.
  • The cost-weighted share is only as current as the price table in bin/contextburn.

Citing

Software DOI (all versions): 10.5281/zenodo.22712985. GitHub's "Cite this repository" button gives the reference; metadata is in CITATION.cff.

Author

Evgenii Arsentev — arsentev.ai · ORCID 0000-0002-9120-7298

This project was published as tokmon on its first day and renamed to avoid confusion with unrelated tools of that name; TOKMON_* environment variables still work.

License

MIT — see LICENSE.

来源:README.md,提交 2f7ac04

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.2.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分