r/ClaudeCode • • 8d 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.

5 Upvotes

17 comments sorted by

•

u/AutoModerator 8d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/CorpT 8d ago

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

1

u/The-Writer-Man 8d 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/

2

u/CorpT 8d ago

It's the TODO list of Claude Code. There are no good versions because anyone who would build it well wouldn't really be bothered to maintain it or likely keep using it. Token usage is not a good judge of effificnecy because tasks can vary so wildly. Have Claude review your previous tasks and usage over a week or month. A/B test it with different workflows. I changed workflows, pulled the data and realized I found a way to save a bunch of tokens. A meter would not have shown that.

-1

u/vovazk 8d ago

From my experience this subreddit will downvote almost anything lol

2

u/RealFullMetal 8d 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 8d 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 8d 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 8d 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 8d 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 8d 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 8d 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

0

u/vovazk 8d ago

Here’s how I did it; basically a separate branch to which Claude reports the usage (extracted via a script) after every turn. You can ask yours to have a look