{"_id":"context-autopsy","_rev":"4-04178a4b930b10566e6de92cfdcfcb7f","name":"context-autopsy","dist-tags":{"latest":"0.2.0"},"versions":{"0.0.0-stage":{"name":"context-autopsy","version":"0.0.0-stage","_id":"context-autopsy@0.0.0-stage","stub":true,"maintainers":[{"name":"alistairclark7","email":"alistairclark7@gmail.com"}],"dist":{"shasum":"521e508ec6ef2991be0cc4ca046ce121c25e7951","tarball":"https://registry.npmjs.org/context-autopsy/-/context-autopsy-0.0.0-stage.tgz","fileCount":2,"integrity":"sha512-Lt5BZXmBIQUmOCvZOj0DNZl1Vy6OVdMULJUHU6Zjj2GgU0VGf8GK35K4fOpWpitPUI0o/PEDL1gQjer2DjSe/g==","signatures":[{"sig":"MEYCIQDCnryxPs/nDkXh4ocMmRolpDztSKagMDcVMYhgb5mJ8gIhALJrFahnSwlFuEPHTEHt45v9ctdXBxjQy8a3YBkyGMKO","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":337},"_npmUser":{"name":"alistairclark7","email":"alistairclark7@gmail.com"},"description":"Temporary package placeholder for staged publishing","directories":{}},"0.1.0":{"name":"context-autopsy","version":"0.1.0","keywords":["llm","context-window","claude-code","codex","tokens","ai-agents","coding-agents","observability"],"author":{"name":"Alistair Clark"},"license":"MIT","_id":"context-autopsy@0.1.0","maintainers":[{"name":"alistairclark7","email":"alistairclark7@gmail.com"}],"homepage":"https://github.com/AlistairClark7/context-autopsy#readme","bugs":{"url":"https://github.com/AlistairClark7/context-autopsy/issues"},"bin":{"context-autopsy":"bin/context-autopsy.js"},"dist":{"shasum":"b55dd4411a4d20169ec42900aa39024220203850","tarball":"https://registry.npmjs.org/context-autopsy/-/context-autopsy-0.1.0.tgz","fileCount":14,"integrity":"sha512-57ykPAcz21wBfUKqXIavF8QiKjRR5JOp5ESaem9fleRHitBleI3M+v2lTERLG0WKRK5xB8eBN1+kLa//fjBJcA==","signatures":[{"sig":"MEUCIHQi+8FWry5MncOkATbv2T/iQbYP+JCQpYjgLVYWDAWZAiEAzU6nmaCTOwSMP+4L+fhUQIDcF9w5UApZuwLbpRLb4dk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIACHeadiPNcu+ti7qBcZ8nhSBp+SCBdyrY7vVDBWywo6AiEAuv25B4cdwGGG9UJlaHLs7E9Q9+F2aa3yW78Lyn9bmx0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":71886},"type":"module","engines":{"node":">=18.3"},"gitHead":"7fea7e422340c2eb4483671d10ca26806ec497b9","scripts":{"test":"node --test test/*.test.js"},"_npmUser":{"name":"alistairclark7","email":"alistairclark7@gmail.com"},"repository":{"url":"git+https://github.com/AlistairClark7/context-autopsy.git","type":"git"},"_npmVersion":"11.18.0","description":"Find out what's actually filling your coding agent's context window. Breaks Claude Code and Codex sessions down into code, build logs, environment wrangling, errors, overhead and leaked secrets.","directories":{},"_nodeVersion":"26.6.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/context-autopsy_0.1.0_1792006331903_0.9803237855647904","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"context-autopsy","version":"0.1.1","keywords":["llm","context-window","claude-code","codex","tokens","ai-agents","coding-agents","observability"],"author":{"name":"Alistair Clark"},"license":"MIT","_id":"context-autopsy@0.1.1","maintainers":[{"name":"alistairclark7","email":"alistairclark7@gmail.com"}],"homepage":"https://github.com/AlistairClark7/context-autopsy#readme","bugs":{"url":"https://github.com/AlistairClark7/context-autopsy/issues"},"bin":{"context-autopsy":"bin/context-autopsy.js"},"dist":{"shasum":"eafac8947c06c885178eaa57068bfb5a740033ec","tarball":"https://registry.npmjs.org/context-autopsy/-/context-autopsy-0.1.1.tgz","fileCount":17,"integrity":"sha512-8iCglNkjkO8d+aozfltWPRfQre20/0Gggzpc2RnDBHMFjD/nXCGTQmmKWIgnxNsvNMsaz1kmAokX+uLjhF0/Yw==","signatures":[{"sig":"MEUCIGTexvlM8Xu/As7FcnvLvvM2bOmJkarF0GmAnUvNjagcAiEAzjz4mVaMnLe82Kn2PTlUwu75Sd4mh1J8m4NTqQXp8nM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQCttUus5lPFxPyYoMcHB1tZoAwSJ9radIzf7b4L9s2CiwIhALHnAc83Nt0b7rMLI2FJmKcLWdlaPzq9a5JOGiMaj1I6","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":83707},"type":"module","engines":{"node":">=18.3"},"gitHead":"6fef9e366b619bceb7517fcb1d9052722e5ed669","scripts":{"test":"node --test test/*.test.js"},"_npmUser":{"name":"alistairclark7","email":"alistairclark7@gmail.com"},"repository":{"url":"git+https://github.com/AlistairClark7/context-autopsy.git","type":"git"},"_npmVersion":"11.18.0","description":"Find out what's actually filling your coding agent's context window. Breaks Claude Code and Codex sessions down into code, build logs, environment wrangling, errors, overhead and leaked secrets.","directories":{},"_nodeVersion":"26.6.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/context-autopsy_0.1.1_1792007343849_0.7298529826285749","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"_id":"context-autopsy@0.2.0","bin":{"context-autopsy":"bin/context-autopsy.js"},"bugs":{"url":"https://github.com/AlistairClark7/context-autopsy/issues"},"dist":{"shasum":"50b7fa6b272c8c6875ddaf6ec4221bca9bc24153","tarball":"https://registry.npmjs.org/context-autopsy/-/context-autopsy-0.2.0.tgz","fileCount":26,"integrity":"sha512-vxwjyjUbRaBiNxzifnfNUbs0uLFqfl/ADzGHtuvVRIC7N8MCxpWMAqgxdz4kMFMepqHxJ8US7SP9va9lC59awA==","signatures":[{"sig":"MEYCIQC/zMBZwcFiz8NQaPy3t8MMkD3qhzc7DQyikwoFSNCXewIhAOuhx1D+hXjmQswke7iS+45aC/yOvpbtGlvDvdnSk8S0","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDll8suskH0bPW2xJ1a8JfnlZx6417T9qysfIfW29lXNwIhAJoEdXhgvNMmVrJTF9U8F3T6iwdGfQYL0CmES3D1TfFx"}],"unpackedSize":138151},"name":"context-autopsy","type":"module","author":{"name":"Alistair Clark"},"engines":{"node":">=18.3"},"gitHead":"d75b8f7914856bfeb14076cd057e4e936f7f1bdc","license":"MIT","scripts":{"test":"node --test test/*.test.js"},"version":"0.2.0","_npmUser":{"name":"alistairclark7","email":"alistairclark7@gmail.com"},"homepage":"https://github.com/AlistairClark7/context-autopsy#readme","keywords":["llm","context-window","claude-code","codex","cursor","opencode","gemini-cli","cline","tokens","ai-agents","coding-agents","observability"],"repository":{"url":"git+https://github.com/AlistairClark7/context-autopsy.git","type":"git"},"_npmVersion":"11.18.0","description":"Find out what's actually filling your coding agent's context window. Breaks Claude Code, Codex, Cursor, OpenCode, Pi, Gemini CLI, Qwen Code, Cline, Roo, Kilo, Droid, Amp and Goose sessions down into code, build logs, environment wrangling, errors, overhea","directories":{},"maintainers":[{"name":"alistairclark7","email":"alistairclark7@gmail.com"}],"_nodeVersion":"26.6.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/context-autopsy_0.2.0_1792009085142_0.27723464841744083"}}},"time":{"created":"2026-10-14T19:31:15.278Z","modified":"2026-10-14T20:18:05.419Z","0.0.0-stage":"2026-10-14T19:31:15.278Z","0.1.0":"2026-10-14T19:32:11.981Z","0.1.1":"2026-10-14T19:49:03.998Z","0.2.0":"2026-10-14T20:18:05.224Z"},"bugs":{"url":"https://github.com/AlistairClark7/context-autopsy/issues"},"author":{"name":"Alistair Clark"},"license":"MIT","homepage":"https://github.com/AlistairClark7/context-autopsy#readme","keywords":["llm","context-window","claude-code","codex","cursor","opencode","gemini-cli","cline","tokens","ai-agents","coding-agents","observability"],"repository":{"url":"git+https://github.com/AlistairClark7/context-autopsy.git","type":"git"},"description":"Find out what's actually filling your coding agent's context window. Breaks Claude Code, Codex, Cursor, OpenCode, Pi, Gemini CLI, Qwen Code, Cline, Roo, Kilo, Droid, Amp and Goose sessions down into code, build logs, environment wrangling, errors, overhea","maintainers":[{"name":"alistairclark7","email":"alistairclark7@gmail.com"}],"readme":"# context-autopsy 🩻\n\n**Find out what's actually filling your coding agent's context window.**\n\nYour 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.\n\n```bash\nnpx context-autopsy\n```\n\nIt 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.\n\nEverything runs locally. Nothing is uploaded. No dependencies.\n\n---\n\n## What you get\n\nFirst, a card sized for one post (example output):\n\n```\n🩻 I autopsied my Claude Code context window.\n\nOnly 27% of it was my actual code.\n\n🔑 It saw 23 secret keys & passwords\n💥 1,204 failed commands\n🔧 21% was build logs & env wrangling\n🧠 Hit its context limit 87 times\n\n1.9B tokens in 60 days\nnpx context-autopsy\n```\n\nThe 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.\n\nBelow the card is the full breakdown:\n\n```\nWHERE YOUR CONTEXT WENT\n                                  processed*   share  in context\nReading code                          512.3M   27.0%        9.1M  ██████████████████████████████\nFixed overhead                        398.4M   21.0%        5.2M  ███████████████████▍··········\nBuild, test & run output              246.6M   13.0%        4.4M  █████████████▏················\nReasoning                             227.6M   12.0%        4.6M  ████████▍·····················\nEnvironment & infrastructure          151.8M    8.0%        2.7M  ████████▏·····················\nGit & version control                 132.8M    7.0%        2.4M  ███████▍······················\n...\n\nTHE HEADLINES\n▸ 21% of everything your agents processed was build output and environment wrangling.\n▸ 1,204 failed commands and tool calls (7% of all tool calls), 64.0M tokens of error output processed.\n▸ 23 credentials passed through the model's context (9 Database URL with password, 6 AWS access key, …).\n▸ Most expensive single output: a 14k-token `pnpm install` result, re-sent 212 times = 3.0M tokens.\n▸ 41 sessions filled the window and compacted (87 times).\n```\n\nAlso shown:\n\n- **At peak**: what your fullest context was made of at the moment it was fullest.\n- **Most expensive tool outputs**: the single results that cost you the most.\n- **Sessions most buried in plumbing**: the ones where the agent spent its time on setup instead of your feature.\n\n## Why \"processed\" and not just \"size\"?\n\nAn 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.\n\n`context-autopsy` follows each piece of content from the turn it entered the context to the turn it left. It reports two numbers:\n\n- **in context**: the tokens added.\n- **processed**: tokens × the number of model calls they rode along for. This is what drives cost, latency and context rot.\n\nEstimates 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.\n\n## The groups\n\n| Group | What lands here |\n| --- | --- |\n| **Fixed overhead** | System prompt, tool and MCP schemas, injected instructions (`CLAUDE.md`, `AGENTS.md`), reminders, compaction summaries |\n| **Conversation** | Your prompts and the model's replies |\n| **Reasoning** | Thinking and reasoning blocks |\n| **Reading code** | File reads, `grep`/`rg`/`find`/`ls`, search results |\n| **Writing code** | Edits, patches, new files |\n| **Build, test & run output** | `npm`/`pnpm`/`pip`/`cargo`/`go`/`dotnet` installs and builds, test runners, linters, dev servers |\n| **Environment & infrastructure** | `docker`, `kubectl`, `helm`, `terraform`, `aws`/`gcloud`/`az`, `ssh`, ports and processes, env vars, `.env`, Dockerfiles, CI and infra config |\n| **Git & version control** | `git`, `gh` |\n| **Web & docs lookups** | Web search, fetched pages, `curl` |\n| **Browser & UI checks** | Playwright, browser and computer-use tools poking at the running app |\n| **Subagents & coordination** | Spawning, messaging and waiting on other agents |\n| **Other tool output** | MCP tools and everything else |\n\nIt 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).\n\nCredentials are fingerprinted with a one-way hash so they can be counted. The values are never stored or printed.\n\n## Options\n\n```\nnpx context-autopsy [options] [transcript.jsonl | directory ...]\n\n  --agent <ids>                Only these agents, comma-separated (default: all)\n                               claude, codex, cursor, opencode, pi, gemini, qwen,\n                               cline, roo, kilo, droid, amp, goose\n  --since <7d|2026-09-01>      Only sessions active since this date or age\n  --project <text>             Only sessions whose working directory contains <text>\n  --last <n>                   Only the n most recent sessions\n  --no-subagents               Skip subagent / child-thread transcripts\n  --detail                     Show sub-categories (which tools, which commands)\n  --top <n>                    Rows in the \"most expensive\" table\n  --share                      Just the post-ready card, plus a link to post it\n  --copy                       Copy the card to the clipboard\n  --json                       Machine-readable output\n```\n\n## Supported agents\n\nEvery agent found on your machine is read automatically.\n\n| Agent | Where it reads from | Token usage |\n| --- | --- | --- |\n| Claude Code | `~/.claude/projects` (`CLAUDE_CONFIG_DIR`) | per request |\n| Codex | `~/.codex/sessions` (`CODEX_HOME`) | per request |\n| Cursor | `state.vscdb` in Cursor's global storage | context snapshots only¹ |\n| OpenCode | `~/.local/share/opencode` (`XDG_DATA_HOME`, `OPENCODE_DB`): SQLite and older JSON storage | per request |\n| Pi | `~/.pi/agent/sessions` (`PI_CODING_AGENT_DIR`, `PI_CODING_AGENT_SESSION_DIR`) | per request |\n| Gemini CLI | `~/.gemini/tmp/*/chats` | per request |\n| Qwen Code | `~/.qwen/projects` (`QWEN_HOME`) | per request |\n| Cline | `tasks/` in the extension's storage³, and `~/.cline/data` (SDK and CLI sessions) | per request |\n| Roo Code | `tasks/` in the extension's storage³ | per request |\n| Kilo Code | `~/.local/share/kilo` (7.x), and `tasks/` in the extension's storage³ (≤5.x) | per request |\n| Factory Droid | `~/.factory/sessions` | per request² |\n| Amp | `~/.local/share/amp/threads` (`AMP_DATA_DIR`) | per request² |\n| Goose | `~/.local/share/goose/sessions/sessions.db` (`GOOSE_PATH_ROOT`) | per request² |\n\n¹ Cursor doesn't store per-request usage. Sizes are calibrated from the context-window snapshot Cursor saves with each message you send.\n² Droid and Amp are closed source. Their formats come from open-source parsers, not vendor code.\n³ \"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.\n\nSQLite-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.\n\nIs your agent missing? Open an issue with where it stores sessions.\n\n## Share yours\n\n```bash\nnpx context-autopsy --share --copy\n```\n\nThis prints just the card, copies it to your clipboard, and gives you a link that opens a pre-filled post.\n\n## Use it from inside Claude Code\n\nInstall it as a plugin, then ask \"where is my context going?\" or run `/context-autopsy`:\n\n```\n/plugin marketplace add AlistairClark7/context-autopsy\n/plugin install context-autopsy@context-autopsy\n```\n\nOr copy [`skills/context-autopsy`](skills/context-autopsy) into `~/.claude/skills/`. The skill runs the analysis, explains the numbers, and suggests fixes specific to what it found.\n\n## Caveats\n\n- Token counts per item are estimated from text length (about 3.8 characters per token), then scaled per session to match the API's reported totals. Category shares are good. Individual items are approximate.\n- Category rules are heuristics over tool names, commands and file paths. `--detail` shows exactly what went where. PRs that improve the rules are welcome.\n- Transcript formats change between agent versions. Claude Code, Codex and Roo Code have been tested against real sessions. The other agents' parsers were built from their source code and are tested with synthetic sessions. If something looks off, run with `DEBUG=1` and open an issue.\n\n## Licence\n\nMIT\n","readmeFilename":"README.md"}