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 分