Track token usage with CodeBurn
Full Lesson Reference
You've trimmed overhead, learned the 50% rule, installed RTK + Caveman, and built habits to keep sessions clean. Now measure all of it.
CodeBurn is a free local CLI that reads Claude Code's session logs and tells you exactly where your tokens went - by task, model, project, and tool. No account, no telemetry, runs entirely on your machine. One terminal command and you can see a week's worth of work broken down to the dollar.
This lesson is the verification layer for everything else in Module 13. The levers from Lesson 4 are only valuable if you can see them working - CodeBurn is how.
Why measure
You can install RTK + Caveman + switch to Sonnet and feel cheaper. Feeling cheaper isn't proof. CodeBurn turns gut feel into a number.
- Confirms your Opus/Sonnet split is actually happening - not drifting back to Opus by default
- Shows which projects burn the most tokens - so you know where the next 10 minutes of tightening pays back hardest
- Surfaces token-waste patterns you'd never spot manually - large file reads, repeated MCP calls, runaway sessions
- Sets a baseline before changes, then a number after - you can prove the trim worked
Install
CodeBurn installs once globally via npm. You need Node.js on your machine - if you installed Claude Code via npm, you already have it.
Open your terminal before you run claude and tell it
terminalnpm install -g codeburn
Verify it's working
codeburn --version
That's the entire setup. No API keys, no login, no config file. CodeBurn reads the JSONL transcripts Claude Code already writes to ~/.claude/projects/ on your machine.
The 5 commands you'll actually use
codeburn status
The fastest check. Compact view of today + this month in one screen.
codeburn status
Run it at the end of a session to see what you spent. Run it Monday morning to see last week's total. 5 seconds. Zero ceremony.
codeburn report
The interactive dashboard. Breakdowns by task, model, project, and tool. Navigate with arrow keys.
codeburn report Use this monthly. Look for the projects that are eating disproportionate tokens vs the value coming out. That's where the next optimisation pass lives.
codeburn optimize
The single most useful command for cutting waste. CodeBurn scans your session logs, surfaces the biggest token-waste patterns, and tells you the specific fix.
codeburn optimize
Findings look like: "You re-read the same 30K-token file 14 times this week - cache it once via /wrapup memory." Each finding comes with the exact prompt or workflow change that fix es it.
codeburn models
Per-model token + cost table. Shows how much of your spend is Opus vs Sonnet vs Haiku.
codeburn models
This is the audit trail for Lever 1 from Lesson 4. If you set out to default Sonnet + escalate to Opus, the table tells you whether you actually did it. Most people find their first audit shows 80%+ Opus - the habit is invisible until CodeBurn surfaces it.
codeburn export
Dump everything to CSV or JSON. Useful when you want to track trends over months or share a summary.
codeburn export --format csv > codeburn-date +%Y-%m-%d.csv
Drop the file into Sheets or hand it to Claude with a prompt like "Spot the top 3 token-waste patterns in this export and tell me what to change."
How to use CodeBurn in your weekly routine
Once a week (Monday morning works well)
- Run codeburn status - see last week's spend at a glance
- Run codeburn optimize - read the top 3 findings
- Apply the fix es that take under 10 minutes
- Run codeburn models if anything feels off - confirm your Opus/Sonnet split is what you intended
That's it. 10 minutes a week. Compounds across the year into thousands of dollars saved on token spend - and faster sessions because every fix also speeds Claude up.
What to look for in your first audit
When you run CodeBurn for the first time, these are the patterns that usually show up
-
and what each one means.
-
One project burning 60%+ of your tokens - the workflow for that project needs a CLAUDE.md trim or a database move. Big payback if you fix it.
-
90% Opus spend - the Sonnet habit from Lesson 4 hasn't stuck yet. Type
/model at the start of execution work.
- Repeated large file reads - same PDF or transcript loaded 5+ times. Cache the summary in memory once, reference it after.
- MCP tools dominating session cost - too many MCPs connected, or one MCP returning oversized responses. Audit which ones earn their context (Module 12).
- Sessions running 3+ hours - context filled past the 50% rule from Lesson 3. Shorter sessions + /wrapup + restart cycle.
Pair CodeBurn with the rest of Module 13
CodeBurn is diagnosis, not treatment. It tells you what to fix - the fix es themselves come from earlier lessons.
- CodeBurn shows high baseline - Lesson 2 (Trimming overhead) is your fix
- CodeBurn shows long sessions - Lesson 3 (50% rule) is your fix
- CodeBurn shows Opus dominance - Lesson 4 Lever 1 (/model switching) is your fix
- CodeBurn shows verbose output - Lesson 4 Levers 2 + 3 (RTK + Caveman) are your fix
- CodeBurn shows runaway parallel sessions - Lesson 5 (Multi-session + RAM) is your fix
Diagnose with CodeBurn. Treat with the lever the diagnosis points at.
Power-user tips
- Set a baseline this week - run codeburn status today, screenshot it, then revisit in 30 days to see the trend
- Use codeburn menubar on macOS - installs a menu-bar app so you can glance at today's spend without opening a terminal
- Run codeburn optimize after any big workflow change - new MCP, new skill, new project. Catches regressions before they compound
- Check codeburn yield - tracks which AI spend shipped to main vs got reverted. Tells you which sessions were ROI-positive
- Pair with rtk gain - rtk gain shows what RTK saved you; codeburn shows total spend. Side-by-side = full picture
Action items
☐ Install CodeBurn (npm install -g codeburn in your terminal before you run claude)
☐ Run codeburn status - set today's number as your baseline
☐ Run codeburn report - identify the project burning the most tokens
☐ Run codeburn optimize - apply the top finding
☐ Run codeburn models - confirm your Opus/Sonnet split is what you set out to do
☐ Schedule a 10-minute Monday-morning CodeBurn review into your week
☐ Re-check baseline in 30 days - confirm the trim from Module 13 worked Module complete. Next: Module 14 - QA and verifying Claude's output.
Exercises
- Review the concepts covered in this lesson: Track token usage with CodeBurn.
- Write down your key takeaway from this lesson.
- Practice running any commands or prompts mentioned above inside your terminal.