DEV Community

Cover image for Claude Code Context Window Size: 200K vs 1M, What Fills It
Nishil Bhave
Nishil Bhave

Posted on • Originally published at maketocreate.com

Claude Code Context Window Size: 200K vs 1M, What Fills It

Two bars comparing Claude Code context windows. The same 18,349 tokens of startup configuration fills 9.2 percent of a 200,000 token window and 1.8 percent of a 1,000,000 token window.

The first time I paid attention to my context window, it was because Claude Code compacted itself in the middle of a refactor and forgot a convention I had explained twenty minutes earlier. My first instinct was to blame the model. My second was to actually look.

What I found was worse and more useful: a meaningful slice of the window was already spent before I typed a single character. Not on my code. On my own configuration.

That is the part nobody puts in the answer. Search for "Claude Code context window size" and you get a number. The number is the least interesting thing about it.

Key Takeaways

Claude Code's context window is 200,000 tokens on most models and 1,000,000 tokens on Sonnet 5, Opus 4.6 and later, Sonnet 4.6, and Fable 5. On the Anthropic API, Sonnet 5 always runs at 1M with nothing to configure, and it is what the sonnet alias resolves to. The ceiling is rarely your problem. Your startup footprint is: in my own install, roughly 18,000 tokens of system prompt, CLAUDE.md, memory, and skill descriptions load before my first prompt. Run /context to see yours, and treat installed skills as a recurring tax rather than free capability.

How big is the Claude Code context window?

Claude Code's context window is 200,000 tokens by default, and 1,000,000 tokens on Fable 5, Sonnet 5, Opus 4.6 and later, and Sonnet 4.6.

Anthropic's own framing is the useful one here: more context is not automatically better. As token count grows, accuracy and recall degrade, a failure mode Anthropic calls context rot. Curating what sits in the window matters at least as much as how much room it has.

Three details matter more than the headline number.

On the Anthropic API, several models are always at 1M. Fable 5, Sonnet 5, and Opus 4.7 and later run with the million-token window as their normal state, not as an upgrade you enable. Sonnet 5 is the sharpest case: there is no 200K variant, no [1m] suffix to select, and no usage credits required on any plan.

Auto-compaction fires before the window fills, not when it does. Sonnet 5 sessions compact at about 967,000 tokens by default. You can move that with the CLAUDE_CODE_AUTO_COMPACT_WINDOW environment variable. The gap between the ceiling and the trigger is the reserved buffer, and /context shows it to you as its own slice.

Two configurations quietly drop Sonnet 5 back to 200K. If ANTHROPIC_BASE_URL points at an LLM gateway, Claude Code cannot verify 1M support, so it budgets 200K and compacts there instead. Select "Sonnet 5 (1M context)" in the model picker to get the full window back. Setting CLAUDE_CODE_DISABLE_1M_CONTEXT=1 does the same thing on purpose, for deployments that need a hard cap.

Haiku 4.5 is the outlier that stays at 200K with no extended option.

Grouped bar chart of Claude Code context windows by model: Haiku 4.5 is 200K with no upgrade, Sonnet 4.6 and Opus 4.6 default to 200K but reach 1M, and Sonnet 5 and Opus 5 run at 1M by default

What model does Claude Code use by default?

For most accounts, Claude Code's recommended model is Sonnet, and on the Anthropic API that alias resolves to Sonnet 5. That is the practical answer to the question people actually search for, and it is why the 1M window is now the common case rather than the exception.

The mechanics underneath are worth knowing, because "default" means two different things in Claude Code. The default option in the model picker is not itself a model. It is a special value that clears any override and reverts to the recommended model for your account type, or to an organization default if an admin has set one. The sonnet alias, by contrast, always points at the newest Sonnet your provider offers.

The full alias list:

Alias What it selects
default Clears overrides, reverts to the account or organization default
best Fable 5 where your org has access, otherwise the latest Opus
fable Claude Fable 5, for the hardest and longest-running tasks
sonnet Latest Sonnet, for daily coding
opus Latest Opus, for complex reasoning
haiku Fast and cheap, for simple tasks
sonnet[1m] / opus[1m] The 1M context variant
opusplan Opus during plan mode, then Sonnet for execution

