Show HN: CodeBurn – Analyze Claude Code token usage by task
TL;DR Highlight
An open-source tool that visualizes where and how much tokens are consumed in AI coding tools with a terminal dashboard, operating by reading only local session files without the need for separate API keys or proxies.
Who Should Read
Developers who use AI coding tools such as Claude Code, Cursor, and Codex daily and want to understand their costs and identify tasks that consume a lot of tokens.
Core Mechanics
- CodeBurn shows token usage for major AI coding tools like Claude Code, OpenAI Codex, Cursor, OpenCode, Pi, and GitHub Copilot, categorized by task type, tool, model, MCP server, and project.
- Its operation is unique: it doesn't require any wrappers, proxies, or API keys, and directly analyzes session files stored on disk by each tool. Claude Code uses paths like ~/.claude/projects/, and Codex uses ~/.codex/sessions/.
- It tracks the 'one-shot success rate' for each task type, allowing you to see which tasks are completed on the first attempt and which ones waste tokens with edit/test/fix retries.
- It's an interactive TUI (Terminal UI) dashboard that runs in the terminal, built on Ink (a terminal React framework), and supports gradient charts, responsive panels, and keyboard navigation.
- It supports various time ranges such as today, 7 days, 30 days, monthly, and all time, and also features CSV/JSON export, a macOS SwiftBar menu bar widget, and auto-refresh functionality.
- Price information is automatically cached from LiteLLM, allowing you to calculate costs for all supported models without separate configuration.
- Installation is as simple as `npm install -g codeburn`, and you can run it directly with `npx codeburn` if you have Node.js 20+. Cursor/OpenCode automatically install better-sqlite3 to read SQLite files.
- The creator revealed that they were spending about $1,400 per week on Claude Code and wanted to see where the tokens were being consumed.
Evidence
- Regarding the creator's mention of spending $1,400 per week on Claude Code, one comment stated that a $200/month plan was sufficient to run 5 agents simultaneously on a 300k LoC codebase without ever hitting the rate limit, suggesting that a flat-rate plan eliminates cost concerns compared to pay-as-you-go.
- Claudoscope (github.com/cordwainersmith/Claudoscope) and ClaudeRank (clauderank.com) were mentioned in the comments as tools with similar purposes, and commenters expressed a preference for CodeBurn's approach.
- A compatibility issue with Cursor Agent was reported, where the tool fails to recognize data if Cursor stores it in the ~/.cursor path.
- An interesting fact was shared in the comments about the terminal UI being built with Ink (React for terminals), noting that 'Claude Code itself is also made with Ink'.
- A comment suggested adding a feature to detect cost inefficiencies and propose improvements, and the creator responded positively.
How to Apply
- If you use Claude Code or Cursor daily and your bill at the end of the month is higher than expected, you can immediately run `npx codeburn` to see which projects and task types are consuming the most tokens.
- By identifying task types with low one-shot success rates, you can improve the prompts or task decomposition methods to reduce token waste from retries.
- If you're deploying AI coding tools across a team and need to justify costs, you can extract data with `codeburn report --format json` to create team- and project-based cost reports.
- If you're on macOS and want to continuously monitor token usage, you can connect it to a SwiftBar menu bar widget to view the status without opening a separate dashboard.
Code Example
snippet
# Installation
npm install -g codeburn
# Run directly without installation
npx codeburn
# Basic interactive dashboard (last 7 days)
codeburn
# Today's usage
codeburn today
# This month's usage
codeburn month
# Recent 30-day rolling window
codeburn report -p 30days
# All time
codeburn report -p all
# Output in JSON format
codeburn report --format json
# Auto-refresh every 60 seconds
codeburn report --refresh 60
# One-line summary (today + this month)
codeburn status
# Export to CSV (today/7 days/30 days)
codeburn export
# Export to JSON
codeburn export -f jsonTerminology
TUIShort for Terminal UI, it refers to an interactive screen that can be manipulated with a mouse/keyboard within a terminal (command-line window) instead of a web browser or GUI app.
InkA Node.js library that allows you to create terminal UIs using React syntax. Claude Code itself is built with it.
MCP serverShort for Model Context Protocol server, it's a server component that enables AI models to connect to external tools or data sources in a standardized way.
one-shot success rateThe percentage of tasks completed on the first attempt without modification when given to an AI. A lower rate indicates more token waste due to retries (edit/fix).
LiteLLMAn open-source library that allows you to use over 100 LLM APIs with a unified interface, and also provides model pricing information.
better-sqlite3A library that allows you to synchronously read and write SQLite database files in Node.js. Cursor/OpenCode store session data in SQLite, so this is required.