Kipt

Claude Code context window: what fills it and how to manage it

How the Claude Code context window works: what loads before you type, /context, /compact, auto-compaction, what survives it, 1M token models, and tips.

By the Kipt team · Updated 24 October 2026

The Claude Code context window holds everything Claude knows about your session: your CLAUDE.md, the files it reads, command output, its own replies and instructions you never see in the terminal. Run /context to see what's using it, /compact to summarize and free space, and /clear to start fresh. When it fills up, Claude Code compacts automatically so the session continues.

Anthropic's best practices page calls it "the most important resource to manage," because "LLM performance degrades as context fills." This guide explains what fills it and what you can do about it, based on the official docs checked on 24 October 2026.

What fills the Claude Code context window?

According to Anthropic's context window walkthrough, context builds up in three stages.

Before you type anything, Claude Code loads:

  • your CLAUDE.md files (or AGENTS.md in their place)
  • auto memory
  • MCP tool names (full tool definitions are deferred until a tool is used)
  • skill descriptions (the full skill body loads only when the skill runs)
  • an output style or --append-system-prompt text, if you use them

As Claude works, every file it reads adds to context. Path-scoped rules load when Claude touches a matching file, and hook output gets added when hooks fire.

Over the conversation, every message, every tool result and every reply stays in context. The best practices page notes that "a single debugging session or codebase exploration might generate and consume tens of thousands of tokens."

Claude Code also adds its own context alongside your messages, such as a note when a file changes on disk and the commit attribution lines, as explained in how Claude Code works.

How big is the context window?

It depends on the model. The model configuration docs list which models support a 1 million token window:

Model Context window in Claude Code
Fable 5.1, Fable 5, Sonnet 5 and later, Haiku 5.5, Opus 4.7 and later 1M by default, no suffix needed
Opus 4.6, Sonnet 4.6 200K, or 1M through the [1m] variant

For Opus 4.6 and Sonnet 4.6, the [1m] variant depends on your plan. On Max, Team and Enterprise, Opus 4.6 with 1M context is included; Sonnet 4.6 with 1M needs usage credits on every subscription plan. Pro needs usage credits for both. On the API, both have full access. Select it like this:

/model claude-opus-4-6[1m]
/model claude-sonnet-4-6[1m]

On the Anthropic API, the 1M window uses standard pricing with no premium beyond 200K tokens, except Haiku 5.5, which costs more on prompts longer than 100K tokens. To hold every model at 200K, set CLAUDE_CODE_DISABLE_1M_CONTEXT=1.

A bigger window is not a reason to stop managing context. Performance still degrades as it fills, and stale context costs tokens on every message.

How do you check context usage with /context?

Run /context at any point. The commands reference describes it as a way to "visualize current context usage as a colored grid," with optimization suggestions for context-heavy tools, memory bloat and capacity warnings. It also shows which CLAUDE.md and auto memory files loaded. In fullscreen mode, where the per-item breakdown is collapsed, run /context all to expand it.

For a live readout, add a status line. Claude Code passes context_window.used_percentage and context_window.context_window_size to your status line script; our statusline guide shows a working setup. /usage shows session cost and plan usage, which is a separate number.

How do /compact and auto-compaction work?

/compact frees up context by summarizing the conversation so far. Add instructions to steer the summary:

/compact focus on the auth bug fix and the list of files changed

Claude Code also compacts automatically as you approach the limit. The docs say it "clears older tool outputs first, then summarizes the conversation if needed. Your requests and key code snippets are preserved; detailed instructions from early in the conversation may be lost."

When it runs depends on the model. Models with a native 1M window compact at about 967K tokens by default. Opus 4.6 and Sonnet 4.6 without extended context compact at the 200K boundary. You can change the point with /autocompact:

/autocompact 500k
/autocompact auto

It accepts 100K to 1M tokens, saves the value for the current model, and auto returns to the default. For one launch, use claude --autocompact; in scripts, set CLAUDE_CODE_AUTO_COMPACT_WINDOW.

You can also compact part of a conversation. Press Esc twice on an empty prompt, or run /rewind, pick a message, and choose Summarize from here or Summarize up to here.

