context-receipt
v0.1.0
Published
Your coding agent loads thousands of tokens before your first word. Here's the receipt.
Maintainers
Readme
context-receipt
Claude Code loads ~36k tokens into context before you type a single word. Memory files, instruction files, skill listings, agent listings, tool schemas — all of it spends your context window before your first prompt. This prints the itemized receipt.
npx context-receipt CONTEXT RECEIPT
claude code · vault
──────────────────────────────────────────────
LOADED BEFORE YOUR PROMPT tokens*
claude code system prompt ~6.8k
built-in tool schemas ~2.4k
CLAUDE.md (global) 1.5k
rules/ (3 files, global) 486
CLAUDE.md (project chain) 5.5k
MEMORY.md (auto-memory index) 3.6k
skill listing, user (115 skills) 10.6k
skill listing, plugins (31 skills) 2.0k
agent listing (10 agents) 407
──────────────────────────────────────────────
TOTAL ~33.5k
DEAD WEIGHT — on disk, NOT loaded
AGENTS.md 17.8k chars
not read by Claude Code unless @imported from CLAUDE.mdWhy care
It's not (only) the cost — startup context is cache-priced after the first message. It's the context-window tax: every always-loaded token brings compaction closer and competes with your actual work for the model's attention. Most setups accrete this invisibly — old memory entries, skills you installed once, rules files you forgot.
And the inverse surprise: dead weight — files you think are loaded that aren't. AGENTS.md sits on disk looking authoritative; Claude Code never reads it unless you @import it from a CLAUDE.md.
Usage
npx context-receipt # receipt for the current directory
npx context-receipt ~/code/myproj # receipt for another project
npx context-receipt --json # write context-receipt.json (diffable, CI-able)
npx context-receipt --budget 30000 # exit 1 if the estimate exceeds the budgetexplain — computed styles for a single file
/context tells you what's loaded now. It can't tell you which instructions apply
when Claude touches a specific file:
npx context-receipt explain src/auth/login.ts src/auth/login.ts
inherits 7 instruction layers (~2.0k tokens est)
1. CLAUDE.md (global) [1.5k] always (startup)
5. CLAUDE.md (project) [15] always (startup)
6. @import docs/extra.md [4] always (startup)
7. CLAUDE.md (src) [17] when Claude works in this directory
OVERLAPPING SECTIONS — same heading in multiple layers,
all in context at once; review for contradictions:
"git" — CLAUDE.md, src/CLAUDE.mdIt resolves the global + project CLAUDE.md chain, nested per-directory CLAUDE.md
files (which load lazily), and one level of @imports — then flags headings that
appear in more than one layer, since those are where contradictory rules hide.
Honest semantics: Claude Code loads all applicable layers simultaneously; there
is no enforced cascade, so explain reports layers and overlaps rather than
pretending a precedence engine exists. --json prints the structured version.
Method, honestly
- Static scan of the same files Claude Code reads: the global and project
CLAUDE.mdchain (walking up from the project directory),~/.claude/rules/, one level of@imports, the project's auto-memoryMEMORY.md, skill frontmatter (name + description are listed in context at startup), and agent frontmatter. - Token counts are estimates (chars ÷ 4). Reconcile against
/contextinside a live session — that's the ground truth this tool approximates without needing a session. - The Claude Code base system prompt and built-in tool schemas can't be derived statically; they're included as constants measured via
/contexton v2.1.212. - Calibration: on the author's setup the static estimate lands within ~8% of the live
/contexttotal (33.5k estimated vs 36.3k measured), on the undercount side — your real number is likely a bit worse than the receipt says.
Roadmap
- Plugin skill counting, real tokenizer,
/contextauto-reconciliation context-receipt diffbetween two receipts (did that PR add 4k always-loaded tokens?)- Codex CLI, Cursor, Gemini CLI receipts
MIT
