Blog

Claude Code context window full? What it means and what to do

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 windowTypeHow it grows
System promptFixedSet by Claude Code
Built-in tool definitionsFixedSet by Claude Code
MCP tool definitionsFixedOne block per connected server
CLAUDE.md and memory filesFixedGrows as you add rules
Your messages and Claude's repliesSessionEvery turn
File readsSessionWhole files, re-read after edits
Command, test and search outputSessionOften 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 showsThen
MCP tools or memory files are large before any workYour setup is the problem. Trim MCP servers and CLAUDE.md.
Messages dominateThe 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.

Context carried per turn
Illustrative session
auto-compactturn 1turn 40
  • default
  • with condense
Context climbs every turn until auto-compact resets it, often mid-task. Compressed, the same session carries a fraction of it.

What to do when Claude Code is running out of context

  1. 1
    Compact 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.

  2. 2
    Clear between tasks

    Have Claude write a handoff note, then /clear and start from the note.

  3. 3
    Send exploration to a subagent

    It reads dozens of files in its own context and returns a short answer.

  4. 4
    Keep tool output small

    Failing tests only, tail long logs, scope searches. More in tool output is eating your context.

  5. 5
    Read parts of files

    Point Claude at a function or line range, not a whole 2,000-line module.

  6. 6
    Disconnect what you do not use

    /mcp lists 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.

  1. 1
    Write the plan to a file

    Steps as markdown checkboxes. No compaction can lose what is on disk.

  2. 2
    Tick and commit as you go

    Git history and the plan tell any new session where things stand.

  3. 3
    Restart 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 requestWhat condense does
System prompt, your messages, Claude's final answersNever rewritten
New contentHelene trims it, keeping surviving text verbatim
Code, patches and error outputNever touched by Helene
Finished agent loopsAdeline 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.

All posts