Skip to Content

How do I find how much of each prompt came from cache in Claude Code?

Rius records cache reads and writes on the span for each Claude Code model call, so you find them by opening the session in the trace list and looking at its model-call spans. Filter the Spans tab to LLM spans to see every call in a session, or filter on the cache attribute to find the calls that read from cache. Cache tokens are recorded even when a folder sends structure only.

How it works

The Claude Code plugin turns one Claude Code session into one trace. Each model call becomes its own span, and that span records the model, input and output tokens, cache reads and cache writes. Subagents get their own model-call spans with their own tokens, so a subagent’s cache use shows separately from the main session’s.

The cache counts are stored as these span attributes:

  • gen_ai.usage.cache_read.input_tokens: tokens read from cache.
  • gen_ai.usage.cache_write.input_tokens: tokens written to cache.

Rius prices cache reads and writes at their own rates, so the cost on a call already reflects them. Costs are list-price estimates in US dollars. On a Claude Pro or Max subscription, the cost measures usage and is not what you pay.

The cache counts are not content, so a folder enabled with /rius:enable-here (structure only) records them as well as one enabled with /rius:enable-content-here.

Set it up

  1. Install the plugin, sign in with /rius:login, and enable the folder you work in. The Claude Code plugin page covers sign-in and folder rules in full.

    claude plugin marketplace add glassflow/rius-coding-agents && claude plugin install rius@rius-coding-agents
    /rius:enable-here
  2. Work in Claude Code as usual. Open the trace list in the console. The session appears while it runs, and the Sent by column names the owner of the key, so click your name to see only your sessions. A structure-only session is named claude-code session. With content on, the trace carries the session’s name.

  3. Open the session. The waterfall shows every turn and model call in order, with token counts inline on each model call. Select a model call to open its detail panel.

  4. Open the Raw tab to see the span exactly as ingested, including the cache read and cache write attributes. Use the menu on an attribute to pick Filter traces by this.

  5. To compare calls across sessions, go to the Spans tab and open the All kinds menu. Pick LLM to list only model calls. Click the Tokens or Cost header to sort. Pasting a session ID in the search box lists every span in that session.

  6. To find only the calls that used cache, click Add filter, pick gen_ai.usage.cache_read.input_tokens as the field, and choose the operator exists. Each attribute shows how many spans carry it in the current window. For comparisons such as greater than, a workspace admin declares the attribute with a number type first. Until then it is filtered as text.

  7. To see where prompts grow, open a session with several model calls. A strip above the tree plots input tokens per call in order, and clicking a bar selects that call.

Filters live in the URL, so you can copy a filtered list to a teammate. Because the plugin also connects the Rius MCP server, you can ask Claude from the terminal which sessions cost the most and what the tokens went on. Sign in once with /mcp and pick rius.

What you get

  • The cache read and cache write counts for every model call in a session, next to its input and output tokens and its cost.
  • A list of LLM spans across all your sessions, sortable by tokens and cost, that you can narrow with a filter on the cache attribute.
  • Separate figures for subagents, which can account for more than half of all tokens in long sessions.
  • The context growth strip, which shows which call’s input jumped.
  • A way to share the finding: Share on the trace list creates a read-only link with metadata only, never span content.

For team-wide views, see Track Claude Code usage and cost across a team. The wider setup for other agents is under Coding agents.

When something else fits

  • Rius shows the cache read and write counts as recorded on each span. If you want one cache percentage per prompt, read the counts from the span and work it out yourself.
  • To see exactly what changed in a prompt between two calls, turn content on for the folder with /rius:enable-content-here, then use Since previous llm call on the span’s Input / Output tab.
  • A session that is still running appears in the trace list, but the Users and Agents pages count it only after it ends.

Still stuck? Get help

Last updated on