9  Using Claude Code: Session Management and 1M Context

9.1 The Million-Token Window

On April 15, 2026, Anthropic published a guide to session management in Claude Code, oriented around a single fact: Claude Code operates with a one-million-token context window. A million tokens is a vast amount of information — roughly equivalent to a thick novel, a large codebase, or the transcript of a long working session. But having a large context window is not the same as using it well.

The guide’s central message was that context is a resource to be managed, not a bucket to be filled. As context grows, a phenomenon called context rot degrades performance. The skills of session management — knowing when to continue, when to rewind, when to clear, when to compact, and when to delegate to a subagent — are what separate effective Claude Code users from those who let their sessions drift into inefficiency.

This chapter covers the mechanics of the 1M context window, the problem of context rot, and the five tools for managing sessions effectively.

9.2 Context Rot: Why More Context Isn’t Always Better

Context rot is the degradation of model performance as the context window fills. It’s not that the model “forgets” earlier information — the information is still there. Rather, as the volume of context grows, the model’s ability to focus on the relevant parts and reason effectively diminishes. The signal-to-noise ratio drops.

Symptoms of context rot include:

  • The model begins to repeat itself or reference earlier, now-irrelevant parts of the conversation.
  • Responses become generic or shallow where they were previously specific and deep.
  • The model loses track of the current task, meandering toward tangential topics.
  • Tool calls become less targeted — the model reads files it doesn’t need, or re-reads files already in context.
Note

Context rot is analogous to the cognitive load a human experiences in a long meeting. The first hour is productive; by hour four, even intelligent participants start to lose focus, repeat points, and miss details. The solution isn’t a bigger brain — it’s breaks, summaries, and knowing when to start fresh.

The onset of context rot depends on the nature of the work. A focused session on a single, coherent task may remain effective with a large context. A session that has jumped between multiple unrelated tasks — fixing a bug, then writing docs, then refactoring something else — will rot faster because the context is a tangle of unrelated threads.

9.3 The Five Session Management Tools

When a task is complete (or when context rot sets in), Claude Code offers five options. Choosing the right one is the core skill of session management.

9.3.1 Option 1: Continue

Continue means exactly that: keep going in the current session, with all existing context intact. This is the right choice when:

  • The next task is closely related to the work just completed.
  • The existing context is directly useful for what comes next.
  • Context rot has not yet set in.

Continue is the default, and it’s the right choice more often than not when you’re in the flow of a coherent piece of work. The danger is continuing past the point of diminishing returns — when context has grown large and the current task is only loosely related to earlier work.

9.3.2 Option 2: /rewind — Jump Back

/rewind lets you jump back to an earlier point in the session, discarding everything after that point. It’s the session equivalent of git reset.

/rewind is the right choice when:

  • The session went down a wrong path and you want to try a different approach.
  • A recent change or investigation didn’t help and is now just noise.
  • You want to branch — go back and explore an alternative without the dead-end context.
Tip

/rewind is better than “try again” for corrections. If Claude took a wrong turn, typing “try again” or “no, do it differently” keeps the wrong-turn context alive, which can confuse subsequent attempts. /rewind cleanly removes the wrong turn, giving the next attempt a clean starting point.

9.3.3 Option 3: /clear — Fresh Session

/clear starts a completely fresh session with an empty context. It’s the session equivalent of closing the editor and reopening it.

/clear is the right choice when:

  • You’re starting a new, unrelated task.
  • Context rot has set in and the session is no longer productive.
  • You want a clean slate with no risk of earlier context bleeding in.

The rule of thumb from the guide: start a new session for a new task. If the new task is unrelated to the current session’s work, /clear is almost always the right move. The cost of losing context is low (you can re-load files as needed); the cost of context rot is high (degraded performance on the new task).

9.3.4 Option 4: /compact — Summarize and Continue

/compact asks Claude to summarize the current session and continue with the summary in place of the full history. It’s a middle ground between Continue and Clear — you keep the essential information but shed the bulk.

/compact is the right choice when:

  • The session has useful context that you want to preserve in compressed form.
  • You’re transitioning to a related task that benefits from the session’s history.
  • Context is large but not yet fully rotted — compaction can extend productive life.

The risk with /compact is bad compacts — summaries that lose critical information or misrepresent the work done. The guide noted that bad compacts happen when the model can’t predict the direction of future work. If the summary is optimized for the wrong upcoming task, it preserves the wrong information and discards what you’ll actually need.

