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.
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 the default on Fable 5.1, Fable 5, Sonnet 5 and later, Haiku 5.5, and Opus 4.7 and later; only Opus 4.6 and Sonnet 4.6 need the
[1m]variant, and sessions auto-compact at about 967K tokens - Context rot is real, but Anthropic publishes no token threshold for it; it depends on the task
- /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 holds your instructions; auto memory holds what Claude learns. Bloat in either 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 in April 2026, and it is now the default on current models. Anthropic's model configuration docs say Fable 5.1, Fable 5, Sonnet 5 and later, Haiku 5.5, and Opus 4.7 and later run with the 1M window by default, with no [1m] suffix needed. Only Opus 4.6 and Sonnet 4.6 reach 1M through their [1m] variant (/model opus[1m]), and that depends on the plan: Opus 4.6 with 1M is included on Max, Team, and Enterprise and needs usage credits on Pro, while Sonnet 4.6 with 1M needs usage credits on every subscription plan. On the Anthropic API there is no price premium for tokens beyond 200K, except on Haiku 5.5. CLAUDE_CODE_DISABLE_1M_CONTEXT=1 holds every model to a 200K window.
Sessions on the native-1M models auto-compact at about 967K tokens by default, not at the full million. To compact earlier, run /autocompact with a value from 100K to 1M tokens, such as /autocompact 500k; Claude Code saves it for the current model, and /autocompact auto returns to the tuned default. Sessions with the full window compact less often and keep more of the conversation intact.
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; the same page warns that more context isn't automatically better. 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. The name for it, context rot, started as an engineer's coinage and is now in Anthropic's own context windows documentation, which says that as token count grows, "accuracy and recall degrade, a phenomenon known as context rot." It has stuck because it captures the gradual, attention-dilution mechanism rather than a sudden cliff.
Anthropic publishes no token threshold for context rot: the context windows page, the Claude Code best-practices guide, and the Claude Code context window guide all describe the degradation without naming a point where it starts, checked October 9, 2026. Treat it as task-dependent. A focused session reading two files stays sharp for a long time. 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 checkpointing docs describe five options at each checkpoint: restore code and conversation, restore conversation, restore code, "Summarize from here", and "Summarize up to here". Checkpoints persist across sessions; file snapshots are deleted about 30 days after the session last saved one./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. Five options: restore both code and conversation, restore conversation only, restore code only, "Summarize from here," which compresses everything after the chosen message, and "Summarize up to here," which compresses everything before it and keeps the recent messages in full. The two code-restore options appear only when the checkpoint has tracked file changes to revert.
The two summarize modes are the secret weapon for pivots, and you can type instructions while one is highlighted to steer what the summary keeps. "Summarize from here" is the one for a direction change. 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.
What Survives Compaction
Compaction does not treat everything in context the same way. Anthropic's context window guide lists what happens to each kind of content:
| Content | After compaction |
|---|---|
| System prompt and output style | Both still apply |
| Project-root CLAUDE.md and unscoped rules | Re-injected from disk |
| Auto memory | Re-injected from disk |
| The plan Claude wrote in plan mode | Re-injected from disk |
Rules with paths: frontmatter and nested CLAUDE.md files | Reloaded on demand when Claude touches a matching file |
| Files Claude read or edited | Up to five re-read, most recently modified first; a file over 5,000 tokens comes back as a path reference |
| Invoked skill bodies | Re-injected, capped at 5,000 tokens per skill and 25,000 tokens total, oldest dropped first |
| Everything else in the conversation | Summarized |
Two practical consequences. An instruction that must survive a long session belongs in the project-root CLAUDE.md or an unscoped rule, not in a path-scoped rule or a chat message. And because truncation keeps the start of a skill file, put a skill's most important instructions near the top of SKILL.md.
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. The exception is a fork: started with /subtask, it inherits the whole conversation so far, though its own tool calls still stay out of yours and only its result comes back (Anthropic, subagents).
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:
/contextdraws the current context usage as a colored grid with optimization suggestions, so you can see what is eating the window before deciding between compact and clear./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 holds your instructions; auto memory holds what Claude learns. Both load into every session, so anything in them pays a cost on every turn. The memory model layers a few files:
- A managed policy file (
/Library/Application Support/ClaudeCode/CLAUDE.mdon macOS) for organization-wide rules ~/.claude/CLAUDE.mdfor personal global preferences./CLAUDE.mdor./.claude/CLAUDE.mdchecked into the repo for team conventions./CLAUDE.local.mdgitignored for personal-per-repo notes.claude/rules/for topic files, optionally scoped to file paths so they load only when Claude works there- Plus parent directories walked at launch, and child directories loaded on demand when Claude reads files in them
None of these override each other. Anthropic's memory docs say all discovered files are concatenated into context, ordered from the filesystem root down to your working directory, with CLAUDE.local.md appended after CLAUDE.md at each level, so the instructions closest to where you launched are the last thing Claude reads. If two files contradict each other, Claude may pick either. The same docs give a size target: under 200 lines per file.
Three more rules from the same page:
- AGENTS.md: Claude Code (v2.1.277 or later) reads a repository's
AGENTS.mdas project instructions, but by default only when there is noCLAUDE.md,.claude/CLAUDE.md, orCLAUDE.local.mdin your working directory or above it. Adding aCLAUDE.local.mdto an AGENTS.md repo stops Claude readingAGENTS.mdunless you switch the setting to load both. - Auto memory: the notes Claude writes itself from your corrections are a separate mechanism, per repository and shared across worktrees. Only the first 200 lines or 25KB load into each session.
/doctor: the checkup proposes trims for a checked-in CLAUDE.md, cutting what Claude can derive from the code and keeping pitfalls and conventions (v2.1.206 or later)./doctor prompt-audit(v2.1.283 or later) reports outdated or contradictory instructions across CLAUDE.md, AGENTS.md, rules, skills, and subagents, and changes nothing until you approve.
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.
This guide covers in-session tools. For the standing context you load every session (CLAUDE.md, skills, tool definitions, and auto memory), see context engineering for Claude 5 models.
Corrections and Updates
October 9, 2026: This page said 1M context needed plan-specific upgrades on Opus and cited a 300-400k-token context rot estimate from a single x.com post. The 1M window is now the default on every current model except Opus 4.6 and Sonnet 4.6, and Anthropic publishes no context rot threshold, so the estimate is gone.
September 14, 2026: This page said personal and local CLAUDE.md files "generally take precedence over repo files". Anthropic's memory docs say the files are concatenated in filesystem order rather than overriding each other; the section above now says so. The 1M-context eligibility, the rewind menu, and the CLAUDE.md file list were also brought up to the September 2026 docs.
Sources
- Anthropic, "Model configuration", extended context and auto-compaction sections: https://code.claude.com/docs/en/model-config (1M defaults by model, the
[1m]variants and plans,CLAUDE_CODE_DISABLE_1M_CONTEXT, the 967K default auto-compact point,/autocompact; checked October 9, 2026) - Anthropic, "Explore the context window": https://code.claude.com/docs/en/context-window (what survives compaction; checked October 9, 2026)
- Anthropic, "Create custom subagents": https://code.claude.com/docs/en/sub-agents (isolated context, forks and
/subtask; checked October 9, 2026) - Anthropic, "Context windows": https://platform.claude.com/docs/en/build-with-claude/context-windows (the "context rot" definition; checked October 9, 2026)
- Anthropic, "Best practices for Claude Code": https://code.claude.com/docs/en/best-practices (context management,
/compactsteering,/btw, subagents for investigation, the two-corrections rule, CLAUDE.md pruning; checked September 14, 2026) - Anthropic, "Checkpointing": https://code.claude.com/docs/en/checkpointing (the five rewind-menu options, the 30-day snapshot retention; checked September 14, 2026)
- Anthropic, "How Claude remembers your project": https://code.claude.com/docs/en/memory (CLAUDE.md scopes, load order,
.claude/rules/, the 200-line target, AGENTS.md, auto memory limits,/doctortrims andprompt-audit; checked October 9, 2026) - Anthropic, "CLI reference" and "Commands": https://code.claude.com/docs/en/cli-reference and https://code.claude.com/docs/en/commands (
--continue,--resume,/rename,/context,/init,/permissions,/sandbox,/hooks,/plugin; checked September 14, 2026) - Anthropic, "Claude Opus 4.6 and Sonnet 4.6: 1M context now generally available": https://claude.com/blog/1m-context-ga (the April 2026 GA announcement)
Frequently Asked Questions
What is context rot in Claude Code?
Context rot is Anthropic's term for the way accuracy and recall degrade as the context window fills: Claude forgets earlier instructions, repeats itself, and makes more mistakes. Anthropic publishes no token threshold for it. It depends on the task, and 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?
Not by default. A subagent starts with a fresh, isolated context window and returns only its final report, so raw tool output stays out of the parent session. The exception is a fork, started with /subtask, which inherits the full conversation; its own tool calls still stay out of your context.