Alias resolution is provider-specific, which trips people up more than it should:

Provider opus sonnet
Anthropic API Opus 5 Sonnet 5
Claude Platform on AWS Opus 5 Sonnet 4.6
Amazon Bedrock, Google Cloud Opus 5 Sonnet 4.5
Microsoft Foundry Opus 4.6 Sonnet 4.5

So the same /model sonnet gives you a 1M window on the Anthropic API and a 200K default on Bedrock. If your context math suddenly stops adding up after a provider change, start here.

Version floors bite too. Opus 5 needs Claude Code v2.1.219 or later, and Sonnet 5 needs v2.1.197. If a model is missing from your picker, run claude update before debugging anything else.

You can set the model four ways, in precedence order: /model <alias> during a session, claude --model <alias> at startup, the ANTHROPIC_MODEL environment variable, or the model field in your settings file. Since v2.1.153, picking in /model saves your choice as the default for new sessions; press s in the picker to change it for the current session only.

One correction worth making, because it circulates constantly: none of this requires a Max plan. Claude Code's entry point is Claude Pro at $20 per month, and the ladder runs Pro $20, Max 5x $100, Max 20x $200.

the full plan and rate-limit breakdown, including which tier suits sustained agentic work

What actually fills the window before you type

Here is the part I care about. Before your first prompt, Claude Code has already loaded the system prompt, your CLAUDE.md files, auto memory, MCP tool names, and a description for every installed skill.

Anthropic publishes a reference session with representative token counts, and they label those numbers as representative rather than measured, so treat them as a shape rather than a spec: system prompt 4,200, project CLAUDE.md 1,800, auto memory 680, user CLAUDE.md 320, skill descriptions 450, environment info 280, MCP tool names 120. That is roughly 7,850 tokens before anything happens.

Then I measured my own install, on the machine I write these posts on. Character count divided by four, which is a rough English approximation rather than a real tokenizer pass, so read these as the right order of magnitude and not to the digit:

  • 78 installed skills (74 user-level, 4 repo-level): about 9,200 tokens of names and descriptions
  • Project CLAUDE.md: about 2,338 tokens across 103 lines
  • Auto memory (MEMORY.md): about 2,205 tokens
  • Seven configured MCP servers, contributing tool names only, because full schemas are deferred by default

Add Anthropic's figure for the system prompt and environment block and my startup footprint lands near 18,000 tokens. On a 200K window that is roughly 9% gone before I say hello. On 1M it is under 2%, which is genuinely the strongest practical argument for the bigger window.

Stacked bar chart comparing startup context: Anthropic's reference session uses about 7,850 tokens while the author's install uses about 18,349, with skill descriptions the largest single difference

The skill count is the lever almost nobody pulls. Every installed skill puts its description into context at session start so the model knows the skill exists, whether or not you ever invoke it. Going from eight skills to seventy-eight is not a free expansion of capability; it is a standing charge on every session you will ever start.

Two documented fixes exist and both are underused. For skills you invoke by name and never want auto-triggered, set disable-model-invocation: true in the skill's frontmatter. For skills you did not write and cannot edit, skillOverrides in settings does the same thing. Either way the description stops loading until you ask for it.

How do I check my own context usage?

Everything above is a shape. Your install is the only thing that matters, and /context is the command that tells you:

/context
Enter fullscreen mode Exit fullscreen mode

It prints a live breakdown by category, names which CLAUDE.md and auto memory files actually loaded, offers optimization suggestions, and shows the reserved autocompact buffer as its own slice. It is the single highest-value command in Claude Code that most people have never run.

Three companions are worth the muscle memory. /usage reports session cost and, on a paid plan, attributes recent usage to skills, subagents, plugins, and individual MCP servers, flagging anything that accounts for 10% or more. /mcp shows per-server cost and lets you disable servers you are not using. /memory opens the memory files for editing.

