How do I track the cost of each session in Claude Code?
Rius records each Claude Code session as one trace, with tokens and cost on every model call, once you install the Rius plugin and run /rius:enable-here in a folder. You read the cost in the trace waterfall, per developer on the Users page, and by asking Claude from the terminal. Cost is a list-price estimate in US dollars, so on a Claude Pro or Max subscription it measures usage, not what you pay.
How it works
One Claude Code session is one trace, with the same session id throughout. If you resume a session, it continues the same trace. The trace is laid out like this:
AGENT the session
└─ CHAIN a turn: one prompt and everything it caused
└─ LLM a model call: model, input and output tokens, cache reads and writes
├─ TOOL a tool call: Bash, Read, Edit, and so on
└─ TOOL Agent: the call that started a subagent
└─ AGENT the subagent, named by its type
└─ LLM the subagent's own model calls and toolsThe span for each model call carries the model name, input and output tokens, and cache reads and writes. Rius computes the cost from those counts, so you never send a cost value. It prices tokens with LiteLLM’s public model-price catalog, with cache reads and writes at their own rates. A model that is not in the catalog gets an empty cost, not zero.
Subagents get their own spans with their own tokens and cost. That matters because in long sessions subagents can account for more than half of all tokens.
Cost is recorded in both capture modes. A folder enabled with /rius:enable-here sends structure only: the span tree, models, tokens, cost, timing, tool names and error types, with no prompts, replies, file contents or command output. You do not need to send content to track cost.
Set it up
-
Install the plugin in a terminal. The plugin needs Python 3.9 or newer on your PATH.
claude plugin marketplace add glassflow/rius-coding-agents && claude plugin install rius@rius-coding-agents -
In Claude Code, run
/rius:login. Sign in or sign up in the browser, pick a workspace, and click Connect. -
cdinto the repo you want to measure and run/rius:enable-here. Tracing is off everywhere until you do this, and only you can run the command. Start Claude Code from inside that repo, not from a parent folder. -
Run
/rius:status. The first line readsRius tracing: on, andSpans exported this sessioncounts what has been sent. -
Work as usual, then open the trace list in the console at
console.rius-glassflow.comand find the session.
The Claude Code plugin guide covers sign-in, folder rules and troubleshooting in full. To stop tracing a folder, run /rius:disable-here.
To ask about cost from the terminal, run /mcp, pick rius, and sign in with your Rius account once. This is a separate sign-in from /rius:login, which only sends traces. Then ask, for example, “Which of my Claude Code sessions in the last 24 hours cost the most, and what did the tokens go on?” or “How much did subagents cost me this week compared with the main session?”
What you get
- Per session. The trace list shows one row per session while it runs. Open it and the waterfall shows every turn, model call, tool call and subagent in order, with tokens and cost on each model call. A failed tool call is marked as an error, so you can go from an expensive session to the exact step.
- Per developer. With plugin 0.6.2 or later, each session is recorded under the email the developer signed in with. The Users page lists each developer with traces (one per session), failed traces and cost for the selected window, 7 days by default. Sort by Cost to see who drives spend. The Sent by column in the trace list names the owner of the key that sent each session.
- Per agent. The Agents page shows Claude Code as an agent named
claude-code, with its traces, errors and cost for the window, and each open session as a live instance. - By question. Claude can rank sessions by cost and split subagent spend from main-session spend through the Rius MCP server.
For a team rollout with one shared workspace, see Track Claude Code usage and cost across a team. Other agents are compared in Coding agents.
What Claude Code tracing does not report
- Cost is worked out from token counts at API rates. On a subscription plan it measures usage, not your bill.
- The Users and Agents figures count a session only once it has ended. A session that never ends cleanly, because Claude Code crashed or was killed, is never counted there. The trace list still shows it.
- Signing out while a session runs removes the key it was using, so that session stays in progress and never counts on Users or Agents.
- Sessions sent with an existing API key instead of
/rius:logincarry no developer and land in the anonymous row on Users. - Model-call durations are approximate, because a model span can include time you spent reading a permission prompt. Tool durations are exact.
When something else fits
- If you need what you actually pay on a subscription, or negotiated, batch or other discounted prices, Rius does not model that. It reports list-price estimates only.
- If you want cost for Codex (beta), the same plugin reports tokens and cost there. Cursor (beta) sessions carry no token counts or cost, because Cursor’s hooks do not report usage.