Claude Code Context Window: Your AI's Working Desk

What is the Claude Code context window, how big is it, what eats the space, and what /context, /compact and /clear really do — explained with a desk.

claude-codefoundationscontext-windowtokens
Updated 2026-06-12EAEvgenii ArsentevEvgenii Arsentev · PhD

Reviewed for accuracy by Evgenii Arsentev, PhD · 2026-06-12

The context window is everything Claude can 'see' at one moment: your conversation, the files it has read, command outputs, and its instructions — all sharing one limited space. Picture a working desk: roomy, but finite, and every paper you put on it leaves less room for the next one. Once you understand the desk, half of Claude Code's odd behaviors stop being odd.

This is the single most useful mental model I teach, because context is the real currency of working with AI — not prompts, not magic words. Let's measure the desk, see what's already lying on it, and learn the three commands that keep it clean.

Claude Code context window size: how big is it?

The standard window in Claude Code is 200,000 tokens. A token is roughly three-quarters of an English word, so 200K tokens is about 150,000 words — think 'a long novel'. Sounds infinite; it isn't. Real projects burn through it surprisingly fast, because the desk doesn't just hold your messages.

Can I increase the context window to 1M tokens?

On some plans, yes. A few models offer a 1-million-token variant for long sessions with large codebases — selectable as opus[1m] or sonnet[1m] in the /model picker, with availability depending on your plan. It's a bigger desk, same physics: the limit just moves further out, and everything below about keeping it clean still applies.

What's on the desk before you type a word?

This surprises everyone: the desk is never empty. Before your first message, Claude Code loads the system prompt (its standing instructions), your CLAUDE.md files with project rules, auto memory (its own notes from past sessions), one-line descriptions of available skills, and the names of connected MCP tools. Then the real eater arrives: file reads. Every file Claude opens lands on the desk in full — a single source file can cost a few thousand tokens, and you only see a one-line 'Read file' notice in the terminal while the whole content sits in context. File reads dominate context usage; that's the docs' phrase, not mine.

What happens when the context window is full?

Claude Code doesn't crash — it compacts. As you approach the limit, it replaces the conversation with a structured summary: your requests, key decisions and important code snippets survive, while the verbatim details — full tool outputs and intermediate reasoning — are dropped. After compaction, CLAUDE.md and auto memory are re-read from disk automatically — which is exactly why persistent rules belong in CLAUDE.md, not in something you said an hour ago. The desk analogy holds: compaction is sweeping the papers into a folder with a one-page summary stapled on top. Workable, but the fine print is gone.

Why Claude 'forgets' your instruction from this morning

When people complain that Claude forgot what they told it, the context window is the culprit almost every time. The instruction either got compacted away or drowned under fifty file reads. The fix is mechanical, not psychological: put it in CLAUDE.md — that file is reloaded every session and re-injected after every compaction.

Context window management: how to keep the desk clean

Three commands and one habit. /context shows a live breakdown of what's using space — run it whenever Claude starts acting tired. /clear wipes the conversation entirely: use it between unrelated tasks, because yesterday's debugging crowds out today's files. /compact summarizes on your terms — and you can aim it: /compact focus on the API changes keeps what you choose instead of what the automatic pass guesses.

Check your desk right now
/context

Shows what's occupying your context window by category — conversation, files, tools, memory — with optimization suggestions. The single most underused command in Claude Code.

Sweep with a focus
/compact focus on the payment bug

Compacts the conversation but tells the summarizer what matters. Run it before starting a long new task inside an old session — on your terms, before the automatic pass runs on its own.

How do subagents save context?

This is the one habit behind the three commands: delegate big research to subagents. A subagent reads its pile of files on its own separate desk and brings back only a short summary to yours. Instead of fifty file reads landing in your context, you get a few paragraphs — the difference between a clean desk at the end of a long task and a buried one.

Five minutes: watch your own desk fill up

0/5

The mindset shift that follows

Once you see the desk, your habits change by themselves: you stop one endless mega-chat and start fresh sessions per task; you stop pasting whole documents 'just in case'; you start writing rules into CLAUDE.md instead of repeating them. Next time Claude gives a strangely sloppy answer deep into a long session, don't argue with it — run /context, look at the desk, and either /compact with a focus or /clear and restate the task in two tight sentences. You'll fix in ten seconds what an hour of frustrated re-prompting wouldn't.

Free course

Stop reading about AI — start building with it

The free Claude Code course: your first site, tool or game — no coding. No upsells, no cross-sells — nothing to buy here.

Start free →

References

Selected peer-reviewed papers and preprints on the AI research behind this topic.

  1. [1]Xiaoran Liu et al. (2025). Thus Spake Long-Context Large Language Model. arXiv:2502.17129
  2. [2]Zhixuan Lin et al. (2025). Forgetting Transformer: Softmax Attention with a Forget Gate. arXiv:2503.02130
  3. [3]Yifei Gao et al. (2023). Pay Attention to What You Need. arXiv:2307.13365
  4. [4]Alfred Shen et al. (2026). Gated Sparse Attention: Combining Computational Efficiency with Training Stability for Long-Context Language Models. arXiv:2601.15305
  5. [5]Dong Liu et al. (2026). MKA: Memory-Keyed Attention for Efficient Long-Context Reasoning. arXiv:2603.20586
  6. [6]Ziwei He et al. (2023). Fovea Transformer: Efficient Long-Context Modeling with Structured Fine-to-Coarse Attention. arXiv:2311.07102
  7. [7]Junjie Wu et al. (2025). Ref-Long: Benchmarking the Long-context Referencing Capability of Long-context Language Models. arXiv:2507.09506
  8. [8]Dong Liu et al. (2025). $\pi$-Attention: Periodic Sparse Transformers for Efficient Long-Context Modeling. arXiv:2511.10696
EAEvgenii Arsentev

Author

Evgenii Arsentev

PhD · AI transformation executive

Reading is the blue pill

Want to actually build this?

Guides explain. The free course transforms — personalized, gamified, and built to get you shipping fast.

Start the free course →