9.3.5 Option 5: Subagents — Delegate

Subagents (covered in depth in Chapter 10) let you delegate work to an isolated Claude instance with its own context window. The subagent does its work and returns a result to the main session, without polluting the main context.

Subagents are the right choice when:

  • A task needs deep, focused work that would bloat the main context.
  • You need parallel work on independent subtasks.
  • You want a fresh perspective on a problem (a subagent starts with no preconceptions from the main session).

Subagents are the most context-efficient option because they cost the main session zero context — only the result comes back.

9.4 Decision Guide: Which Tool to Use

Situation Recommended Tool Why
Next task is closely related, session is productive Continue Existing context is an asset
Claude went down a wrong path /rewind Cleanly remove the wrong turn
Starting a new, unrelated task /clear Avoid context rot; start fresh
Session has useful context but is getting large /compact Preserve essentials, shed bulk
Task needs deep work or fresh perspective Subagent Isolated context; zero main-context cost
Session is unproductive and you’re not sure why /clear When in doubt, start fresh
Note

The guiding principle: context is a resource, not a virtue. A large, old context is not inherently valuable — it’s valuable only when it’s directly useful for the current task. When it’s not, shedding it (via clear, compact, or rewind) improves performance.

9.5 The /rewind vs. “Try Again” Distinction

The guide emphasized this distinction, so it deserves special attention. When Claude produces a result that isn’t what you wanted, you have two ways to respond:

  1. “Try again” / “No, do it differently”: Keep the wrong attempt in context and ask for a redo. The model sees both the original request and the failed attempt, which can bias it toward variations of the same (wrong) approach.

  2. /rewind then re-prompt: Remove the wrong attempt entirely, then give a new (possibly revised) prompt. The model starts fresh from the pre-wrong-turn point, free of the failed attempt’s influence.

The guide recommended /rewind for most correction scenarios because it gives the next attempt a cleaner start. “Try again” is appropriate only when the failed attempt contains useful diagnostic information — e.g., “that didn’t work because X, so avoid X” — that you want the model to learn from.

9.6 Practical Session Management Patterns

9.6.1 Pattern 1: Task-Oriented Sessions

Structure your work so that each session corresponds to a coherent task or set of closely related tasks. When the task is done, decide: continue (if the next task is related), clear (if it’s new), or compact (if there’s useful context to preserve).

9.6.2 Pattern 2: Subagent Delegation for Deep Work

For deep, context-heavy subtasks (research, exploring an unfamiliar part of the codebase, generating a large artifact), delegate to a subagent rather than doing the work in the main session. The main session stays lean; the subagent does the heavy lifting in isolation.

9.6.3 Pattern 3: Regular Compaction for Long Sessions

If you’re working in a single session for an extended period (e.g., a full day of development on one project), periodic compaction can extend the session’s productive life. Compact when you transition between sub-tasks within the larger work.

9.6.4 Pattern 4: Rewind Early, Rewind Often

Don’t be precious about context. If an approach isn’t working, rewind and try a different one rather than layering corrections on a flawed foundation. The cost of rewinding (losing some context) is almost always less than the cost of continuing with a confused session.

9.7 Understanding Context Rot in Depth

Context rot is the central challenge of session management, and understanding it deeply helps you manage sessions proactively rather than reactively.

9.7.1 Why Context Rot Happens

Context rot isn’t a bug — it’s a fundamental property of how language models process information. A model’s attention is finite: at any given moment, it can focus deeply on a subset of its context. As the context grows, the model must distribute its attention across more information, reducing the depth of focus on any one part.

This is analogous to human cognitive load. In a one-hour meeting about a single topic, you can follow every detail. In an eight-hour meeting covering twelve topics, by hour six you’re skimming, missing details, and confusing points from different topics. Your brain hasn’t gotten worse — the load has gotten higher.

9.7.2 The Three Phases of a Session

Sessions tend to go through three phases:

  1. Ramp-up (productive): Context is being built, but it’s all relevant to the current task. Performance is high.
  2. Steady state (productive): Context is at a stable level, all relevant. Performance is maintained.
  3. Rot (declining): Context has grown beyond what’s relevant, or the task has shifted. Performance degrades.

The goal of session management is to maximize time in phases 1–2 and minimize time in phase 3. The tools (continue, rewind, clear, compact, subagent) are how you transition between phases deliberately.

Note

Most context rot comes from task shifts within a session, not from raw context size. A session that works on one coherent task for 100K tokens may remain sharp, while a session that jumps between five unrelated tasks at 50K tokens is already degraded. The lesson: coherence matters more than size.

