Master Claude Code's 1M Context Window: Rewind, Compact, Clear, and Subagents
Claude Code's 1M token context window opens longer autonomous sessions but introduces 'context rot' -- degraded performance as the window fills. Master four turn-end tools: /rewind to drop bad branches, /compact to summarize and continue, /clear to start fresh with a distilled brief, and subagents to wall off noisy work in their own context.
Master Claude Code's 1M Context Window: Rewind, Compact, Clear, and Subagents
The 1M token context window in Claude Code lets you run longer autonomous sessions than ever, but the headline number hides the real skill. As the window fills, Claude starts forgetting, repeating itself, and getting confused -- a failure mode Anthropic calls context rot. The fix is not bigger context. The fix is knowing which of five tools to reach for at every turn end: continue, /rewind, /clear, compact, or a subagent. Pick correctly and a single session can carry a feature from idea to merged PR -- a shift that defines the 2026 AI tools landscape.
Key Takeaways
- 1M context is GA on Opus 4.6 and Sonnet 4.6 (Max, Team, Enterprise plans)
- Context rot kicks in around 300-400k tokens but is task-dependent
- /rewind beats "try again" -- drops failed branches from context
- /compact is lossy; /clear is deliberate. Steer compactions with explicit instructions.
- Subagents return only conclusions, not raw tool output
- /btw is the underused command for asides that never enter conversation history
- CLAUDE.md is your memory system; bloat hurts more than it helps
The 1M Context Window and Why "More" Is Not "Better"
Anthropic moved the 1M context window to general availability on Opus 4.6 and Sonnet 4.6. Inside Claude Code, Max, Team, and Enterprise users get it automatically: sessions tap the full 1M token budget, with fewer compactions and more of the conversation kept intact. Pro users do not get the full 1M context inside Claude Code; the 1M tier is gated to Max, Team, and Enterprise.
The API context windows page makes the budget look generous: easily a whole codebase plus a long conversation. The catch is that quality and quantity are not the same thing. As Thariq from Anthropic framed it in his essay on session management, more context is more potential, not more guarantee. A long session with junk in it performs worse than a short session with the right context. The 1M window is leverage. What you load into it is the work.
Context Rot: What It Is and When It Kicks In
Anthropic's best-practices guide describes the failure mode directly: as context fills, Claude may start forgetting earlier instructions or making more mistakes. Thariq's name for it -- context rot -- has stuck because it captures the gradual, attention-dilution mechanism rather than a sudden cliff.
Thariq's empirical observation from real coding sessions is that rot starts to bite "around 300-400k tokens" but is "highly dependent on the task -- not a fast rule." Anthropic does not publish a threshold, so treat 300-400k as a working heuristic, not a contract. A focused session reading two files stays sharp past that mark. A debugging session that has read 40 files and chased three dead ends wobbles much earlier.
In practice the symptoms cluster: Claude re-asks for a path you already provided, reintroduces a bug you already fixed, ignores an explicit constraint, or starts repeating itself. Any of those is a signal that the next message is cheaper to write into a clean session.
The Five Paths at Every Turn End
Every time Claude finishes a turn, you have five real options. Most users only use two. The full set:
- Continue. Send another message in the same session. Use this when context is fresh, the work is on track, and the next step builds directly on the previous turn.
/rewind. PressEsc+Escor run/rewind, jump back to a previous message, and drop everything after that point. The file checkpointing docs describe four restoration options: conversation only, code only, both, or "Summarize from here." Checkpoints persist across sessions./clear. Start a fresh session. Usually you do this with a hand-written brief that distills what the new session needs to know.- Compact. Run
/compactto summarize the session so far and keep going on top of the summary. Compaction accepts steering:/compact Focus on the API changestells Claude what to preserve. Auto-compaction also fires near the context limit. - Subagent. Delegate the next chunk of work to a child agent with its own clean context. Only the final report comes back.
Knowing the menu is the prerequisite. The rest of this article is when to pick which.
Rewind: The Most Important Habit You Are Not Using
The most underused tool in the list is /rewind, and it is the single biggest leverage point against context rot. The default user behavior, when Claude does the wrong thing, is to type "no, do it this way" and re-send. That is the worst option. The bad output is now in context forever, and the failed reasoning keeps consuming attention budget.
Esc+Esc -- or /rewind -- opens the checkpoint picker, lets you jump back to a previous message, and drops everything after. The bad branch is gone. Edit your original prompt to be clearer and try again. Four restoration modes: conversation only, code only, both, or "Summarize from here," which keeps a compressed version of the rewound tail.
The "Summarize from here" mode is the secret weapon for pivots. If you have spent 20 turns investigating a bug and want to switch to implementing the fix, rewind to where the new direction starts and summarize the investigation tail. The session keeps the conclusions and drops the dead-end queries.
If you have corrected Claude twice on the same issue, do not correct a third time. Either rewind to before the first wrong turn and reframe, or /clear and restart with a sharper prompt.
Compact vs Clear: Which to Use When
/compact and /clear solve overlapping problems with different trade-offs.
Compact is lossy. You hand the running summary to Claude and trust it to decide what mattered. The cost is that a compaction can drop a detail you needed. The benefit is that Claude often catches things you would forget to write down -- the convention you noticed in passing, the function name from a file you skimmed. With 1M context, you can also compact proactively: before you hit the auto-compact threshold, fire /compact yourself with a description of what comes next, so the model is summarizing while it still has full attention.
Clear is deliberate. You write the brief the next session starts with. More work, but the resulting context is exactly what you decided was relevant.
The rough rule: use /compact when the next chunk continues directly from what just happened. Use /clear when you are pivoting, when the session has accumulated failed approaches, or when you want explicit control over what carries forward. Anthropic recommends /clear after two failed corrections on the same issue.
A practical default for unrelated tasks: /clear between them. If you finish a bug fix and pivot to writing release notes, the bug-fix context adds nothing and adds plenty of noise. Clear, paste a one-paragraph brief, go.
What Causes a Bad Compact -- and How to Avoid It
A bad compact is when the summary loses something the next turn needed. The pattern: you spend a long debugging session on foo.ts, auto-compact fires near the limit, the summary captures the foo.ts investigation, and your next message is "now fix that other warning we saw in bar.ts" -- but the bar.ts warning was dropped from the summary because the model judged it irrelevant.
The structural problem is that the model is at its least intelligent point when it compacts, because the context is full. Compaction is a summarization task done by a tired Claude on a noisy transcript. It will sometimes get it wrong.
Three mitigations that work:
Compact proactively, not reactively. With 1M tokens you have headroom. Before pushing close to the limit, run /compact yourself with steering: /compact Preserve the failing test names and the current branch diff. The model summarizes with attention to spare and explicit guidance about what matters.
Steer every compaction. Plain /compact tells Claude to guess. /compact Keep the OAuth flow we just designed and the three TODO items from the requirements doc tells Claude what to keep. The resulting summary is dramatically better.
Use "Summarize from here" instead of compact when the goal is a pivot. Esc+Esc, pick the message where the new direction starts, choose "Summarize from here." Relevant tail kept, irrelevant head dropped, you control the cut point.
If a compact does go bad, the recovery is /rewind to before the compact and try again with steering, or /clear and start fresh with a brief that includes the things you just lost.
Subagents as Context Isolation
A subagent is the heaviest tool in the kit and the one with the biggest payoff for context budget. A subagent runs in its own isolated context window, does its work using whatever tools it has been granted, and returns only its final report to the parent session. Raw tool output and intermediate reasoning stay walled off.
You define a subagent in .claude/agents/<name>.md with frontmatter declaring name, description, tools, and model. The body is the system prompt. Invoke it with "use a subagent to..." or Claude Code will sometimes call one automatically when the description matches the task.
The mental test for whether to delegate: "Will I need this tool output again, or just the conclusion?" If conclusion-only, send a subagent. If you need to look at all those files yourself in later turns, do the work in the parent session.
Concrete examples:
- Code search. Send a subagent to find every place a deprecated API is called. The parent gets a list of files and line numbers, not the grep output it took to find them.
- Test triage. A subagent runs the suite, reads the failures, classifies them by root cause, returns a one-paragraph report.
- Library investigation. A subagent reads three pages of docs and returns the three lines of code you need. The doc reading does not enter the parent context.
Think of a subagent as a context-budget purchase. You spend the parent session's words on the conclusion, not the search.
The /btw Command and Other Underused Tools
Two underused commands deserve their own mention.
/btw is the answer to "I have a quick question that has nothing to do with what I am doing right now." Typing it as a regular message would put it in conversation history forever. /btw answers the aside in a dismissible overlay that never enters the session. Use it for "what does this regex mean," "how do I express this in jq," or any one-off that does not deserve permanent context space.
/init generates a starter CLAUDE.md from your codebase. Run it once on a new repo and edit the result rather than writing the file from scratch.
A few more from the CLI reference worth knowing:
/renamegives the current session a name likeoauth-migrationsoclaude --resumecan find it later.claude --continueresumes the latest session;claude --resumeopens a picker./permissions,/sandbox,/hooks,/pluginconfigure tool access, sandboxing, and plugins.- For unattended runs, the same thinking applies inside Routines: every run starts with a clean context, so the prompt itself has to do the work
/clearwould otherwise do.
If you are orchestrating work across multiple Claude Code windows, the redesigned desktop app makes the multi-context view easier to keep in your head.
CLAUDE.md Hygiene Rules
CLAUDE.md is the always-on memory system. It is loaded into every session, so anything you put there pays a cost on every turn. The memory model layers a few files:
~/.claude/CLAUDE.mdfor personal global preferences./CLAUDE.mdchecked into the repo for team conventions./CLAUDE.local.mdgitignored for personal-per-repo notes- Plus child and parent dirs in monorepos, walked automatically
All four are loaded into every session if present. Personal and local files generally take precedence over repo files; consult the official docs if your override isn't taking effect.
Import another file via @path/to/file syntax. For knowledge that is only sometimes relevant, the right home is a Skill -- .claude/skills/<name>/SKILL.md -- not CLAUDE.md. Anthropic's guidance is explicit on this split: knowledge that is only relevant sometimes belongs in a Skill, not in CLAUDE.md.
The MCP servers you wire in also affect the context budget. Picking the right MCP servers -- and disabling the ones you do not need on a given task -- keeps the implicit context smaller.
Seven habits worth burning in:
- Default to
/clearbetween unrelated tasks. A clean session with a better prompt almost always outperforms a long session with accumulated corrections. - Two corrections, then reset. If you have corrected Claude twice on the same issue, the context is poisoned with failed approaches.
- Steer your compactions.
/compact Preserve the failing test names and the current branch diffbeats letting auto-compact guess. - Use "Summarize from here" before pivoting.
Esc+Esc, pick the message where the new direction starts, summarize the tail. - Investigate via subagents, implement in main. Apply the test "Will I need this tool output again, or just the conclusion?" -- if conclusion-only, delegate.
- Use
/btwfor asides. Quick "what does this regex mean?" questions do not deserve permanent context space. - Prune
CLAUDE.mdruthlessly. Anthropic's guidance on the file boils down to one test: if removing a line would not cause Claude to make a mistake, cut it.
Frequently Asked Questions
What is context rot in Claude Code?
Context rot is Anthropic's term for the way Claude's performance degrades as the context window fills. The model starts forgetting earlier instructions, repeats itself, and makes more mistakes. In practice it tends to bite around 300-400k tokens, but the threshold is task-dependent -- a noisy debugging session rots faster than a focused code review.
When should I use /clear instead of /compact?
Use `/clear` when switching to an unrelated task, when a session has accumulated failed approaches, or when you want full control over what carries forward. Use `/compact` when the next chunk continues directly from what you just did and you trust Claude to summarize. Anthropic recommends `/clear` after two failed corrections on the same issue.
Do subagents share context with the parent agent?
No. A subagent runs in its own isolated context window and only returns its final report to the parent session. Raw tool output, intermediate reasoning, and search detritus stay walled off. That is the point: you delegate exploration to a subagent so the parent context never has to absorb the noise of finding the answer.
Get the weekly AI Catchup
Tools, practices, and what matters -- in your inbox every Monday.