# Claude Code Session Audit

> Find out where a Claude Code session spent its tokens: cost per subagent, model and tool, cache hits, failing retries and context growth, with ranked fixes. Read-only, nothing to install.

Claude Code Session Audit is a paid AI agent skill on Agensi by Tony Huynh, in Agents & Orchestration. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $4 (one-time purchase)
- Creator: [Tony Huynh](https://www.agensi.io/creators/toni-h)
- Category: [Agents & Orchestration](https://www.agensi.io/skills/agents-orchestration)
- Version: 1.1
- Last updated: 2026-11-24
- Security: scan passed (2026-11-24); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/claude-code-session-audit
- Tags: ai-agents, llm-ops, claude-code, cost, tokens, audit, subagents

## About this skill

Find out where a Claude Code session spent its tokens.

Your agent runs a small read-only script over the transcripts Claude Code already keeps on your machine and returns one report: tokens and API-equivalent cost per subagent, model and tool, cache hit rate, repeated failing tool calls, context growth and compactions, plus ranked fixes, each tied to the number behind it.

- **Nothing to install:** Python 3 standard library only, no network, writes no files.
- **Private by default:** the report holds counts, names and ids, never your prompts or tool output.
- **Any scope:** the last session of a project, a specific session, or every session since a date.

**Good questions to ask your agent**
- "Where did my tokens go in the last session?"
- "Which subagent burned the most?"
- "Why was this session so expensive, and what should I change?"
- "Is my cache working? Did the context get too big?"

**Notes**
- Cost is an estimate at public API list prices. On a subscription plan it shows where usage went, not what you were billed.
- Numbers come from local transcripts only. Background calls Claude Code does not write to transcripts (session titles, prompt suggestions) are not counted.

## Requires

- Python 3.9+
- Claude Code

## Known limitations

Claude Code only. Cost is an estimate at public API list prices, not a bill. Background calls missing from transcripts (session titles, prompt suggestions) are not counted. The context window size is assumed from the model family. Needs Python 3.9+.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Claude Code Session Audit skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What specific types of cost inefficiencies can this skill detect?

Seven ranked checks, each with its threshold: a cache hit ratio below 60 %, one subagent using more than 30 % of the session's tokens, the same tool call failing 3 or more times, the main prompt above 80 % of the context window, a mean main-thread prompt of 150k tokens or more over 30+ responses (the context re-read cost), a scouting subagent running on an expensive model, and 5 or more compactions. It also breaks tokens and cost down per subagent, model and tool, and shows how much text each tool added to the main context.

### Does this work with any AI agent, or is it exclusive to Claude Code?

It reads Claude Code's own transcript files, so it is built for Claude Code. Any agent that can run a Python script can run the audit, but the data it reads comes from Claude Code.

### Do I need to upload my session transcripts to a third-party service for the audit?

No. The script runs on your machine, reads the transcripts, makes no network calls and writes no files. The report holds counts, names and ids, not your prompts or tool output.

### What components are included in this skill package?

The SKILL.md instructions for your agent, one read-only Python script (standard library only) and a reference that explains every metric and recommendation rule. Reports come out as Markdown or JSON.

### How does the tool stay up to date with changing API token prices?

The script carries a price table with its as-of date, printed on every report. Skill updates refresh it, and you can pass your own prices as a JSON file with --prices.

### Are there any types of usage that the audit might miss?

Background calls that Claude Code does not write to transcripts (session titles, prompt suggestions) are not counted, so totals can sit a few percent below Anthropic's own usage figures. For every request the transcript does record, the token counts are exact.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