9.7.3 Symptoms to Watch For

Learn to recognize context rot symptoms early:

  • Repetition: The model repeats points it already made or references earlier, now-irrelevant context.
  • Generic responses: Where the model was specific, it becomes vague. “Consider the edge cases” replaces “handle the null user case on line 42.”
  • Lost thread: The model loses track of what it was doing, asking “what were we working on?” or starting tangential work.
  • Tool scatter: The model reads files it already read, or runs commands that don’t serve the current task.
  • Slowing responses: As the model processes more context, responses take longer — a practical sign that context is large.

When you notice these symptoms, it’s time to act — rewind, compact, clear, or delegate to a subagent.

9.8 The Compaction Problem

/compact is the most nuanced session management tool because it relies on the model producing a good summary — and summarization quality varies.

9.8.1 When Compaction Works Well

Compaction works well when:

  • The session has a clear narrative — a sequence of related work with a logical flow.
  • The next task is predictable — the summary can be optimized for what comes next.
  • The session is large but coherent — lots of relevant context that benefits from compression.

9.8.2 When Compaction Fails

Compaction fails when:

  • The session is tangled — multiple unrelated threads that can’t be cleanly summarized.
  • The next task is unpredictable — the summary may preserve the wrong information.
  • The model can’t predict the work direction — it doesn’t know what will be important, so it guesses, often wrongly.

A bad compact is worse than /clear because it gives you false confidence: you think the essential context is preserved, but it’s actually a distorted summary. When in doubt about whether compaction will work, /clear and re-load specific files as needed is safer.

Tip

If you’re unsure whether to compact or clear, ask yourself: “If I had to start fresh, what would I re-load?” If the answer is “most of the current context,” try compacting. If the answer is “just a few specific files,” clear and load those files. Clearing is cheap if you know what you need.

9.9 The Subagent Strategy

Subagents are the most underutilized session management tool. Many users think of subagents only for parallelism, but their context isolation benefit is equally valuable for session management.

9.9.1 Delegating Context-Heavy Work

Any task that requires reading many files or generating large artifacts is a candidate for subagent delegation. Instead of doing the work in the main session (where it fills the context), delegate it:

> Use a subagent to read all the files in the auth/ directory
  and produce a summary of how authentication works.
  Give me the summary, not the file contents.

The subagent reads all the files (its context fills up), produces a summary, and returns only the summary. Your main session gets the information it needs without the context cost of all those file reads.

9.9.2 The “Research and Report” Pattern

A common pattern: delegate research to a subagent, then work with the results in the main session:

  1. Subagent: “Explore the codebase and answer: how does the payment system handle refunds?”
  2. Main session: Works with the subagent’s report — designing changes, writing code, etc.

The main session never sees the exploration; it only sees the answer. This keeps the main session lean for the actual work.

9.10 Building Session Discipline

Effective session management is a discipline — a set of habits that keep your work productive. Key habits:

  1. One session, one task. Don’t mix unrelated work in a single session.
  2. Delegate heavy work. Use subagents for research, exploration, and large artifact generation.
  3. Rewind wrong turns immediately. Don’t build on a flawed foundation.
  4. Watch for rot symptoms. Act at the first sign of degradation, not after it’s severe.
  5. Prefer clear over compact when uncertain. Clearing is safe; bad compacts are misleading.
  6. Keep CLAUDE.md lean. Every word in CLAUDE.md is in context on every turn — make it count.

9.10.1 A Session Management Checklist

Before starting work in a session:

During work:

After completing a task:

9.11 Key Takeaways

  • Claude Code has a 1M-token context window — vast, but not infinite, and not free to fill.
  • Context rot degrades performance as context grows — the model loses focus, repeats itself, and produces shallow results.
  • Five session management tools: Continue (related work), /rewind (jump back from a wrong turn), /clear (fresh session), /compact (summarize and continue), Subagents (delegate to isolated context).
  • Rule of thumb: start a new session for a new task. Unrelated work should not share a session.
  • /rewind is better than “try again” for corrections — it removes the wrong turn cleanly rather than building on a flawed foundation.
  • Bad compacts happen when the model can’t predict future work direction — the summary may preserve the wrong information.
  • Subagents cost zero main-context — use them for deep work, parallel tasks, or fresh perspectives.
  • Manage context as a resource: shed it when it’s not useful, preserve it when it is.