The Claude Code context window is a session's working memory: it holds your messages, Claude's responses, the files it read, command output, CLAUDE.md, auto memory, your skill descriptions and the system instructions. According to Anthropic, the current models Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.1 run in Claude Code with a 1 million token window by default. When it fills up, Claude Code summarizes the conversation automatically, which is called compaction; on these models that happens at about 967,000 tokens by default, and in the terminal since version 2.1.299 of October 14, 2026, also when a conversation of 200,000 tokens or more sits idle for about 54 minutes. After compaction, Claude Code reloads the project-root CLAUDE.md and auto memory fresh from disk; instructions given only in chat can get lost. A new session starts with a fresh context into which only CLAUDE.md and auto memory load automatically; you continue an old conversation with /resume. And because every request sends the whole conversation, a long session draws more from your allowance than a single question would suggest.
Two of my AI employees, Conny and Ralf, regularly run in long, continuous sessions. What follows comes from Anthropic's documentation and changelog, retrieved on October 26, 2026. This article is not about Claude's memory in the chat app; that is covered in Claude Memory: Check It and Use It. Everything about Claude is collected on my Claude page.
What is in the context window
Anthropic describes a session in three phases. Before you type anything, CLAUDE.md (or an AGENTS.md in its place), auto memory, MCP tool names and your skill descriptions load; plus an output style if you set one. As Claude works, every file read is added, every command output, rules scoped to certain paths once Claude touches a matching file, and the output of hooks. A subagent reads in its own context window, and only its summary comes back.
What a component costs depends on when it loads:
To see what takes up space in your own session, run /context: a breakdown by category with suggestions, which CLAUDE.md and auto memory files loaded, and with /context all the tokens per MCP tool.
How big the context window is
According to Anthropic, Fable 5.1, Fable 5, Sonnet 5 and later, Haiku 5.5, and Opus 4.7 and later run in Claude Code with 1 million tokens by default, including on Amazon Bedrock, Google Cloud and Microsoft Foundry. Opus 4.6 and Sonnet 4.6 reach 1 million only through their variant with the [1m] suffix, and whether that is included depends on your plan. If you deliberately want to stay at 200,000 tokens, set CLAUDE_CODE_DISABLE_1M_CONTEXT=1; Claude Code then compacts at that boundary.
A large window does not mean you should fill it. On the API, the range above 200,000 tokens costs the normal model price according to Anthropic; only Haiku 5.5 costs more on prompts above 100,000 tokens. On a subscription you don't pay per token, but every request draws from your allowance, and a request carrying 600,000 tokens of history draws more than one with 60,000. Which models exist and what I use each one for is in Claude Models: Opus, Sonnet, Haiku, Fable.
Compaction: automatic, manual and while idle
According to Anthropic's glossary, compaction is the automatic summarization of your conversation when the context window approaches its limit. It happens in three ways.
Automatically. According to the docs, models with 1 million tokens compact at about 967,000 tokens by default, Sonnet 4.6 and Opus 4.6 without [1m] at the 200,000 boundary. With /autocompact you set your own value, for example /autocompact 500k; anything from 100,000 to 1 million tokens is allowed. Claude Code saves the value per model in your settings. For every model, use the autoCompactWindow settings entry; for a single launch the --autocompact flag; in scripts the CLAUDE_CODE_AUTO_COMPACT_WINDOW variable. Since version 2.1.296 of October 9, 2026, a single subagent can also compact earlier than the main conversation with autoCompactWindow.
Manually. /compact compacts right away, ideally with a focus such as /compact focus on the auth bug fix. That way the summary keeps what you choose instead of what the automatic pass guesses is important. With /rewind you can also summarize only part of the conversation, from or up to a message you pick.
While idle. Since version 2.1.299 of October 14, 2026, Claude Code in the terminal compacts a conversation of 200,000 tokens or more that has been idle for about 54 minutes, before the one-hour prompt cache expires. Your next message then sends a summary instead of the whole history. You can tell by a line that starts with "Compacted while idle, before the prompt cache expired". You change the 200,000 threshold with CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS (minimum 100,000) and turn the feature off with "idleCompaction": false or, since version 2.1.302 of October 16, 2026, in /config. In the VS Code extension and the desktop app it only runs for accounts Anthropic selects, according to the docs.
Two things about compaction itself: according to the docs it is a large request in its own right, because it reads the whole conversation it summarizes. If you want a fresh start anyway, /clear costs nothing. And if a single huge file or output refills the context right after every summary, Claude Code stops after a few attempts and shows an error instead of compacting in a loop.
What survives compaction
Whether something survives compaction depends on how it was loaded, according to the docs:
Three practical rules follow from this. Whatever should always apply belongs in the project-root CLAUDE.md, not in the chat. Put the most important part of a skill at the top of its SKILL.md, because truncation keeps the start. And you can tell the summary what to keep in a "Compact Instructions" section of your CLAUDE.md.
What every new session loads: CLAUDE.md and auto memory
According to Anthropic, every session starts with a fresh context window. Only two sources load automatically at start, and both then travel with every request:
- CLAUDE.md, the instructions you write: Claude Code loads every file that applies at launch in full, as long as it is no larger than 4 MiB.
- Auto memory, the notes Claude writes itself: only the start of
MEMORY.md loads, the first 200 lines or 25 KB. Claude reads the detail files only when needed. Auto memory is on by default in local sessions.
Claude Code reloads both fresh from disk after compaction. /context shows which files are loaded, and /memory lets you open and edit them. One thing to keep in mind: according to Anthropic, both are context, not enforced configuration. Anything that must hold in every case is enforced with a PreToolUse hook; without managed settings and without a Team or Enterprise login, though, an installed mod can override a hook's block, details in Claude Code Hooks: Rules That Always Apply. How CLAUDE.md and AGENTS.md work together is in CLAUDE.md vs AGENTS.md: What Survives.
An old conversation is not lost with a new session: you continue it with /resume, and its history is back in context. That is exactly what can draw on your allowance, as the next section shows.
Context and limits: why long sessions draw on your allowance
According to Anthropic, Claude Code is included in all paid plans and draws from the same pool as the chat. Limits depend on the plan: Pro and Max have a rolling five-hour window and weekly limits. Verified Ultra accounts have no five-hour limit, but retain a weekly limit; unverified accounts may temporarily have an additional limit. Anthropic gives no fixed message count because conversation length also matters (Anthropic on Ultra, checked 31 October 2026).
That is where context comes in. According to the docs, Claude Code sends the whole conversation with every request, and after each tool use another request with the results. Thanks to the prompt cache it re-reads the history at the cheaper cache rate, but "a one-line question in a session that has been open all day still draws usage for the whole conversation". After a break longer than the cache lifetime, the first message reprocesses the full context. Scheduled tasks, messages from other sessions, subagents and workflows send requests of their own as well.
Anthropic added two things for this in October. Idle compaction, from October 14, 2026, compacts an idle conversation before the cache expires. And since version 2.1.304 of October 19, 2026, Claude Code warns on Pro and Max when resuming an old conversation would use a noticeable share of the five-hour limit: you can resume anyway or start fresh, and Claude can look up the old conversation if you refer to it.
/usage shows where you stand: on Pro, Max, Team and Enterprise with bars for your plan limits and a breakdown that recommends a change for behaviors behind 10 percent or more of your recent usage, such as long context or cache misses. The status line keeps this visible: on Pro and Max it receives five-hour and weekly limit usage plus context usage as fields. How to set that up is in my guide to the Claude Code status line.
/compact or /clear: which one when?
The short answer: /compact summarizes the conversation so far, and you keep working on the same task. /clear starts a new conversation with empty context; according to the docs, your project memory stays: the new conversation loads CLAUDE.md and auto memory too, as described above under "What every new session loads". Anthropic draws the line itself: to free up context while continuing the same conversation, use /compact instead of /clear.
Three examples, made up for illustration:
- Bug fixed, now the docs. You have repaired a login bug and want to rework the README next. That has nothing to do with the login, so
/clear. If you want to come back later, name the old conversation first with /rename, or use /clear login-fix straight away; according to the docs, the name then shows up in the /resume picker.
- In the middle of a refactor. You are migrating a module, three steps are still missing, and
/context shows a full history. Here, /compact focus on the remaining steps and the files changed so far keeps the plan intact.
- The third attempt. Claude introduces the same bug for the third time. In this case the docs do not suggest
/compact but /clear and a new, more specific prompt that already contains what you learned. According to Anthropic, a clean session with a better prompt almost always outperforms a long session full of corrections.
Two things help with the decision. First, /clear costs nothing, while /compact is a large request in its own right, as described above. Second, /clear is not a deletion with no way back: you bring the old conversation back with /resume, and within the same Claude Code process the /rewind menu shows an entry at the top for the session before the /clear. According to the docs, /reset and /new are other names for /clear.
Seven habits for a lean context
- Run
/context more often. It shows what takes up space and suggests cuts.
/clear between tasks. When /clear fits and when /compact does is in the section "/compact or /clear: which one when?" above.
- Before a long new task,
/compact with a focus. The examples are in the same section.
- Hand big reading jobs to subagents. The files stay in their context, and only the summary comes back. How I set that up is in Claude Code Subagents: Best Practices.
- Mark skills you only invoke yourself with
disable-model-invocation: true. Then their description is not in every request; for skills you didn't write, use skillOverrides in your settings.
- Enable plugins sparingly. Every enabled plugin brings its descriptions into every session, even when it does nothing; how to see the context cost beforehand is in Claude Code Plugins: Install, Build, Trust.
- Permanent rules go into the project-root CLAUDE.md, not the chat. That is the only way they reliably survive compaction. Anthropic recommends keeping it under 200 lines.
Frequently asked questions
How big is the Claude Code context window?
With the current models Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.1, 1 million tokens according to Anthropic, by default and without a suffix. Opus 4.6 and Sonnet 4.6 have 200,000 tokens without their [1m] variant. With CLAUDE_CODE_DISABLE_1M_CONTEXT=1 you stay at 200,000.
What happens when the context window is full?
Claude Code summarizes the conversation automatically and keeps working; on models with 1 million tokens, at about 967,000 tokens by default. It then reloads the project-root CLAUDE.md and auto memory fresh, while instructions from the chat can get lost.
Does my CLAUDE.md survive compaction?
The project-root CLAUDE.md does: Claude Code reloads it fresh from disk afterwards. CLAUDE.md files in subdirectories and rules with paths: only come back once Claude touches a matching file. Instructions given only in chat stay only as far as the summary keeps them.
What is idle compaction?
Since version 2.1.299 of October 14, 2026, Claude Code in the terminal compacts a conversation of 200,000 tokens or more that has been idle for about 54 minutes, before the one-hour prompt cache expires. That way your next message doesn't have to reprocess the whole history. You can turn it off with "idleCompaction": false or in /config.
Does a large context window use more of my allowance?
Not the window, but what is in it. Claude Code sends the whole conversation with every request; the longer it gets, the more each question draws from your allowance. That is why /clear between tasks and subagents for big reading jobs pay off.
What is the difference between /compact and /clear?
/compact summarizes the conversation so far, and you keep working on the same task. /clear starts a new conversation with empty context, though Claude Code still loads CLAUDE.md and auto memory. Rule of thumb from the docs: a new, unrelated task means /clear, the same task with a long history means /compact.
Where to go from here
In your next session, run /context once and see what is already loaded at start, before you have typed anything. Then clean up where it costs you permanently: skill descriptions, plugins, an overly long CLAUDE.md. How to keep big tasks out of your main conversation is in Claude Code Subagents: Best Practices. Which components cost how much context, and when to use which, is in Claude Code Extensions: Plugins, Mods, Skills. How others organize their sessions and AI employees is what I show in my community AI Employee Framework.