The Context Window: What Fills It and How Fast
- Map the sequence of events that fill the context window from session start through a typical debugging session
- Estimate token cost for common operations: file reads, bash output, search results, and path-scoped rules
- Explain the attention degradation problem and why content buried in the middle of a large context gets less reliable attention
The Window Fills Faster Than It Looks
A typical Claude Code session on a 200,000-token model starts with roughly 6,000–8,000 tokens already consumed by the startup stack. By the time you send your first prompt and Claude reads two or three files, you have often spent 15–20% of your budget — before any productive work has happened. Understanding the sequence helps you intervene at the right moments.
The Startup Stack (Before Your First Prompt)
These load in order at session start:
- System prompt: ~4,200 tokens — always first, never visible
- Auto memory (MEMORY.md): up to 200 lines or 25KB
- Environment info: git branch, status, recent commits — ~280 tokens
- MCP tool names (deferred): ~120 tokens for names only; schemas load on demand
- Skill descriptions: ~450 tokens for one-liners
- Global CLAUDE.md: your user-level preferences
- Project CLAUDE.md: your project conventions
During the Session: What Each Operation Costs
The entire file content enters context — typically 1,000–5,000 tokens per file depending on size. A codebase exploration that reads 30 files can fill half the available window before any coding begins.
Full command output enters context. A test run that prints 500 lines of output costs thousands of tokens. An npm install log can easily exceed 10,000 tokens by itself.
Rules in .claude/rules/ with matching paths: patterns load the first time Claude reads a matching file. A rule matching src/api/** loads automatically when Claude reads any file in that directory.
Grep or codebase search across many files returns all matching content. Ten matching files return ten blocks of surrounding context, each costing tokens.
Every MCP tool call returns its output to context. An MCP tool that fetches a documentation page can return tens of thousands of tokens at once.
Typically the smallest contributor — a few dozen to a few hundred tokens per turn. The file reads and tool results dwarf them.
The Attention Degradation Problem
Context size is not just a cost issue — it is a performance issue. Claude attends well to content near the beginning and end of the context window. Content buried in the middle — added thousands of turns ago, now covered by subsequent messages — receives less reliable attention. This means a session that has been open for hours is not just expensive; it is also less accurate on instructions that were given early in the session.
The practical consequence: if you correct Claude twice on the same issue without lasting improvement, the problem is often not that Claude cannot follow the rule — it is that the instruction is now buried under too much subsequent context. Starting fresh with /clear often fixes this immediately.
What Survives Compaction
When you run /compact or auto-compaction triggers, Claude summarizes earlier conversation history. Not everything survives equally:
- Survives well: CLAUDE.md files (re-injected automatically), recently read files (up to five), explicit decisions and code changes
- Does not survive: skill listing (only invoked skills are preserved), detailed intermediate steps, instructions given only in conversation (not in CLAUDE.md), exact file content from early reads
- Skill listing specifically: the one-line skill descriptions are not re-injected after compaction — only skills you actually invoked are preserved in the summary
This asymmetry is why CLAUDE.md is the right place for rules you want Claude to follow throughout a session, not the conversation itself.
- File reads are the single biggest context consumer — a codebase exploration that reads 30 files can fill half the window before any coding begins; specific prompts that name the exact file let Claude work efficiently.
- Bash output, tool results, and search results each add their full text to context — a noisy test run or a documentation fetch can cost as much as ten file reads.
- Path-scoped rules in .claude/rules/ load automatically when Claude reads a matching file, adding tokens you may not realize are there; use /context to see them.
- Attention degrades for content buried in the middle of a large context — if Claude keeps repeating a mistake you have corrected, the instruction is probably buried, not ignored; /clear often fixes this instantly.
- CLAUDE.md is re-injected after compaction; instructions given only in conversation are not — put rules you need to persist in CLAUDE.md, not in messages.