Submit a toolSubmit

Claude Code's context window filled up. Compact it and keep the task

A long Claude Code session fills the context window, and earlier instructions get summarized away at the wrong moment. Short answer: 5 steps. 1) See what is using the window; 2) Compact with a focus before the next task; 3) Keep standing rules where compaction can reload them; 4) Clear unrelated work, or hand big reads to a subagent; 5) Move the auto-compact point if it fires too late.

Last updated: · This page is the decision checklist; the tools list for “Free up a Claude Code context window” is a separate URL.

The problem: A long Claude Code session fills the context window, and earlier instructions get summarized away at the wrong moment.

How do I fix this: Claude Code's context window filled up?

  1. See what is using the window

    Run /context. It draws current usage and points at heavy items, including which CLAUDE.md and auto memory files loaded. If the conversation is already past the window, the output warns how far over you are and which command frees space. Commands: https://code.claude.com/docs/en/commands

  2. Compact with a focus before the next task

    Run /compact with instructions, for example /compact focus on the auth bug fix. That summarizes the conversation so far and keeps what you name. Claude Code also compacts on its own as you near the limit, so a full window does not end the session, and that automatic pass works the same way as /compact. https://code.claude.com/docs/en/context-window

  3. Keep standing rules where compaction can reload them

    After a compact, the system prompt and output style still apply, and the project-root CLAUDE.md, unscoped rules, and auto memory are read from disk again. Rules with a paths frontmatter and nested CLAUDE.md files are summarized away and only come back when Claude next reads a matching file. If a rule has to survive every compact, drop the paths frontmatter or put it in the project-root CLAUDE.md. As of v2.1.198, the summary request uses your session's extended thinking setting.

  4. Clear unrelated work, or hand big reads to a subagent

    /clear starts a new conversation with empty context. Use it when you switch tasks. Use /compact when you still want this conversation. A subagent does research in its own window, so those file reads stay out of yours and only a summary comes back.

  5. Move the auto-compact point if it fires too late

    On Claude Code v2.1.221 or later, /autocompact 500k sets how full the window gets before the automatic pass, and /autocompact auto returns to the window tuned for your model. The value is saved in user settings. If you need a larger window instead, Fable models, Sonnet 5 and later, Haiku 5.5, Opus 4.6 and later, and Sonnet 4.6 support 1 million tokens, depending on your plan. https://code.claude.com/docs/en/context-window

Which tools are best to free up a Claude Code context window?

Claude Code

Terminal coding agent. /context, /compact, /clear and /autocompact manage the window.

Context window

What loads at startup, what survives /compact, and when the automatic pass runs.

Commands

/context shows usage, /compact summarizes, and /clear starts empty. /autocompact needs v2.1.221 or later.

All tools for “Free up a Claude Code context window” →

Related fixes

See also AI tools launched today on the daily board.