How to track Claude Code costs per project (before they get out of control)
If you work on one project, Claude Code costs are simple. But most developers and solopreneurs juggle multiple codebases. A client project, a side project, maybe an internal tool. Each one has different file sizes, different session patterns, and different costs.
The problem is that Claude Code gives you one total bill or one shared rate limit. You have no way to see that Project A consumed 60% of your monthly budget while Project B used 10%. Without that visibility, one runaway project silently drains the budget for everything else.
Why per-project costs vary so much
Not all projects cost the same per session. The differences can be dramatic:
Codebase size drives context costs
A small CLI tool with 20 files costs far less per session than a monorepo with 500 files. Claude Code loads CLAUDE.md, rules, and contextual files at session start. A project with extensive documentation and configuration loads more context, consuming more tokens before any work begins.
In our experience, a well-configured small project costs 5,000-10,000 tokens per session start. A large project with detailed CLAUDE.md and multiple rule files costs 20,000-40,000. Over 20 sessions a day, that is the difference between 100K and 800K tokens just for startup.
File size determines read costs
Projects with large source files (500+ lines per file) cost more per file read. A React project with component files averaging 150 lines costs far less to navigate than a legacy Python project with 1,000-line modules. Claude reads entire files, not just the parts it needs, so file size directly maps to token cost.
Task complexity affects session length
Bug fixes in familiar code take 3-5 messages. Implementing a new feature in unfamiliar code takes 15-25 messages. The longer the session, the more conversation history compounds. A project that regularly requires long exploratory sessions will cost 3-5x more per task than one where tasks are quick and well-defined.
How to measure per-project costs
Claude Code organizes session logs by project path. Each project gets its own directory under ~/.claude/projects/, making it possible to calculate costs per project. The raw data is there. The challenge is processing it.
Option 1: Manual log analysis
Navigate to ~/.claude/projects/ and look at directory sizes. A project with 500MB of session logs has consumed far more tokens than one with 50MB. This gives you a rough ratio but not dollar amounts.
For actual numbers, you would need to parse each JSONL file, sum tokens by type (input, output, cache), multiply by the per-token rate for each model used, and aggregate by project. We wrote a complete guide to counting tokens if you want to go this route. It is doable but tedious.
Option 2: Use the free analyzer with per-project uploads
Our free Claude Code cost analyzer lets you upload JSONL files and get an instant breakdown. To compare projects, run it separately for each project's log directory. You get per-session costs, model breakdowns, and cache efficiency for each project individually.
The budget tracking feature lets you set a monthly target and see how each project contributes to it. If you are on a $200/month Max plan and one project is burning through tokens 3x faster than the others, you will see it immediately.
Common patterns (and what to do about them)
The 80/20 project split
In most multi-project setups, one project consumes 60-80% of the total budget. It is usually the largest codebase or the one in active development with complex tasks. Knowing which project is the heavy hitter lets you focus optimization where it matters most.
Fix: Optimize the expensive project first. Trim its CLAUDE.md, split large files, use shorter sessions. See the five hidden cost drivers for specific optimization tactics. A 30% reduction in your most expensive project's cost is worth more than a 90% reduction in a minor project.
The maintenance tax
Projects in maintenance mode (occasional bug fixes, minor updates) still cost tokens every time you open a session. If you have five maintenance projects and each session costs 10K tokens in context loading alone, that is 50K tokens per day for projects that might only need attention once a week.
Fix: Keep minimal CLAUDE.md files for maintenance projects. Strip them down to essential information only. Detailed context should live in separate files loaded on demand, not in the startup context.
The exploration trap
New projects or unfamiliar codebases trigger exploration mode. Claude reads more files, tries more approaches, and sessions run longer. The first week on a new project can cost 5-10x more per task than the same type of task after you have established patterns and CLAUDE.md is tuned.
Fix: Front-load CLAUDE.md setup when starting a new project. Spend 30 minutes writing clear architecture notes, key file locations, and coding conventions. This investment pays back quickly in reduced exploration costs across all future sessions.
Setting project budgets
Once you have per-project cost data, you can make informed decisions:
- Client projects: Factor Claude Code costs into your billing rate. If a project costs $50/month in tokens, that is real overhead.
- Side projects: Set a token budget and track against it. If a side project is consuming more than its fair share, either optimize or accept the cost consciously.
- Team allocation: For teams sharing an API key or organization account, per-project tracking prevents one team member's workflow from draining everyone's quota.
The key principle is measurement before management. You cannot set meaningful budgets without knowing current spend. And you cannot know current spend without analyzing your session logs.
Get started in two minutes
Open your free cost analyzer, drag in the JSONL files from one project, and look at the total. Then do the same for another project. Compare the numbers. That is all it takes to start making informed decisions about where your Claude Code budget goes.
If you are managing costs across multiple projects or a team, CostPilot is built to handle this at scale with historical tracking, budget alerts, and multi-project dashboards. Join the waitlist to get early access.
You might also like
Want to build your own AI OS?
The AI OS Blueprint gives you the complete system: 53-page playbook, working skills, and a clonable repo. Starting at $47.
30-day money-back guarantee. No subscription.