Detailed Analysis
Claude Code's context window documentation reveals the sophisticated architecture underlying Anthropic's agentic coding tool, explaining in granular detail how the system manages information across a working session. The context window functions as the totality of what Claude "knows" at any given moment, and it is populated in layers: before a user types a single command, system-level content such as CLAUDE.md project files, auto memory, MCP tool names, and skill descriptions are already loaded. As the session progresses, file reads, path-scoped rules, and PostToolUse hooks continuously add to this running total. The documentation uses a timeline visualization with representative token counts to make this abstract process concrete, allowing developers to understand precisely when and how different information enters the model's active awareness.
A central concern of the documentation is what happens during compaction — the process by which Claude Code summarizes conversation history when the context window approaches its limit. The system distinguishes sharply between content that is preserved automatically and content that must be reloaded conditionally. System prompts and output styles survive intact because they exist outside message history. Project-root CLAUDE.md files and auto memory are re-injected from disk. However, path-scoped rules and nested subdirectory CLAUDE.md files are lost until a matching file is read again, a behavior that has meaningful implications for developers who rely on granular, directory-specific instructions across long sessions. Skill bodies are re-injected but subject to a 5,000-token per-skill cap and a 25,000-token aggregate ceiling, with oldest invocations dropped first — a design choice that rewards putting critical instructions at the top of SKILL.md files.
The documentation also addresses proactive context management as a core developer discipline rather than an edge case. Claude Code supports several strategies: running /compact with targeted instructions before a new task to preserve relevant context, using /clear when switching to unrelated work, and delegating large file reads to subagents so their contents consume a separate context window entirely. This last technique is particularly notable because it reflects a broader architectural pattern in agentic AI systems — decomposing tasks so that resource-intensive operations are isolated from the primary reasoning loop. The subagent model allows a main session to receive only a summary and metadata trailer rather than absorbing potentially enormous file contents directly.
The mention of a one-million-token context window for Opus 4.6, later versions, and Sonnet 4.6 situates this documentation within a rapidly evolving capability landscape. Extended context support has become a competitive frontier across major AI providers, and Anthropic's decision to make compaction function identically at both standard and extended limits signals an intentional design philosophy: context management is a permanent discipline, not a workaround for insufficient capacity. Even with vastly larger windows, the same principles of selective retention, efficient delegation, and structured summarization apply, suggesting Anthropic views context hygiene as fundamental to reliable agentic performance regardless of raw token limits.
This documentation reflects a broader trend in the AI industry toward treating agentic coding tools as systems requiring explicit resource management analogous to memory management in traditional software engineering. By exposing the mechanics of context loading, compaction survival rules, and token budgets, Anthropic is effectively asking developers to reason about their AI tool's cognitive constraints with the same rigor they would apply to compute or memory budgets. The /context and /memory commands — which provide live usage breakdowns and show which instruction files loaded at startup — reinforce this framing, positioning context awareness not as an implementation detail but as a first-class concern in professional use of Claude Code.
Read original article →