Run this in a terminal:
ls ~/.claude/projects/
If you use Claude Code, you just found a folder for every project you've ever opened it in. Inside each one: JSONL files logging every session, every message, every token. Codex CLI does the same thing in ~/.codex/sessions/. Cursor, Windsurf, Cline, Aider, Continue: all of them keep local logs like this.
Most developers have no idea these files exist. I've been digging through them for months, and they're genuinely useful. Here's a tour.
What one log entry looks like
Each line in a Claude Code JSONL file is one event. The interesting ones are assistant messages, which carry a usage block:
{
"type": "assistant",
"timestamp": "2026-07-06T21:14:03.812Z",
"sessionId": "a1b2c3d4-...",
"cwd": "/Users/you/projects/my-app",
"message": {
"model": "claude-sonnet-5",
"usage": {
"input_tokens": 4,
"output_tokens": 512,
"cache_creation_input_tokens": 12034,
"cache_read_input_tokens": 148220
}
}
}
Five things worth noticing:
- The model is recorded per message. Not per session. If Claude Code switched models mid-session, it's in here.
-
cwdis the project directory. This is the field that makes per-project cost analysis possible. -
Cache tokens dwarf everything else. Look at that
cache_read_input_tokensnumber. In a long agentic session, cache reads are routinely 95%+ of all tokens. This is why agentic coding is affordable at all: cache reads are billed at a tenth of the input price. -
sessionIdlets you resume.claude --resume <sessionId>reopens that exact conversation. Your whole history is addressable. - It's all plaintext on your disk. More on that at the end.
Total your tokens in one line
Want your lifetime output token count? jq does it:
cat ~/.claude/projects/*/*.jsonl 2>/dev/null \
| jq -s '[.[] | .message.usage.output_tokens // 0] | add'
Swap in cache_read_input_tokens and the number gets absurd. Mine is in the billions.
Turning tokens into dollars
Multiply by published API prices and the logs become a cost report. Current Anthropic list prices per million tokens for Sonnet-class models: $3 input, $15 output, $3.75 cache write, $0.30 cache read. So a quick estimate:
cat ~/.claude/projects/*/*.jsonl 2>/dev/null | jq -s '
[.[] | .message.usage // empty] |
(([.[].input_tokens // 0] | add) * 3
+ ([.[].output_tokens // 0] | add) * 15
+ ([.[].cache_creation_input_tokens // 0] | add) * 3.75
+ ([.[].cache_read_input_tokens // 0] | add) * 0.30) / 1000000
'
That prints your all-time Claude Code usage in API-equivalent dollars (roughly, assuming Sonnet pricing for everything). If you're on a Pro or Max subscription, this is a number Anthropic never shows you. /cost only works for API users. Comparing it against your plan price answers a question a lot of people are currently arguing about without data: whether the subscription is worth it for you.
Codex logs are shaped differently (rollout files, with reasoning tokens tracked separately inside the usage object) but the same idea applies.
Where every tool keeps its logs
| Tool | Location |
|---|---|
| Claude Code | ~/.claude/projects/ |
| Codex CLI | ~/.codex/sessions/ |
| Claude Desktop | ~/Library/Application Support/Claude/ |
| Cursor | ~/.cursor/projects/ |
| Windsurf | ~/.windsurf/ |
| Cline | ~/.cline/ |
| Aider | ~/.aider/ |
| Continue | ~/.continue/sessions/ |
Formats vary (Aider logs through litellm, Continue uses plain JSON) but they all record models and token counts.
The part you should actually think about
These logs also contain your conversations: prompts, file paths, project names, fragments of your code. Locally, that's fine, arguably great. But it means two things.
First, if you back up your home directory to a cloud service, your AI pair-programming history goes with it. Worth knowing.
Second, be skeptical of any "AI usage analytics" tool that wants to upload these files to give you a dashboard. There is nothing in the analysis that requires a server. It's multiplication.
I got tired of running jq, so I built the dashboard
The one-liners above got me hooked, and then annoyed. So I built AI Usage Tracker, an open source (MIT) macOS app that parses all of these log formats, prices every provider correctly per model (including cache and reasoning tokens), and renders it as a local dashboard: daily spend, cost per project, cost per model, a peak-hours heatmap, and a session browser with resume commands. There's a toggle to view Claude and Codex separately, which settles the "which tool am I actually using more" question fast.
Fully local, no telemetry, no account. Source is here:
https://github.com/658jjh/claude-usage-tracker
Free to build from source; there's a $9 signed build if you don't want to. But honestly, even if you never touch my app, go run that ls command. Your usage history has been sitting there this whole time, and the numbers in it will probably change how you use these tools.
What's in your logs? I'm curious whether anyone else's cache-read ratio is as lopsided as mine.
Top comments (0)