The context window is everything the model sees on one request: system prompt, tools, CLAUDE.md, the conversation and every file and command output still in it. When it fills, Claude Code auto-compacts the history into a summary and details get lost. Run /context to see what is using the space, then compact on your terms, clear between tasks and keep tool output small.
- Fixed overhead loads before you type and rides along on every request.
- Session content grows every turn until auto-compact replaces it with a lossy summary.
- The fix is to carry less: compact early, clear often, read less, compress the rest.
What the Claude Code context window holds
The model has no memory between requests, so every step re-sends the full working state. Window size depends on the model; see Anthropic’s models overview.
| What is in the window | Type | How it grows |
|---|---|---|
| System prompt | Fixed | Set by Claude Code |
| Built-in tool definitions | Fixed | Set by Claude Code |
| MCP tool definitions | Fixed | One block per connected server |
| CLAUDE.md and memory files | Fixed | Grows as you add rules |
| Your messages and Claude's replies | Session | Every turn |
| File reads | Session | Whole files, re-read after edits |
| Command, test and search output | Session | Often the biggest single additions |
Check what is filling it with /context
/context breaks the window into system prompt, system tools, MCP tools, memory files, messages and free space. Run it at the start to see fixed overhead, and again when things feel slow.
| If /context shows | Then |
|---|---|
| MCP tools or memory files are large before any work | Your setup is the problem. Trim MCP servers and CLAUDE.md. |
| Messages dominate | The session has grown. Use the fixes below. |
Context left until auto-compact: what happens at zero
At zero, Claude Code summarizes the conversation, drops the history and continues. CLAUDE.md and the system prompt survive; exact errors, rejected approaches and one-off constraints often do not. See /compact vs /clear to control what survives.
- default
- with condense
What to do when Claude Code is running out of context
- 1Compact before it is forced
At a natural break, with instructions:
/compact keep the files changed, the failing test names and the decision to keep the v1 API. - 2Clear between tasks
Have Claude write a handoff note, then
/clearand start from the note. - 3Send exploration to a subagent
It reads dozens of files in its own context and returns a short answer.
- 4Keep tool output small
Failing tests only,
taillong logs, scope searches. More in tool output is eating your context. - 5Read parts of files
Point Claude at a function or line range, not a whole 2,000-line module.
- 6Disconnect what you do not use
/mcplists servers; turn off the ones this project does not need.
Keep a long task going across several context windows
For work that does not fit in one window, plan for auto-compact instead of fighting it.
- 1Write the plan to a file
Steps as markdown checkboxes. No compaction can lose what is on disk.
- 2Tick and commit as you go
Git history and the plan tell any new session where things stand.
- 3Restart from the file
/clear, then “read PLAN.md and continue with the next unchecked step.” A few thousand tokens to catch up instead of a hundred thousand of history, and a plan you can review.
Why a bigger context window does not fix it
- It postpones the wall but every token is still re-sent on every turn.
- Each step costs more and drains plan limits faster near the top of a bigger window.
- Quality drops well before the window is full. See context rot.
Compressing context on the way to the model
Most of a late-session request is old tool output and finished work. condense is a proxy between Claude Code and the model that compresses it before each request.
| Part of the request | What condense does |
|---|---|
| System prompt, your messages, Claude's final answers | Never rewritten |
| New content | Helene trims it, keeping surviving text verbatim |
| Code, patches and error output | Never touched by Helene |
| Finished agent loops | Adeline rewrites them into short summaries that keep intents, file paths, identifiers, errors and code |
dense info shows tokens sent against tokens forwarded for the current session. Install with curl -fsSL https://cli.condense.chat/unix | sh and run dense claude instead of claude.
Frequently asked questions
What does "context left until auto-compact" mean in Claude Code?
It is the room left before Claude Code summarizes the conversation to free space. At zero, auto-compact runs and the session continues from the summary.
How big is the Claude Code context window?
It depends on the model; see Anthropic's models overview. Run /context to see the total and how much your session uses.
Why is my context already partly full when I start a session?
The system prompt, built-in tools, every MCP server's tools and your CLAUDE.md files load before you type. /context lists each one.
Can I turn off auto-compact in Claude Code?
Yes, in /config. Then you have to run /compact or /clear yourself before the window fills.
Is it better to /compact or /clear when the context is full?
Use /compact with instructions mid-task. Use /clear when switching tasks or after a dead end, once anything important is saved to a notes file.