new(bin/context-audit.sh): which files fill the context window, from real transcripts - #181
Merged
Merged
Conversation
…real transcripts token-burn.sh counts tokens per project; this attributes them to files: start context per session and per subagent, auto-loaded instruction files, every file read (Read tool and simple shell reads) with re-reads, other tool output, and compactions with what was read before them. Project names are masked by default so the output can be pasted. Field run: this cloud session plus one pipeline-start subagent captured here; the subagent starts at 52,503 tokens and pages the runbook 6 times, 2 repeats. Fixture is that capture, scrubbed to same-length filler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VJgWP5vEoAsNsJYqCDMGNw
This was referenced Sep 30, 2026
Merged
…ines) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VJgWP5vEoAsNsJYqCDMGNw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why (one paragraph)
bin/token-burn.shsays how many tokens a project burned, but not which files burned them. Deciding what to split, trim or stop routing needs that per-file number from real runs, notwcon the skill files.bin/context-audit.shreads the Claude Code transcripts on a machine and reports: (1) the context size before any work, from the first call's billed input + cache, split into sessions and subagents; (2) the instruction files loaded every run and their size; (3) every file read, by the Read tool or a simple shell read (cat,sed -n,git show REV:path, followingcdandVAR=), with reads, sessions, total and per-read size, and re-reads within a session (paging through a file is not a re-read, asking for the same part again is); (4) other tool output by tool; (5) compactions, with the files read before them. Project names are masked by default (project-1/architecture/modules/*.md), so the output can be pasted;--namesshows them locally. It is read-only and exits 0, and prints NOT AVAILABLE when there is no transcript tree.Field evidence
This cloud session, plus one pipeline-start subagent run here (read CLAUDE.local.md, the runbook, two baseline skills, one again):
learned-mdl-preflight.mdFixture:
tests/wave2/test-context-audit.sh bin/context-audit.shovertests/wave2/fixtures/context-audit/, which is that capture scrubbed. The scrubber keeps every field the script reads, swaps all text for filler of the same length, rewrites paths to/srv/example/and replaces model ids (seeCAPTURE.md). Its assertions were checked by hand against the output.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01VJgWP5vEoAsNsJYqCDMGNw
Generated by Claude Code