Magento 2 Experten — Hyvä Theme, Tailwind CSS & SEO aus einer Hand ›

Understanding the Context Window: Compaction and Keeping Long Sessions in Check

Understanding the Context Window: Compaction and Keeping Long Sessions in Check

~7 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026

After five blocks full of work on the recipe planner, this is a good moment to pause and understand what's actually happening behind the scenes as a conversation keeps growing - and why Claude Code eventually steps in on its own.

What the context window is

The context window is the amount of information Claude has "in view" at any given moment: the entire conversation so far, every file content read so far, every intermediate result from tool calls. It has a fixed upper limit - comparable to a desk that can only hold so many documents spread out at once before things get cramped.

In a long session - like the one that might have built up across several chapters of work on the recipe planner, with many files read, several features, bug fixes, and test runs - this window gradually fills up. Eventually it gets full.

What happens when the context window fills up

So a session doesn't simply break once the context window is full, there's compaction: the conversation so far is condensed into a compact summary that keeps the most important facts and decisions, but takes up far less room than the full, detailed history. The session then continues to build on that summary.

This happens either automatically once the context window hits its limit, or deliberately via the /compact slash command from chapter 16, which you can trigger yourself before it gets that far.

Why you should keep this in mind

A summary is naturally less detailed than the full history. Very fine details from a very early discussion - say, a small side remark about a design decision in the recipe planner right at the start of block 3 - can get lost after a compaction, even though the essential facts are preserved.

Tipp: For especially important decisions, the same principle from CLAUDE.md in chapter 10 applies: anything meant to hold permanently doesn't just belong in the conversation history, it belongs written down somewhere that survives a compaction - first and foremost, the project's own CLAUDE.md.

New session vs. resuming

In addition to compaction, you have two deliberate choices available: /clear from chapter 16 starts completely fresh, with no history at all - useful when a new, unrelated topic comes up. /resume, on the other hand, picks up a previous session, including its (possibly already compacted) history - useful when you want to continue the same task after having ended the session in between.

Practical rules of thumb

  • For a new, unrelated topic (e.g. a completely different project): a new session with /clear instead of mixing everything together.
  • For a very long, nested research task within the same job: consider a subagent from chapter 19 instead of filling up the main session.
  • Important, lasting decisions: write them into CLAUDE.md, don't just mention them in conversation.

With this understanding in place, the next chapter covers a related question: how Claude can remember things beyond a single session.