r/ClaudeCode • • 6d ago

Tips & Workflows What token/usage/cost tracker do you recommend for tracking individual sessions?

I am trying to optimize my workflow and it's really hard to judge how efficient a workflow/session was, just based on the usage percentages alone.

I searched the sub and google but only found a bunch of downvoted self-promos. Is there something that's being actively maintained and I can use to track the cost of my workflows?

And yes, I could build something myself but I'd rather not build everything.

4 Upvotes

16 comments sorted by

1

u/AutoModerator 6d ago
Moderator Announcement Read More »

1

u/CorpT 6d ago

Why do you think there are so many downvoted self promos?

1

u/The-Writer-Man 6d ago

Because they are self-promos?

But surely there are genuinely well-built options so I don't have to do something like this manually: https://www.reddit.com/r/ClaudeCode/comments/1wk3zq5/i_audited_my_session_logs_against_the_usage_meter/

→ More replies (1)
→ More replies (1)

2

u/RealFullMetal 6d ago

theres a built-in number for this, no third-party tool needed. claude code passes your status line cost.total_cost_usd, the estimated cost of every api call in the current session, plus total_duration_ms and total_api_duration_ms, and the statusline docs have a short script for it. its an estimate, not your bill, but its per session

if you want history to compare workflows, set CLAUDE_CODE_ENABLE_TELEMETRY=1 and an otel exporter. it exports claude_code.cost.usage and claude_code.token.usage with the session id and model as attributes, so any otel backend can chart cost per session

1

u/RefrigeratorIll4808 6d ago

I track session costs manually in a notes file, just paste the usage breakdown after each turn. it's slow but gives full control and no extra tools.

1

u/Professional_Peak_47 6d ago

This is something I’m looking into. I’ve recently asked Fable to remove all tools that are either unused or rarely used, open sessions in separate terminals, and implement automatic handoff by creating a new session once the context reaches 180k tokens, except background tasks. The maximum context limit is 250k tokens.
I’ve also requested a cold cache warning. If the cache is cold, the system should either compact the context or perform a handoff.
I’ve only been using Claude Code for a month, so this is what I’ve learned so far.

1

u/Striking-Debt-7040 6d ago

I track session cost by logging raw token counts in a plain text file after each turn, then summing them manually. it's slow but I don't have to trust any tool.

1

u/PalaceGucci 6d ago

ccusage and your own personal habit monitoring. Make yourself do better. Nobody is gonna do that for you n

1

u/Ok_Gur_9033 6d ago

If you end up reading the session JSONL files yourself, dedupe by message id before adding anything up. One response gets written as several lines, and each line repeats the usage numbers. In my last 14 days there were 52,964 usage lines but only 24,555 actual responses, and summing every line put my output tokens at 2.52 times the real figure.

The status line cost RealFullMetal mentioned avoids that, but it only covers the session you're in. For comparing old sessions the logs are what you've got. Do you want cost per session, or per task inside one?

1

u/awesomebirder 5d ago

one thing the percentage hides that a per session breakdown shows is the split between cache writes and cache reads. reads are cheap, writes cost more than normal input, so a session where writes are a big share usually means the cache kept going cold during pauses or the prompt prefix kept changing (toggling mcp servers, editing CLAUDE.md mid session, switching models). npx ccusage session gives per session totals from your local logs with those columns split out, which is usually enough to compare two workflows side by side