Claude Code usage
Harness Claude Code Usage Repro
Repro: @ai-sdk/harness-claude-code finish-step reports the whole turn's cumulative usage on the last step, not that step's own
Install
git clone https://github.com/mattpocock/harness-claude-code-usage-repro.gitFrom the README
@ai-sdk/harness-claude-code: last-step finish-step usage is the whole turn's cumulative total, not that step's own usage Minimal reproduction. npm install && npm run repro — no API key needed, it drives the package's own bridge event-processing code against a synthetic (but protocol-accurate) Claude Code CLI stream. The bug On any turn with two or more model calls (i.e. any turn with at least one tool round trip before the final answer — subagents not required), the finish-step part emitted for the last step reports the whole turn's cumulative usage (every step summed) instead of that step's own usage. Concretely, in packages/harness-claude-code/src/bridge/index.ts, on the CLI's turn-ending result message: streamEventState.pendingStepUsage is already sitting there with the right value — the final step's own assistant message set it correctly (see create-emit-stream-event.ts). But a text-only final response never runs through closeStepIfReady() (that only fires from tool-result handling or finishApprovalStep), so the step is still open when result arrives — and harnessUsage (the cumulative total) wins over pendingStepUsage (the correct, final-step-only value) because of the ?? precedence. Expected vs. actual Given a turn with: - step 1 (a Bash tool call): 1000 input / 50 output tokens - step 2 (the final text answer): 1800 input / 70 output tokens *of its own* - CLI's result.usage (cumulative): 2800 input / 120 output tokens Why it matters Anything consuming finish-step/finish to answer "how many tokens did the model just use" — most obviously, a live "how full is the context window right now" indicator — overcounts by the sum of every prior step in the turn, on every ordinary multi-tool-call turn. It's easy to miss in testing because a single-model-call turn…
Details
- Repository
- mattpocock/harness-claude-code-usage-repro
- Language
- TypeScript
- Last updated
- 19 August 2026
FAQ
What is Harness Claude Code Usage Repro?
Repro: @ai-sdk/harness-claude-code finish-step reports the whole turn's cumulative usage on the last step, not that step's own It is a usage for Claude Code, from mattpocock/harness-claude-code-usage-repro on GitHub.
How do I install Harness Claude Code Usage Repro?
Clone mattpocock/harness-claude-code-usage-repro from GitHub and follow the setup steps in its README.
Is Harness Claude Code Usage Repro popular?
mattpocock/harness-claude-code-usage-repro has 36 GitHub stars and 7 forks. It was last updated on 19 August 2026.
More usage & cost trackers
Claude Governance
36datallmhub/claude-governance
Claude Code governance templates by tech stack : CLAUDE.md, scoped rules, architecture docs, cost control & dev-level adaptation
Claudetuner
35chaehyun2/claudetuner
Know when you'll hit your Claude, ChatGPT & Gemini usage limits — live 5h/weekly gauges, reset forecasts, and the usage history they don't show you. Covers Claude Code via the shared subscription pool. Chrome extension + dashboard, MIT.
Claude Code Workarounds
43phase3dev/claude-code-workarounds
Unofficial community workarounds for Claude Code (empty thinking summaries; missing context-usage icon; no copy/paste of markdown).
Caprock
41dspv/caprock
Agentic development environment: run Claude Code, Codex, OpenCode and Gemini CLI side by side, and follow every PR from agent to release with its cost. Desktop app for macOS, Windows and Linux. Local, free.
Ccclub
37mazzzystar/ccclub
Know how much Claude Code your friends are burning through. Create a group, share a code, compare usage.
Cctray
41goniszewski/cctray
macOS menu bar app for monitoring Claude Code usage
Browse the most popular Claude Code mods, all usage & cost trackers, or the skills and MCP server directories.