If you want the number in front of you permanently, the status line can display context usage continuously, which beats remembering to check.

How does a real session consume the window?

Anthropic's reference session is a useful walkthrough because it accounts for the things you never see. Four file reads, two path-scoped rules loading automatically alongside matching files, a grep, two edits, a prettier hook firing after each one, a test run, a subagent, and a couple of slash commands. Total: about 22,225 tokens.

Waterfall chart of a Claude Code session consuming about 22,225 tokens, with 7,850 loaded automatically at startup before any user prompt and file reads adding a further 6,900

Two things jump out of that shape.

The first bar is the biggest single contributor and you did not cause it. Startup is 35% of the session's total context here, and in my own install it would be closer to half.

The subagent bar is almost invisible, and that is the point. It read three files in its own context window and returned a 420-token summary. Had those reads happened in the main conversation they would have cost several thousand tokens that never come back. This is the single most effective context lever Claude Code gives you.

how to structure subagent delegation so verbose work stays out of your main context

What happens when the context window fills up

Claude Code does not fail when you hit the limit. It clears older tool outputs first, then summarizes the conversation if that is not enough. Your requests and key code snippets survive. Detailed instructions from early in the conversation frequently do not, which is exactly the failure I opened this post with.

There is a wrinkle here that explains a lot of model-to-model difference in long sessions. Sonnet 5, Sonnet 4.6, Sonnet 4.5, and Haiku 4.5 have context awareness: the API injects their remaining token budget into every request, so they can pace a long task against the room that is actually left. Opus 4.7 and later, plus Fable 5, do not get those injected tags. If a Sonnet session feels like it starts wrapping up as the window fills while an Opus session keeps going regardless, that is why, and it is automatic on both sides rather than anything you configure.

What survives compaction is documented precisely, and the table is worth memorizing:

Mechanism After compaction
System prompt and output style Unchanged, never part of message history
Project-root CLAUDE.md, unscoped rules Re-injected from disk
Auto memory Re-injected from disk
Rules with paths: frontmatter Lost until a matching file is read again
Nested CLAUDE.md in subdirectories Lost until a file in that subdirectory is read again
Invoked skill bodies Re-injected, capped at 5,000 tokens per skill and 25,000 total, oldest dropped first
Hooks Unaffected, they run as code rather than context

The two "lost" rows explain most mystery regressions. A path-scoped rule loads into message history when its trigger file is read, so compaction summarizes it away with everything else. If a rule genuinely must survive, drop the paths: frontmatter or move it into the project-root CLAUDE.md.

The skill-truncation row has a practical consequence too: truncation keeps the start of the file, so the most important instructions belong near the top of any SKILL.md you write.

One failure mode to recognize. If a single file or tool output is large enough that context refills immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows a thrashing error rather than looping forever. That is a signal to /clear and change approach, not to retry.

You can also get ahead of it. /compact focus on the auth bug fix keeps what you choose instead of what the automatic pass guesses, and a "Compact Instructions" section in CLAUDE.md sets that preference permanently.

Does the 1M context window cost extra?

Per token, no. The 1M context window uses standard model pricing with no premium for tokens beyond 200K. That is a genuine difference from how long-context pricing has worked elsewhere, and it is easy to miss.

Availability is the part that varies:

Plan Opus with 1M Sonnet 4.6 with 1M
Max, Team, Enterprise Included with subscription Requires usage credits
Pro Requires usage credits Requires usage credits
API and pay-as-you-go Full access Full access

Sonnet 5 sidesteps the table entirely: on the Anthropic API it runs at 1M on every plan with no credits required.

The cost that does scale is recurring, and this is where a bigger window quietly gets expensive. Claude Code sends your full conversation with every request, and each tool use sends another request carrying that history. Prompt caching means you re-read it at cached rates rather than full price, but cached is not free. A one-line question in a session that has been open all day still draws usage for the entire conversation.