What survives compaction?

This is the part most people get wrong. From the context window docs:

Content After compaction
System prompt and output style Still apply
Project-root CLAUDE.md and unscoped rules Re-injected from disk
Auto memory Re-injected from disk
A plan written in plan mode Re-injected from disk
Rules with paths: frontmatter, nested CLAUDE.md files Reload only when Claude touches a matching file again
Files Claude read or edited Up to five re-read, most recently modified first
Invoked skill bodies Re-injected, up to 5,000 tokens per skill and 25,000 total
Context added by hooks Summarized with the rest of the conversation

Two practical lessons follow. If a rule must survive compaction, put it in the project-root CLAUDE.md, not in a path-scoped rule or a message you typed early on. And because truncated skills keep the start of the file, put a skill's most important instructions near the top of SKILL.md. Our memory guide covers where CLAUDE.md files and rules live.

You can also add a "Compact instructions" section to CLAUDE.md, such as "When compacting, always preserve the full list of modified files and any test commands," so automatic compaction keeps what you need.

How do you keep context small?

These habits come from the best practices and costs docs:

  • Run /clear between unrelated tasks. Old conversation crowds out what Claude needs next. Use /rename first if you want to /resume it later.
  • Send research to subagents. A subagent reads files in its own context window and returns only a summary.
  • Ask side questions with /btw. The answer never enters conversation history.
  • Keep CLAUDE.md short. The docs suggest under 200 lines per file; move workflows you need only sometimes into skills, which load on demand.
  • Prefer CLI tools and disable unused MCP servers with /mcp.
  • Write specific prompts. "Improve this codebase" makes Claude scan broadly; "add input validation to the login function in auth.ts" doesn't.
  • Filter noisy output with hooks. A hook can trim a 10,000-line log down to the error lines before Claude reads it.

Extended thinking also produces tokens. If you raise the effort level or use ultrathink often, see our ultrathink guide for the trade-offs, and our Claude Code tips for more context habits.

Where can you keep the context you reuse?

The best way to save context is to stop retyping it. A tight project brief, a review checklist or a compaction instruction you trust can live as a prompt or skill instead of a message you paste each session. Kipt keeps prompts and Agent Skills as Markdown in a private GitHub repo you own, and installs every skill into Claude Code with one npx skills add command, so the instructions load only when you need them.

Questions

How big is the Claude Code context window?

It depends on the model. Fable models, Sonnet 5 and later, Haiku 5.5, and Opus 4.7 and later run with a 1 million token window by default. Opus 4.6 and Sonnet 4.6 use 200K unless you select their [1m] variant, which depends on your plan.

How do I check how much context I'm using in Claude Code?

Run /context. It shows current usage as a colored grid, with suggestions for context-heavy tools, memory bloat and capacity warnings. For a constant readout, configure a status line that shows context_window.used_percentage.

What happens when the Claude Code context window is full?

Claude Code compacts automatically as you approach the limit, so the session keeps going. It clears older tool outputs first, then summarizes the conversation if needed. Your requests and key code are kept, but detailed instructions from early in the conversation may be lost.

What is the difference between /compact and /clear?

/compact replaces the conversation with a summary so you can keep working on the same task with more room; you can add focus instructions. /clear starts a new conversation with empty context, which suits switching to unrelated work.

How do I make Claude Code compact earlier?

Run /autocompact with a token count, for example /autocompact 500k, to set how full the context gets before automatic compaction runs. It accepts values from 100K to 1M tokens and saves the setting for the current model. /autocompact auto returns to the default for your model.

Will Claude Code forget my CLAUDE.md after compaction?

No. The project-root CLAUDE.md, unscoped rules and auto memory are re-injected from disk after compaction. Rules with paths frontmatter and nested CLAUDE.md files in subfolders reload only when Claude touches a matching file again.

More in Claude Code

All guides

Keep your prompts and skills in one place, in your own GitHub. Install every skill with one command.

Get started

Kipt is an independent product, not affiliated with or endorsed by Anthropic, OpenAI, Cursor or GitHub. Claude, ChatGPT, Codex, Cursor and GitHub are trademarks of their owners.