TL;DR
- In a Grafana clone, Claude Code 2.1.288 on Sonnet sent about 38,100 tokens on the first request of a plain session, before reading a single file.
- In that Claude Code setup, built-in tool definitions (23.3k tokens) were the biggest item in
/context, and reading one 1,100-line file in full added 16,481 tokens. - A 310 KB
git grepadded only 1,142 tokens, because Claude Code saved the output to a file and gave the model a 2 KB preview. - Measured on 10 November 2026 from the usage field of every API request; some runs also had repowise, the code index I work on, connected over MCP.
I wanted to know where the tokens go when Claude Code works in a large repository, so I stopped guessing and logged every request. I used Grafana (a shallow clone at 12c49a4d, 24,428 tracked files, Go backend and TypeScript frontend), Claude Code 2.1.288 and Sonnet, and ran everything headless with --output-format stream-json, which prints the token usage of every API call.
The first request of every session carried about 38,100 tokens. That is before the agent had read a single file. A whole cross-stack exploration task added 12,412 tokens on top of it. Reading one 1,100-line file in full added 16,481.
Here is what makes up those numbers, how to see them in your own sessions, and what changed them.
See it first: /context
/context prints the breakdown of the current window. It also works in print mode, which is how I got it without opening a session:
cd grafana claude -p "/context" --model sonnet (On Git Bash for Windows, set MSYS_NO_PATHCONV=1 first. Otherwise Git Bash rewrites /context into C:/Program Files/Git/context and the model gets a confusing message instead of the command.)
**Model:** claude-sonnet-5-5 **Tokens:** 32.5k / 1m (3%) | Category | Tokens | Percentage | |----------|--------|------------| | System prompt | 2.2k | 0.2% | | System tools | 23.3k | 2.3% | | System tools (deferred) | 19.9k | 2.0% | | Memory files | 3.9k | 0.4% | | Skills | 3.1k | 0.3% | | Messages | 10 | 0.0% | | Free space | 934.5k | 93.5% | | Autocompact buffer | 33k | 3.3% | ### Memory Files | Type | Path | Tokens | |------|------|--------| | Project | ./CLAUDE.md | 16 | | Project | ./AGENTS.md | 3.9k | ... On this model Claude Code reports a 1M window, so 32.5k is 3%. The same fixed cost on a 200k window would be about a sixth of it.
What fills the Claude Code context window before you type?
Going down that table:
- System tools, 23.3k. The definitions of the built-in tools (Read, Grep, Bash, Edit, Agent and the rest). This is the biggest single item, and you pay it on every request. The "deferred" 19.9k are tools whose full definitions are only loaded when the model searches for them, so they are not counted in the 32.5k.
- Memory files, 3.9k. Grafana ships a
CLAUDE.mdthat is one line,@AGENTS.md. That import pulls in a 10.8 KBAGENTS.mdwith build commands, test commands, review rules and pointers to four directory-levelAGENTS.mdfiles. Every session in this repo starts with it. - Skills, 3.1k. Only the name and description of each skill load up front. Grafana adds three of its own under
.claude/skills/(about 580 tokens together), the rest are built in. - MCP servers. I ran a second
/contextwith one MCP server connected (repowise, which I use below). It added 344 tokens of server instructions. Its 10 tools, 6.2k tokens of definitions, stayed in the deferred bucket until used.
The first API request in my runs was slightly bigger than /context's estimate: 38,120 to 38,170 tokens with no MCP server, about 38,700 with one, and 40,014 when I also added a 3.4 KB generated CLAUDE.md section.
If you install a lot of plugins and skills globally, this part grows in every repo you open. My runs used --setting-sources project,local to skip my own user settings, so the numbers above are Grafana's own setup plus Claude Code's defaults.
What grows the context window during a task?
To isolate single actions, I gave Claude Code one instruction per session and diffed the window between the request before the action and the request after it.
| Action | Window growth |
|---|---|
Read of public/app/features/dashboard/state/DashboardMigrator.ts in full (1,104 lines, 36 KB) | +16,481 tokens |
The step that read apps/dashboard/pkg/migration/schemaversion/README.md (16.7k characters) plus two small greps | +7,864 tokens |
git grep -n -i schemaversion over the whole repo (310 KB of output) | +1,142 tokens |
A subagent reads DashboardMigrator.ts and returns a 5-line summary | +1,256 tokens in the main window |
14 targeted Grep/Glob calls and one Read while tracing the dashboard save path | +12,412 tokens for the whole task |
Two of these surprised me.
The 310 KB grep cost almost nothing. Claude Code did not put it in the window. It saved the output to a file and gave the model a 2 KB preview with the path:
<persisted-output> Output too large (310.2KB). Full output saved to: ~/.claude/projects/<project>/.../tool-results/b2o2qaoan.txt Preview (first 2KB): apps/alerting/notifications/kinds/manifest.cue:104: versions: [...#IntegrationTypeSchemaVersion] ... The model then ran tail on that file to get the line it needed. Huge command output is less of a threat than it used to be. The full-file Read has no such guard, because a 36 KB file is under the limit, and it was the single most expensive action I measured.
The subagent kept the main window small, but it was not cheaper. It started its own context at 32,216 tokens (it gets its own system prompt and tools) and then read the same file. The session cost $0.21, against $0.12 for reading the file directly. In this run the subagent protected the window I was working in, and it did not save money.
Two real tasks, measured
Then I gave Claude Code two questions a new contributor to Grafana might ask, and logged each run end to end.
Task 1: "Where is the dashboard JSON schema migrated between versions, and which files would I touch to add a new migration step?"
Task 2: "Trace what happens when a user clicks Save on a dashboard in the Grafana UI, through the frontend and the Go backend, down to where the dashboard is written to storage."
| Run | Tool calls | Read calls | Window at start | Window at answer | Growth | Wall time |
|---|---|---|---|---|---|---|
| Task 1, plain | 8 | 1 | 38,129 | 50,614 | 12,485 | 18.3 s |
| Task 1, MCP server connected | 6 | 0 | 38,680 | 45,082 | 6,402 | 14.7 s |
| Task 2, plain | 15 | 1 | 38,170 | 50,582 | 12,412 | 29.5 s |
| Task 2, MCP + generated CLAUDE.md section | 20 | 6 | 40,014 | 55,677 | 15,663 | 28.7 s |
| Task 2, MCP, prompt says to use it | 6 | 0 | 38,736 | 48,239 | 9,503 | 30.0 s |
"Window at answer" is the input of the last request, when the model wrote its reply. I am comparing tokens, not dollars. Prompt caching makes the dollar figure depend on run order: the first run paid to write 38k tokens to the cache and every later run read them back cheaply.
What I take from this:
The fixed part was the biggest part. In every run, the 38k loaded before the task was two and a half to six times what the task itself added. On a short question, trimming your setup moves the number more than any prompt trick.
Sonnet was careful on its own. It grepped with head_limit, used files_with_matches before asking for content, and in the second task-2 run it read six slices of files with offset and limit (1 to 6 KB each) instead of whole files. The full reads it did choose were a 15 KB README and a 6 KB hook file.
Grafana's own docs did the heavy lifting on task 1. The plain run found apps/dashboard/pkg/migration/schemaversion/README.md, a step-by-step guide for adding a schema migration, read it, and answered from it. Both runs named the same files: schemaversion/vN.go, migrations.go (where LATEST_VERSION = 42 lives), the test fixtures and the frontend DashboardMigrator.ts. A good README sitting next to the code is worth more than any amount of agent cleverness.
One run per condition is anecdotal. The two task-1 runs differ only by an MCP server that was never called, and they still differ by 6,000 tokens, because one run read the README and the other answered from grep results. Treat any single-run difference smaller than that as noise.
How to make Claude Code show the context window while you work
-
/contextfor the breakdown above, any time during a session. -
/usagefor session cost and plan usage./costand/statsare aliases of it in 2.1.288. - A statusline, so the number is always on screen. Claude Code pipes JSON to your statusline command, and it includes
context_window.total_input_tokens,context_window.context_window_size,context_window.used_percentageandcost.total_cost_usd. Mine is a few lines of Python:
# ~/.claude/statusline.py import json, sys d = json.load(sys.stdin) cw = d.get("context_window") or {} used = cw.get("total_input_tokens") or 0 size = cw.get("context_window_size") or 0 cost = (d.get("cost") or {}).get("total_cost_usd") or 0 print(f"{d['model']['display_name']} | context {used/1000:.1f}k / {size/1000:.0f}k | ${cost:.2f}") { "statusLine": { "type": "command", "command": "python ~/.claude/statusline.py" } } That goes in ~/.claude/settings.json, and it prints something like Sonnet | context 50.6k / 1000k | $0.25.
- For scripted measurement,
claude -p "<task>" --output-format stream-json --verbosegivesinput_tokens,cache_creation_input_tokens,cache_read_input_tokensandoutput_tokensfor every request. Their sum is the window at that request. That is all I used for the tables above.
How to reduce Claude Code context usage
Prune what loads every session. The fixed ~38k was the biggest part of every run, so that is where I would start. Look at the Memory files and Skills rows in /context. Grafana's approach is a good model: one root file of commands and rules, and a list of directory-level AGENTS.md files the agent reads only when it works in that directory. Global plugins and skills you installed once and forgot about load in every repo.
Point at files, ask for slices. "Read DashboardMigrator.ts lines 1 to 120" or "find where LATEST_VERSION is set" costs a fraction of a full read. The full read was 16,481 tokens, the six slices in my second task-2 run were 1 to 6 KB of text each, roughly 250 to 1,500 tokens.
Use subagents for wide exploration you do not need to keep. They keep your working window clean (+1,256 instead of +16,481 here), though in my run the total cost was higher.
/clear between unrelated tasks, /compact with a focus inside a long one. My runs were single questions, so none of them got close to the 33k autocompact buffer. In a long interactive session, everything above stays in the window and is sent again on every turn until you clear or compact. This guide on Claude Code in large codebases covers what to put in CLAUDE.md and how to steer /compact.
Name the tool you want used. MCP tools are deferred behind tool search, so the model has to decide to look for them. That turned out to matter, below.
Where an index fit in
I connected repowise, the open-source tool I work on, over MCP (repowise mcp <path>) after indexing Grafana with repowise init. It answers "how does X flow" and "where is Y" questions from a code graph instead of from file reads.
In the two runs where the server was just connected, Sonnet never called it. It went straight to Grep, same as the plain runs, so the only effect was the 344 tokens of instructions (and about 1.3k more for the generated CLAUDE.md section in the second one, which tells the agent when to use each tool).
When the prompt said "Use the repowise MCP tools before reading files", it made one get_answer call and three search_codebase calls, read zero files, and finished task 2 with 6 tool calls against 15, and 9,503 tokens of growth against 12,412. It listed the same frontend chain (SaveDashboardDrawer.tsx, useSaveDashboard.ts, dashboard/api/v1.ts) and the same unified storage files down to the SQL backend's backend.go, marked two middle hops of the backend as inferred from file names, and offered to open them.
If you use any MCP server for code context, saying so in the prompt or in your own instructions is what gets it used. The Claude Code setup page shows how repowise wires itself into Claude Code beyond a bare MCP server.
What do you see in /context on your largest repo? I would like to know which row is the biggest for people with a lot of plugins installed.
How I ran this
All runs on 10 November 2026, Windows 11, Git Bash. Grafana shallow clone at 12c49a4d (24,428 tracked files). Claude Code 2.1.288, model alias sonnet (reported as claude-sonnet-5-5, 1M window), repowise 0.60.1 indexed with repowise init --yes --no-prose --no-editor-setup (no model used for the index).
Every run used the same isolation flags, so my own setup did not leak in:
claude -p "<task>" --model sonnet --output-format stream-json --verbose \ --strict-mcp-config --mcp-config <empty or repowise-only config> \ --setting-sources project,local --no-session-persistence \ --permission-prompts none --disallowedTools "Edit Write NotebookEdit" --setting-sources project,local skips user settings, plugins and hooks. Built-in skills and Claude Code's own system prompt still load, and I added .repowise/ to .git/info/exclude so search tools would not wander into the index. One run per condition. Total spend for every run in this post was about $1.35. All five task runs named the right main files, which I checked against the clone. The token figures come straight from the usage field of each request.
FAQ
What does a 200K context window mean in Claude Code?
It is the most tokens the model can take in one request, and everything counts toward it: system prompt, tool definitions, memory files, skills and the whole conversation so far. In my Grafana runs /context counted 32.5k before the first message, which would be about a sixth of a 200K window.
What happens when I hit my context window in Claude Code?
Claude Code compacts automatically when the window gets close to full, summarizing the earlier conversation to free space. /context shows the reserved autocompact buffer (33k in my runs), and you can run /compact yourself or /clear to start fresh between tasks.
How do I make Claude Code show the context window?
Run /context at any point for the full breakdown. For a number that is always on screen, use a statusline command that reads context_window.used_percentage or context_window.total_input_tokens from the JSON Claude Code passes to it.

