Claude Code · Updated 2026-10-09
Claude Code context limit: why you run out and what to do
Claude Code warns you as the context window fills, then compacts the session. Most of what fills it is tool output that the agent read once and never needs again. This guide shows how to see what is in the window, the built-in ways to free it, and how to stop bulky output from piling up in the first place.
/context to see what is using the window. Use /clear between tasks, /compact with a focus inside long tasks, and subagents for wide searches. To stop large logs and file reads from filling the window, run npm install -g supercompress-proxy && supercompress setup so Claude Code keeps only the lines that answer the current question.
What fills the Claude Code context window
- System prompt and tools. Built-in tools plus every enabled MCP server's tool definitions.
- Memory files.
CLAUDE.mdfiles from your home folder and the project. - Messages and tool results. Every file read, Bash run, Grep and MCP result that is still in the session. This is usually the largest part.
See what is using it
Run /context. It breaks the window down by category so you know whether to trim tools, memory files or the session itself.
Free it up
| Command | What it does | Use it when |
|---|---|---|
/clear | Starts an empty session. | You are switching to unrelated work. |
/compact | Replaces the session with a summary. Add a focus, such as /compact keep the failing test and the fix plan. | You are mid-task and the session is long. |
| Auto-compact | Compacts automatically as the window fills. | On by default; compacting earlier yourself gives you control over what is kept. |
| Subagents | Run a search or investigation in a separate context and return a short report. | The task needs reading a lot of code to find a little. |
Stop it filling up
- Keep
CLAUDE.mdshort. Link to longer docs instead of pasting them. - Disable MCP servers you are not using. Their tool definitions are sent every turn.
- Ask for narrow output. One test file instead of the whole suite; a line range instead of a whole file.
- Compress bulky output against the question. SuperCompress keeps the original lines from a log, diff or file read that answer what Claude is working on and drops the rest, before that output piles up in the session.
How SuperCompress works
SuperCompress is hosted, extractive and query-aware. Your agent sends a large block of context (a log, a diff, a file read, an MCP result) together with the question it is working on. Our Neural Keep model scores the lines against that question, keeps the original lines that answer it, and drops the rest. It never rewrites or summarizes, so file paths, error messages, IDs and code come back exactly as they were. The question itself is never compressed.
Every compress call reports original_tokens and kept_tokens, so you can see what was dropped on your own work instead of trusting a headline number. The usage_summary MCP tool shows totals per agent for your account.
Install
npm install -g supercompress-proxy && supercompress setup
Setup links your SuperCompress account in the browser, detects the coding agents on the machine and wires each one. Restart the agent so it loads the new MCP server. Then check what is wired up:
supercompress doctor
doctor prints a per-agent health check. supercompress uninstall removes only the entries SuperCompress added. Setup backs up each config file before it edits it.
Setup details for Claude Code, including the plugin, are on Reduce Claude Code token usage.
FAQ
Why does Claude Code say the context is almost full?
The window holds the system prompt, tool definitions, memory files and the whole session, including every tool result. Long sessions with large file reads and logs fill it fastest. Run /context to see the breakdown.
What happens when the Claude Code context window is full?
Claude Code compacts the session: it replaces the history with a summary so work can continue. Details that were only in old tool output can be lost in that summary.
Is /compact or /clear better?
Use /clear when you switch to unrelated work. Use /compact with a short focus when you are mid-task and want to keep the important details.
Can I stop large tool output from filling the context?
Yes. Ask for narrower output, disable unused MCP servers, and use SuperCompress to keep only the original lines of a large result that answer the current question.