bugyal

Token Autopsy — AI skill for Claude Code

AI community

Token autopsy for agent fleets: ingest Claude Code / Codex / Cursor transcripts, emit per-behavior cost reports (file re-reads, retry storms, tool-result bloat, cache hit-rate).

How to install Token Autopsy

This entry records only its repository, not the path inside it, so there is no exact command to give. Open bugyal/token-autopsy and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Token Autopsy does

Token autopsy for agent fleets: ingest Claude Code / Codex / Cursor transcripts, emit per-behavior cost reports (file re-reads, retry storms, tool-result bloat, cache hit-rate). One binary, zero LLM calls.

Alternatives in AI

  • Open Multi Agent — TypeScript multi-agent orchestration engine — one runTeam() call from goal to result 5.8k ★
  • Wiki Ingest — Ingest a source document into the LLM Wiki 2.3k ★
  • Mancode — AI coding agent harness 358 ★

README

token-autopsy

[![ci](https://github.com/bugyal/token-autopsy/actions/workflows/ci.yml/badge.svg)](https://github.com/bugyal/token-autopsy/actions/workflows/ci.yml) [![release](https://img.shields.io/github/v/release/bugyal/token-autopsy)](https://github.com/bugyal/token-autopsy/releases/latest) [![go reference](https://pkg.go.dev/badge/github.com/bugyal/token-autopsy.svg)](https://pkg.go.dev/github.com/bugyal/token-autopsy)

**token-autopsy is a per-behavior cost autopsy for agent session transcripts.**

Why

Agent fleets (Claude Code, Codex, Cursor) burn tokens in ways the invoice never explains. Total spend per day is easy to get; *which behaviors* drove that spend is not. Teams end up tuning prompts blind while the actual waste — re-reading the same file nine times, retrying a failing command in a tight loop, pasting 40 MB of logs into context — goes unmeasured.

token-autopsy ingests a week of session transcripts and attributes token cost to the behaviors that caused it, so you can fix the workflow instead of just paying for it.

What it does

It walks a directory of `.jsonl` session transcripts (Claude Code format: one JSON object per line with `timestamp`, `message`, `tool_calls`; Codex/Cursor flat records tolerated), normalizes every message and tool call into a single event stream, detects cost-driving behaviors, and prints a table sorted by estimated token cost:

Behavior What it detects Attributed cost
re-reads Same file_path in multiple Read/Glob calls within one session Every read after the first
retry-storms Identical tool call (same tool + args) repeated >2× in a row Repeats beyond the threshold
tool-result-bloat Tool result chars / call content chars ≥ 3.0 (flag with --bloat-ratio) Result volume above the threshold
cache hit-rate Sessions carrying cache_read_input_tokens / cache_creation_input_tokens metadata Informational line under the table

Token counts come from tr