The Claude Code context window: what it holds and how large it is
The context window is Claude’s working memory for one session. Anthropic: “Claude’s context window holds your conversation history, file contents, command outputs, CLAUDE.md, auto memory, loaded skills, and system instructions.” (How Claude Code works) It is the thing to watch in a long session: “Claude’s context window fills up fast, and performance degrades as it fills.” (Best practices)
Its size, the context limit, depends on the model. Anthropic’s help center: “On paid plans, the newest models support up to a 1M token context window, while others support 500K or 200K tokens.” (How do usage and length limits work?) The help center’s table for Claude Code lists 1M tokens for every model in it, with a note on Opus 4.6 and Sonnet 4.6. (How large is the context window on paid Claude plans?)
That note is where the plan comes in: “Opus 4.6 and Sonnet 4.6 reach 1M only through their [1m] variant, and access to that variant depends on your plan.” The newer models need no such step: “On the Anthropic API, Fable 5.1, Fable 5, Sonnet 5 and later, and Opus 4.7 and later run with the 1M window on every plan, including Pro.” (Model configuration)
/clear: a new conversation with empty context
The command reference describes /clear in one sentence: “Start a new conversation with empty context.” /reset and /new do the same. (Commands)
The old conversation is kept: “Running /clear starts a new session; the previous one stays stored and is available via /resume.” (Glossary) Anthropic’s tip for finding it again: “Use /rename before clearing so you can easily find the session later, then /resume to return to it.” (Reduce token usage)
A new session does not forget your project. “Each Claude Code session begins with a fresh context window. Two mechanisms carry knowledge across sessions:” CLAUDE.md files and auto memory. (How Claude remembers your project)
/compact: summarize the conversation and keep working
/compact keeps you in the same conversation and shrinks it: “Free up context by summarizing the conversation so far. Optionally pass focus instructions for the summary.” (Commands) Anthropic’s example of a focus: “/compact Focus on code samples and API usage tells Claude what to preserve during summarization.” (Reduce token usage)
What survives is documented: “Project-root CLAUDE.md and auto memory survive compaction and reload from disk; instructions given only in conversation may be lost.” (Glossary) The full table is in What survives compaction.
Compacting is work in itself. “/compact reads the conversation it summarizes, so compacting a large context is itself a large request. When you want a fresh start instead of continuity, /clear costs nothing” (Manage costs effectively). On timing, Anthropic advises: “run /compact at a natural break in your work, such as between tasks, instead of waiting for auto-compaction to trigger mid-task.” (Prompt caching)
Auto-compact: when it runs and how to change it
If you type neither command, Claude Code compacts on its own: “Claude Code compacts automatically as you approach the limit, so a full context window doesn’t end your session.” (Explore the context window) It goes in two steps: “It clears older tool outputs first, then summarizes the conversation if needed.” (How Claude Code works)
There is no single trigger point: “The point where automatic compaction runs depends on your model and configuration.” (Explore the context window) Two documented defaults: “Models running with a native 1M window compact before the window fills, at about 967K tokens by default.” And: “Sonnet 4.6 and Opus 4.6 without extended context compact at the 200K boundary”. (Default auto-compact thresholds)
You can move that point: “run /autocompact with a token count, like /autocompact 500k, to set how full the context window gets before the automatic pass runs.” (Explore the context window) The command needs Claude Code v2.1.221 or later and accepts “a window size from 100K to 1M tokens”. (Commands, Set the auto-compact window)
To switch it off, turn off Auto-compact in /config (setting autoCompactEnabled). “The manual /compact command keeps working while auto-compact is off.” (All settings)
/context: see what fills the window
Before you clear or compact, look at what is in there. “The /context command shows everything occupying the context window for the current session, broken down by category: system prompt, system tools, MCP tools, custom subagents with the source each loaded from, memory files, skills, and conversation messages.” (Debug your configuration)
The command reference adds that it “Shows optimization suggestions for context-heavy tools, memory bloat, and capacity warnings.” (Commands)
Why a long context uses more of your limit
A full window is not only a quality problem. “Token costs scale with context size: the more context Claude processes, the more tokens you use.” (Reduce token usage)
The reason: “Claude Code sends your full conversation with every request”. For subscribers that means: “A session that has been open for hours can use far more of your plan limits than your activity suggests”. (Manage costs effectively)
Hence Anthropic’s tip: “Use /clear to start fresh when switching to unrelated work. Stale context wastes tokens on every subsequent message.” (Reduce token usage) What to do once a limit is reached is in our guide Claude usage limit reached — what to do.
/clear or /compact: which one to use when
A short rule that follows from the quoted docs. It is our summary, not a new fact:
- New, unrelated task: type
/clear;/renamethe session first if you may want it back. Also when Claude keeps repeating a mistake: “After two failed corrections,/clearand write a better initial prompt incorporating what you learned.” (Best practices) - Same task, long session: type
/compactwith a focus at a natural break. “The summary keeps what you choose instead of what the automatic pass guesses is important.” (Explore the context window) - Everything else: let auto-compact handle it, and keep rules that must survive in CLAUDE.md. “Put persistent rules in CLAUDE.md rather than relying on conversation history.” (How Claude Code works)
One more option: Grace
Our own product — this section is advertising.
/clear and /compact keep a single session lean. Grace is our product for Claude Code on Mac and Windows: you install it once, keep typing your tasks as usual, and the same work uses less of your plan’s limit. We measured it against Claude Code with caveman and context-mode installed:
Test result
≈ −49 % of the 5-hour limit for the same 60 tasks.
Measured against Claude Code with two token-saving plugins already installed: caveman and context-mode.
Read from the limit in whole percentage points, two measurements added up: 32 % with Grace 0.3.8, 63 % with Claude Code + caveman + context-mode · 60 tasks, Claude Max 20x on both sides · October 2 – 3, 2026: 30 tasks at the same time on two accounts, 30 with the comparison run measured separately on the same day · on the comparison account 54 s of readings are missing at a 5-hour reset, which can only make the saving look smaller
≈ 96–100 %more work in the same limit
Calculated from the limit value above: ≈ 96 % more. On 43 of the 58 tasks both runs finished, at least twice as much: 2.0× to 4.4×, calculated from Claude’s cost per task (quality on those: 94 % with Grace, 93 % Claude alone). 2 more such tasks are not counted because of their quality (45 % with Grace, 93 % Claude alone).
49 %less time
Measured at the same time with Grace 0.3.8 (October 3, 2026): 3 h 41 min with Grace, 7 h 10 min Claude alone — the time of all 30 tasks, added up. Grace was faster on 28 of them; quality: 93 % with Grace, 90 % Claude alone. Only the 30 tasks measured at the same time are compared on time; the other 30 were measured separately.
All measurements, task by task Token savers, measured
Try it yourself: your first month is free, and /usage shows the difference on your own work.
Just create an account · no payment details · ends on its own
Questions
What does /compact do in Claude Code?
It summarizes the conversation so far to free up context, and you keep working in the same conversation. You can add a focus, for example /compact Focus on the API changes. Source: Claude Code docs: Commands.
What is the difference between /clear and /compact?
/clear starts a new conversation with empty context; the previous one is saved and can be reopened with /resume. /compact stays in the conversation and replaces the history with a summary. Source: Claude Code docs: Manage sessions.
How do I clear the context in Claude Code?
Type /clear. CLAUDE.md and auto memory load again in the new conversation, because they carry knowledge across sessions. Source: Claude Code docs: How Claude remembers your project.
How big is the Claude Code context window?
It depends on the model. Anthropic’s help center lists 1M tokens for the models in its Claude Code table; Opus 4.6 and Sonnet 4.6 reach that only through a [1m] variant, and access to it depends on your plan. Source: How large is the context window on paid Claude plans?.
When does Claude Code auto-compact?
When the conversation approaches the context limit. The exact point depends on your model and configuration; for models running with a native 1M window the docs give about 967K tokens by default. Source: Claude Code docs: Model configuration.
Can I turn off auto-compact in Claude Code?
Yes: turn off Auto-compact in /config, and the manual /compact command keeps working. To move the trigger point instead, use /autocompact. Source: Claude Code docs: All settings.
Sources
Anthropic’s pages, checked on 5 October 2026. Anthropic changes commands, models and wording from time to time — their pages are what counts.
- Claude Code docs: Commands code.claude.com
- Claude Code docs: Explore the context window code.claude.com
- Claude Code docs: How Claude Code works code.claude.com
- Claude Code docs: Model configuration code.claude.com
- Claude Code docs: Manage costs effectively code.claude.com
- Claude Code docs: How Claude Code uses prompt caching code.claude.com
- Claude Code docs: How Claude remembers your project code.claude.com
- Claude Code docs: Manage sessions code.claude.com
- Claude Code docs: Best practices for Claude Code code.claude.com
- Claude Code docs: Debug your configuration code.claude.com
- Claude Code docs: All settings code.claude.com
- Claude Code docs: Glossary code.claude.com
- How do usage and length limits work? support.claude.com
- How large is the context window on paid Claude plans? support.claude.com