Cache misses make it worse. Your first message after a break longer than the cache lifetime reprocesses everything at full price. That lifetime is an hour on a subscription, and five minutes on an API key, a cloud provider, or once you are drawing on usage credits.

So the honest framing is this: 1M does not make long sessions cheap. It makes them possible. /clear remains free, and /compact is itself a large request because it has to read the conversation it summarizes.

Seven levers that actually reclaim context

In rough order of how much they return for the effort:

  1. /clear between unrelated tasks. Costs nothing and returns everything. Use /rename first if you might want the session back via /resume.
  2. Delegate verbose reads to subagents. Log processing, documentation fetches, wide codebase exploration. The output stays in their window; a summary comes back to yours.
  3. Trim your skills. disable-model-invocation: true for skills you always invoke by name, skillOverrides for skills you did not write. This was worth roughly 9,000 tokens per session in my install.
  4. Keep CLAUDE.md under 200 lines. Anthropic's own guidance. Workflow-specific detail belongs in skills, which load on demand, rather than in a file that loads every session regardless of what you are doing.
  5. Prefer CLI tools over MCP servers. gh, aws, gcloud, and sentry-cli add no per-tool listing at all. MCP schemas are deferred by default, but names still cost something, and /mcp will show you which servers are worth keeping.
  6. Preprocess with hooks. A PreToolUse hook that greps a log for ERROR before Claude sees it turns tens of thousands of tokens into hundreds.
  7. Write specific prompts. "Improve this codebase" triggers broad scanning. "Add input validation to the login function in auth.ts" does not.

configuring MCP servers, including tool search and per-server context cost

exploring before editing, which keeps file reads purposeful instead of speculative

Where this stops and architecture begins

Everything above is Claude Code mechanics: the numbers, the commands, the settings. It is deliberately not a theory of context design.

If you are building your own agentic system and need the patterns rather than the CLI, that is a different problem with a different shape, covering retrieval, reranking, and where accuracy degrades inside a long window.

the architecture-level patterns for designing context-limited systems, from retrieval through compaction

the 1M-context model built for long autonomous sessions, and when the extra capability pays

FAQ

How big is Claude Code's context window?

200,000 tokens by default, and 1,000,000 tokens on Fable 5, Sonnet 5, Opus 4.6 and later, and Sonnet 4.6. On the Anthropic API, Fable 5, Sonnet 5, and Opus 4.7 and later always run with the 1M window. Haiku 4.5 stays at 200K with no extended option.

What model does Claude Code use by default?

Sonnet, which resolves to Sonnet 5 on the Anthropic API. On Amazon Bedrock and Google Cloud the same sonnet alias resolves to Sonnet 4.5, and on Microsoft Foundry to Sonnet 4.5, so your default window size depends on your provider as well as your alias. Switch with /model.

How do I check how much context I am using?

Run /context for a live breakdown by category, including which CLAUDE.md and auto memory files loaded and how much is reserved for the autocompact buffer. /usage adds cost and plan-limit attribution, and /mcp shows per-server cost. You can also surface context usage continuously in your status line.

Does the 1M context window cost more per token?

No. It uses standard model pricing with no premium beyond 200K. What does scale is the recurring cost: your full conversation is re-sent with every request, at cached rates when the cache is warm and at full price after a cache miss. A bigger window raises the floor on every turn of a long session.

What gets lost when Claude Code compacts?

Your requests and key code snippets are preserved. Project-root CLAUDE.md and auto memory are re-injected from disk. Rules with paths: frontmatter and nested CLAUDE.md files are lost until a matching file is read again, and invoked skill bodies come back truncated to 5,000 tokens each and 25,000 total, oldest dropped first. Detailed instructions given early in a conversation are the most common casualty, which is why persistent rules belong in CLAUDE.md rather than in chat.

The number that matters

The ceiling is a spec. Your startup footprint is a choice, and it is the one you can actually change.

Run /context once, right now, on a project you work in daily. If the number surprises you, the fix is usually not a bigger window. It is fewer skills loaded by default, a shorter CLAUDE.md, and the habit of typing /clear when you move to something new.

Top comments (0)