audit-usage

A command that reconstructs token usage for a Claude Code session from local transcript files, including work done by sub-agents.

In plain words
What is it for?
Use it with a session ID to print model token counts, or list available sessions when no matching transcript is found, then compare the result with Claude Code and Dash0.
Why use it?
It gives a reference count for investigating differences between Claude Code's usage display and Dash0's recorded usage.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/dash0hq/dash0-agent-plugin/audit-usage
Clone the repo
git clone --depth 1 https://github.com/dash0hq/dash0-agent-plugin
Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 422 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00017 $0.00422
Opus 5 $0.00009 $0.00211
Sonnet 5 $0.00003 $0.00084
Haiku 4.5 $0.00002 $0.00042

Measured 3d ago against content hash ec55df80b6d9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

audit-usage scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

claude/commands/audit-usage.md · 43 lines

What it actually says

Audit Usage

Reconstructs per-model token counts for a Claude Code session — the main session plus every sub-agent it spawned — from the transcripts on disk, and reports how many spans Dash0 should hold for it. Use it when the token or cost numbers in Dash0 look wrong: it produces the ground truth to compare them against.

Steps

  1. Pick the session: $1 if the user passed one, otherwise $CLAUDE_SESSION_ID.

  2. Run:

python3 "${CLAUDE_PLUGIN_ROOT}/claude/tools/claude-code-usage-audit.py" <session-id>

If python3 is not installed, say so and stop — the script needs it. If the script reports no transcript for the session, run it with no argument to list the sessions on disk and ask the user which one they meant.

  1. Leave the script's output as it was printed — do not reformat or summarize the numbers. Repeat it verbatim if it is not already visible to the user, as in a non-interactive run. It is meant to be read side by side with the other two numbers, or pasted into a bug report.

  2. Then say what to compare it against:

    • Claude Code's own numbers: run /usage in that session.
    • Dash0: the spans whose gen_ai.conversation.id is the session id (/open-session opens that page).

    Usage or spans that appear in the audit but not in Dash0 never arrived. The sub-agent rows correspond to the invoke_agent spans.

  3. If the session audited is the current one, add that the turn in progress has not finished, so its usage and its spans are still incomplete — for a clean comparison, audit a session that has ended.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 43 lines · 17 tokens per session scan A ec55df80b6d9

Subscribe to this mod's changes

audit-usage is a command published in the GitHub repository dash0hq/dash0-agent-plugin (5 stars, last pushed yesterday), licensed Apache-2.0. It adds 17 tokens to every session and 422 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.