Find out what's actually filling your coding agent's context window. Local analysis of Claude Code & Codex sessions.
JavaScript
1
1 commits
updated Oct 14, 2026
Find out what's actually filling your coding agent's context window.
Your agent has a 200k–1M token window. You'd think most of it is spent on your code. Run this and see what it's really spent on.
npx context-autopsy
It reads the coding-agent transcripts already on your machine (Claude Code, Codex, Cursor, OpenCode, Pi, Gemini CLI, Qwen Code, Cline, Roo Code, Kilo Code, Factory Droid, Amp and Goose) and breaks every token down by what it was for: reading code, writing code, build and test logs, wrangling Docker, cloud CLIs and env vars, failed commands, fixed overhead, and more.
Everything runs locally. Nothing is uploaded. No dependencies.
First, a card sized for one post (example output):
🩻 I autopsied my Claude Code context window.
Only 27% of it was my actual code.
🔑 It saw 23 secret keys & passwords
💥 1,204 failed commands
🔧 21% was build logs & env wrangling
🧠 Hit its context limit 87 times
1.9B tokens in 60 days
npx context-autopsy
The headline and stats are picked from whatever is most striking in your data. The card always fits in 280 characters and contains no paths, project names or commands. --share --copy puts it on your clipboard and prints a link to post it.
Below the card is the full breakdown:
WHERE YOUR CONTEXT WENT
processed* share in context
Reading code 512.3M 27.0% 9.1M ██████████████████████████████
Fixed overhead 398.4M 21.0% 5.2M ███████████████████▍··········
Build, test & run output 246.6M 13.0% 4.4M █████████████▏················
Reasoning 227.6M 12.0% 4.6M ████████▍·····················
Environment & infrastructure 151.8M 8.0% 2.7M ████████▏·····················
Git & version control 132.8M 7.0% 2.4M ███████▍······················
...
THE HEADLINES
▸ 21% of everything your agents processed was build output and environment wrangling.
▸ 1,204 failed commands and tool calls (7% of all tool calls), 64.0M tokens of error output processed.
▸ 23 credentials passed through the model's context (9 Database URL with password, 6 AWS access key, …).
▸ Most expensive single output: a 14k-token `pnpm install` result, re-sent 212 times = 3.0M tokens.
▸ 41 sessions filled the window and compacted (87 times).
Also shown:
An LLM is stateless. On every turn the whole context is sent again, so a 15k-token npm install log that lands early in a 200-turn session isn't 15k tokens. It's 15k tokens × every remaining turn, until the session compacts.
context-autopsy follows each piece of content from the turn it entered the context to the turn it left. It reports two numbers:
Estimates are calibrated against the real token counts the API reported in each transcript, so the totals add up to what was actually processed. The hidden system prompt and tool schemas are inferred from the size of the first request.
| Group | What lands here |
|---|---|
| Fixed overhead | System prompt, tool and MCP schemas, injected instructions (CLAUDE.md, AGENTS.md), reminders, compaction summaries |
| Conversation | Your prompts and the model's replies |
| Reasoning | Thinking and reasoning blocks |
| Reading code | File reads, grep/rg/find/ls, search results |
| Writing code | Edits, patches, new files |
| Build, test & run output | npm/pnpm/pip/cargo/go/dotnet installs and builds, test runners, linters, dev servers |
| Environment & infrastructure | docker, kubectl, helm, terraform, aws/gcloud/az, ssh, ports and processes, env vars, .env, Dockerfiles, CI and infra config |
| Git & version control | git, gh |
| Web & docs lookups | Web search, fetched pages, curl |
| Browser & UI checks | Playwright, browser and computer-use tools poking at the running app |
| Subagents & coordination | Spawning, messaging and waiting on other agents |
| Other tool output | MCP tools and everything else |
It also flags cross-cutting waste: failed commands, exact duplicates (the same file read twice, the same command re-run), lockfiles and build artefacts read into context, compactions, and credentials (AWS, GitHub, Stripe, OpenAI and Anthropic keys, private keys, JWTs, database URLs with passwords, *_SECRET= assignments).
Credentials are fingerprinted with a one-way hash so they can be counted. The values are never stored or printed.
npx context-autopsy [options] [transcript.jsonl | directory ...]
--agent <ids> Only these agents, comma-separated (default: all)
claude, codex, cursor, opencode, pi, gemini, qwen,
cline, roo, kilo, droid, amp, goose
--since <7d|2026-09-01> Only sessions active since this date or age
--project <text> Only sessions whose working directory contains <text>
--last <n> Only the n most recent sessions
--no-subagents Skip subagent / child-thread transcripts
--detail Show sub-categories (which tools, which commands)
--top <n> Rows in the "most expensive" table
--share Just the post-ready card, plus a link to post it
--copy Copy the card to the clipboard
--json Machine-readable output
Every agent found on your machine is read automatically.
| Agent | Where it reads from | Token usage |
|---|---|---|
| Claude Code | ~/.claude/projects (CLAUDE_CONFIG_DIR) | per request |
| Codex | ~/.codex/sessions (CODEX_HOME) | per request |
| Cursor | state.vscdb in Cursor's global storage | context snapshots only¹ |
| OpenCode | ~/.local/share/opencode (XDG_DATA_HOME, OPENCODE_DB): SQLite and older JSON storage | per request |
| Pi | ~/.pi/agent/sessions (PI_CODING_AGENT_DIR, PI_CODING_AGENT_SESSION_DIR) | per request |
| Gemini CLI | ~/.gemini/tmp/*/chats | per request |
| Qwen Code | ~/.qwen/projects (QWEN_HOME) | per request |
| Cline | tasks/ in the extension's storage³, and ~/.cline/data (SDK and CLI sessions) | per request |
| Roo Code | tasks/ in the extension's storage³ | per request |
| Kilo Code | ~/.local/share/kilo (7.x), and tasks/ in the extension's storage³ (≤5.x) | per request |
| Factory Droid | ~/.factory/sessions | per request² |
| Amp | ~/.local/share/amp/threads (AMP_DATA_DIR) | per request² |
| Goose | ~/.local/share/goose/sessions/sessions.db (GOOSE_PATH_ROOT) | per request² |
¹ Cursor doesn't store per-request usage. Sizes are calibrated from the context-window snapshot Cursor saves with each message you send.
² Droid and Amp are closed source. Their formats come from open-source parsers, not vendor code.
³ "The extension's storage" means VS Code's global storage for the extension, in VS Code, Insiders, VSCodium, Cursor, Windsurf, Trae or Kiro, including remote (~/.vscode-server) installs.
SQLite-backed agents (Cursor, OpenCode, Kilo Code 7.x, Goose) need Node 22.5 or later. On older versions of Node they're skipped. Not supported yet: Cursor's CLI (cursor-agent), which uses undocumented protobuf storage, and GitHub Copilot Chat and Aider, which don't keep tool output in a usable form.
Is your agent missing? Open an issue with where it stores sessions.
npx context-autopsy --share --copy
This prints just the card, copies it to your clipboard, and gives you a link that opens a pre-filled post.
Install it as a plugin, then ask "where is my context going?" or run /context-autopsy:
/plugin marketplace add AlistairClark7/context-autopsy
/plugin install context-autopsy@context-autopsy
Or copy skills/context-autopsy into ~/.claude/skills/. The skill runs the analysis, explains the numbers, and suggests fixes specific to what it found.
--detail shows exactly what went where. PRs that improve the rules are welcome.DEBUG=1 and open an issue.MIT
Find out what's actually filling your coding agent's context window. Local analysis of Claude Code & Codex sessions.
JavaScript
1
1 commits
updated Oct 14, 2026
Find out what's actually filling your coding agent's context window.
Your agent has a 200k–1M token window. You'd think most of it is spent on your code. Run this and see what it's really spent on.
npx context-autopsy
It reads the coding-agent transcripts already on your machine (Claude Code, Codex, Cursor, OpenCode, Pi, Gemini CLI, Qwen Code, Cline, Roo Code, Kilo Code, Factory Droid, Amp and Goose) and breaks every token down by what it was for: reading code, writing code, build and test logs, wrangling Docker, cloud CLIs and env vars, failed commands, fixed overhead, and more.
Everything runs locally. Nothing is uploaded. No dependencies.
First, a card sized for one post (example output):
🩻 I autopsied my Claude Code context window.
Only 27% of it was my actual code.
🔑 It saw 23 secret keys & passwords
💥 1,204 failed commands
🔧 21% was build logs & env wrangling
🧠 Hit its context limit 87 times
1.9B tokens in 60 days
npx context-autopsy
The headline and stats are picked from whatever is most striking in your data. The card always fits in 280 characters and contains no paths, project names or commands. --share --copy puts it on your clipboard and prints a link to post it.
Below the card is the full breakdown:
WHERE YOUR CONTEXT WENT
processed* share in context
Reading code 512.3M 27.0% 9.1M ██████████████████████████████
Fixed overhead 398.4M 21.0% 5.2M ███████████████████▍··········
Build, test & run output 246.6M 13.0% 4.4M █████████████▏················
Reasoning 227.6M 12.0% 4.6M ████████▍·····················
Environment & infrastructure 151.8M 8.0% 2.7M ████████▏·····················
Git & version control 132.8M 7.0% 2.4M ███████▍······················
...
THE HEADLINES
▸ 21% of everything your agents processed was build output and environment wrangling.
▸ 1,204 failed commands and tool calls (7% of all tool calls), 64.0M tokens of error output processed.
▸ 23 credentials passed through the model's context (9 Database URL with password, 6 AWS access key, …).
▸ Most expensive single output: a 14k-token `pnpm install` result, re-sent 212 times = 3.0M tokens.
▸ 41 sessions filled the window and compacted (87 times).
Also shown:
An LLM is stateless. On every turn the whole context is sent again, so a 15k-token npm install log that lands early in a 200-turn session isn't 15k tokens. It's 15k tokens × every remaining turn, until the session compacts.
context-autopsy follows each piece of content from the turn it entered the context to the turn it left. It reports two numbers:
Estimates are calibrated against the real token counts the API reported in each transcript, so the totals add up to what was actually processed. The hidden system prompt and tool schemas are inferred from the size of the first request.
| Group | What lands here |
|---|---|
| Fixed overhead | System prompt, tool and MCP schemas, injected instructions (CLAUDE.md, AGENTS.md), reminders, compaction summaries |
| Conversation | Your prompts and the model's replies |
| Reasoning | Thinking and reasoning blocks |
| Reading code | File reads, grep/rg/find/ls, search results |
| Writing code | Edits, patches, new files |
| Build, test & run output | npm/pnpm/pip/cargo/go/dotnet installs and builds, test runners, linters, dev servers |
| Environment & infrastructure | docker, kubectl, helm, terraform, aws/gcloud/az, ssh, ports and processes, env vars, .env, Dockerfiles, CI and infra config |
| Git & version control | git, gh |
| Web & docs lookups | Web search, fetched pages, curl |
| Browser & UI checks | Playwright, browser and computer-use tools poking at the running app |
| Subagents & coordination | Spawning, messaging and waiting on other agents |
| Other tool output | MCP tools and everything else |
It also flags cross-cutting waste: failed commands, exact duplicates (the same file read twice, the same command re-run), lockfiles and build artefacts read into context, compactions, and credentials (AWS, GitHub, Stripe, OpenAI and Anthropic keys, private keys, JWTs, database URLs with passwords, *_SECRET= assignments).
Credentials are fingerprinted with a one-way hash so they can be counted. The values are never stored or printed.
npx context-autopsy [options] [transcript.jsonl | directory ...]
--agent <ids> Only these agents, comma-separated (default: all)
claude, codex, cursor, opencode, pi, gemini, qwen,
cline, roo, kilo, droid, amp, goose
--since <7d|2026-09-01> Only sessions active since this date or age
--project <text> Only sessions whose working directory contains <text>
--last <n> Only the n most recent sessions
--no-subagents Skip subagent / child-thread transcripts
--detail Show sub-categories (which tools, which commands)
--top <n> Rows in the "most expensive" table
--share Just the post-ready card, plus a link to post it
--copy Copy the card to the clipboard
--json Machine-readable output
Every agent found on your machine is read automatically.
| Agent | Where it reads from | Token usage |
|---|---|---|
| Claude Code | ~/.claude/projects (CLAUDE_CONFIG_DIR) | per request |
| Codex | ~/.codex/sessions (CODEX_HOME) | per request |
| Cursor | state.vscdb in Cursor's global storage | context snapshots only¹ |
| OpenCode | ~/.local/share/opencode (XDG_DATA_HOME, OPENCODE_DB): SQLite and older JSON storage | per request |
| Pi | ~/.pi/agent/sessions (PI_CODING_AGENT_DIR, PI_CODING_AGENT_SESSION_DIR) | per request |
| Gemini CLI | ~/.gemini/tmp/*/chats | per request |
| Qwen Code | ~/.qwen/projects (QWEN_HOME) | per request |
| Cline | tasks/ in the extension's storage³, and ~/.cline/data (SDK and CLI sessions) | per request |
| Roo Code | tasks/ in the extension's storage³ | per request |
| Kilo Code | ~/.local/share/kilo (7.x), and tasks/ in the extension's storage³ (≤5.x) | per request |
| Factory Droid | ~/.factory/sessions | per request² |
| Amp | ~/.local/share/amp/threads (AMP_DATA_DIR) | per request² |
| Goose | ~/.local/share/goose/sessions/sessions.db (GOOSE_PATH_ROOT) | per request² |
¹ Cursor doesn't store per-request usage. Sizes are calibrated from the context-window snapshot Cursor saves with each message you send.
² Droid and Amp are closed source. Their formats come from open-source parsers, not vendor code.
³ "The extension's storage" means VS Code's global storage for the extension, in VS Code, Insiders, VSCodium, Cursor, Windsurf, Trae or Kiro, including remote (~/.vscode-server) installs.
SQLite-backed agents (Cursor, OpenCode, Kilo Code 7.x, Goose) need Node 22.5 or later. On older versions of Node they're skipped. Not supported yet: Cursor's CLI (cursor-agent), which uses undocumented protobuf storage, and GitHub Copilot Chat and Aider, which don't keep tool output in a usable form.
Is your agent missing? Open an issue with where it stores sessions.
npx context-autopsy --share --copy
This prints just the card, copies it to your clipboard, and gives you a link that opens a pre-filled post.
Install it as a plugin, then ask "where is my context going?" or run /context-autopsy:
/plugin marketplace add AlistairClark7/context-autopsy
/plugin install context-autopsy@context-autopsy
Or copy skills/context-autopsy into ~/.claude/skills/. The skill runs the analysis, explains the numbers, and suggests fixes specific to what it found.
--detail shows exactly what went where. PRs that improve the rules are welcome.DEBUG=1 and open an issue.MIT