Claude Code Context Management: How to Stop Long Sessions From Getting Slow, Dumb, and Expensive (2026)
Long Claude Code sessions get slow, dumb, and pricey as context fills. How to fight context rot with /clear, /compact, /context, and CLAUDE.md.
I use Claude Code every day, and the single biggest quality difference I've felt from one session to the next has nothing to do with the model — it's how full the context window was. A fresh session is sharp. Six hours into a sprawling conversation, the same model starts forgetting decisions, re-reading files it already read, and quietly costing more per reply. There's a name floating around for this: context rot.
I'm not the only one who noticed. A r/ClaudeAI thread asking "how do you actually manage really long Claude conversations without losing your mind" turned into a small consensus-building exercise, and the top answers all converged on the same uncomfortable conclusion: stop having really long conversations. One reply put it bluntly — "By not doing really long conversations. Markdown and handoff to a new session." Another: "Never talk to an AI with a full context window EVER."
That advice is correct, but the thread mostly treats it as a manual chore — copy-paste summaries, hand-rolled handoff files. What a lot of those users don't realize is that Claude Code already ships the tools to do this properly. This guide is the community's hard-won wisdom, mapped onto the built-in commands that actually implement it.
What Context Rot Actually Is
Every message you send re-reads the entire accumulated context. That's the mechanic behind both problems people report:
- It gets dumber. As the window fills with old conversation, stale file contents, and finished tool output, the signal-to-noise ratio drops. The model has more to sift through and more chances to anchor on something irrelevant. Claude Code's own docs are direct about this: a full window "can reduce performance and sometimes distract Claude."
- It gets expensive. A one-word
continuelate in a huge session isn't cheap — the model still re-reads everything to answer it. This is the same dynamic behind so many "why did my usage vanish" complaints, which I broke down in Claude Code Usage Limits Explained: limits count tokens, not prompts, and a bloated conversation drags its whole context along on every turn.
So context management isn't housekeeping. It's the lever that controls both output quality and how fast you burn your plan.
Note
Bigger windows don't make this go away. Fable 5, Sonnet 5, and Opus 4.6+ support a 1M-token context window, but a Reddit user running Claude Code with 1M available said it best: "I limit my chats as close to 200k as possible before I open a new one." More room to fill is not the same as staying sharp.
Step Zero: See What's Eating the Window
You can't manage what you can't see. Before you clear or compact anything, run:
/context
This shows what's currently consuming your context window — conversation history, file reads, system prompt, and tool definitions. It's the diagnostic that tells you why a session feels sluggish. If MCP servers are the culprit, /mcp breaks down per-server cost (MCP tool definitions are deferred by default, so only tool names cost tokens until Claude actually uses one).
Get in the habit of glancing at /context the moment replies start feeling off. Usually the answer is obvious: one giant file read or a long-finished task still sitting in the window.
/clear — The Command Most People Underuse
The Reddit consensus of "open a new chat constantly" has a direct in-tool equivalent, and it's the highest-leverage habit I changed:
/clear
/clear wipes the context window and starts fresh without losing your work — the previous conversation is saved and reopenable with /resume. Claude Code's own best-practices doc says to run it between unrelated tasks, and that "between unrelated tasks" is the whole trick. When you finish the auth bug and move to a CSS tweak, the auth conversation is now pure noise for the new task. Clear it.
Tip
Rule of thumb from heavy users: one prompt to plan, one to say "proceed," a couple of follow-up fixes — then /clear before the next unrelated thing. If a single task can't fit in a window without maxing out, that's a signal the scope was too big and needs breaking down, not a bigger window.
/compact — When You Need Continuity, Not a Reset
Sometimes you don't want to start over — you're mid-feature and the accumulated decisions matter. That's what compaction is for. Claude Code compacts automatically as you approach the limit: it clears older tool outputs first, then summarizes the conversation, preserving your requests and key code while dropping the chaff.
You don't have to wait for the automatic pass. Run it manually with a focus:
/compact focus on the auth refactor and the files we changed
The focused version is meaningfully better than letting auto-compact guess. When you say what to keep, the summary keeps it; when the automatic pass runs, it keeps what it thinks is important — and the thread's complaint that "/compact's track record is terrible" usually traces back to letting it run blind on a window that was already 95% full. Compact before starting a big new task, not after you've hit the wall.
For surgical control, Esc + Esc (or /rewind) lets you pick a checkpoint and choose Summarize from here (condense everything after that point) or Summarize up to here (condense the earlier stuff, keep recent turns in full).
Warning
If you see Error during compaction: Conversation too long, the window was already too full to even hold the summary. Press Esc twice to step back a few turns and free space, then run /compact again — or /clear and reopen with /resume if that's not enough. The fix for a jammed compaction is almost always less context, not retrying the same overloaded one.
CLAUDE.md — The "External Brain" the Thread Reinvented
The most-upvoted concrete tactic in that Reddit thread was to "tell Claude to write on a local file where it is at and what it is supposed to be doing" — treat chat history as disposable and keep the real state in files. One user described moving entirely to "structured folders and files… so it's easy for both me and Claude to find the context even though the chat has been cleared or compacted."
That instinct is exactly right, and Claude Code formalizes it as CLAUDE.md. Unlike conversation history, CLAUDE.md content is re-injected on every request and survives compaction — the project-root file reloads from disk even after the window is summarized. Instructions you only say in chat can be lost when compaction runs; instructions in CLAUDE.md persist. That's the difference between a durable brain and a leaky one.
Two CLAUDE.md tricks that pay off directly for long sessions:
-
Tell the compactor what to protect. Add a section that survives every summarization:
# Compact Instructions When summarizing this conversation, always preserve: - The current task objective and acceptance criteria - File paths that have been read or modified - Test commands and their latest results - Decisions made and the reasoning behind themThe header text isn't a magic string — Claude Code matches on intent — but having it means compaction stops eating the context you most need.
-
Keep an action log. The thread's "action log that it updates constantly" is just a project file (say
PROGRESS.md) that Claude appends to as it works. After a/clear, a fresh session reads it and picks up where the last one left off — the handoff those users were doing by hand, made repeatable.
Delegate Big Reads to a Subagent
There's one more built-in that the manual "handoff file" crowd hasn't discovered: subagents. When you need Claude to read something large — a 300-page doc, a sprawling module, a pile of logs — sending it to a subagent keeps that content in its context window, not yours. You get back just the answer, and your main session stays lean.
This is the cleanest fix for the "I need to feed it a huge file but that instantly fills my window" problem. Research goes out to a disposable context; the conclusion comes back. Your working session never pays the token cost of the raw material.
A Workflow That Actually Holds Up
Putting it together, here's the loop I run now, which is really just the Reddit consensus with the right buttons pressed:
- Start narrow. One task per session. State it, let Claude plan, say proceed.
- Watch
/contextwhen replies degrade — don't wait for a wall. /clearbetween unrelated tasks. Aggressively. It's free and it's reversible via/resume./compact focus on …when you need continuity mid-task, before the window is jammed.- Keep durable state in CLAUDE.md + an action log, so a clear or compact never loses the plot.
- Send big reads to a subagent so raw material never enters your main window.
None of this is exotic. It's the same discipline the thread arrived at through pain — "never talk to an AI with a full context window" — with the difference that Claude Code hands you the tools instead of making you cosplay them in copy-paste.
FAQ
What is context rot in Claude Code?
Context rot is the drop in quality and rise in cost that happens as a long session fills the context window with old conversation, stale file contents, and finished tool output. Because every message re-reads the entire window, a bloated session makes the model slower to reason, more likely to get distracted, and more expensive per reply — even for trivial requests.
What's the difference between /clear and /compact?
/clear wipes the context window entirely and starts fresh (the old conversation is saved and reopenable with /resume) — use it between unrelated tasks. /compact keeps the session going but replaces the history with a summary, optionally focused with instructions like /compact focus on the API changes — use it when you're mid-task and the accumulated decisions still matter.
Does a bigger context window fix the problem?
Not really. Fable 5, Sonnet 5, and Opus 4.6+ offer a 1M-token window, but a larger window just delays the rot — it doesn't prevent it. Heavy users cap themselves well below the limit (many aim for ~200k or under 50% full) precisely because a fuller window degrades output regardless of how much room is left. Scope discipline beats window size.
What survives compaction?
Your requests, key code snippets, and the project-root CLAUDE.md (plus auto memory) survive — CLAUDE.md reloads from disk after every summarization. What can be lost are detailed instructions you gave only in conversation. That's why persistent rules belong in CLAUDE.md, and why a "Compact Instructions" section telling the compactor what to preserve is worth adding to any long-running project.
Why does a long Claude Code session cost more?
Because usage is metered in tokens, not prompts, and every message re-reads the whole accumulated context. A one-word follow-up deep in a huge conversation drags the entire window along with it. Keeping sessions short with /clear is one of the most effective ways to slow down how fast you hit your usage limits.
Bottom Line
The Reddit thread that kicked this off landed on the right answer through frustration: don't let conversations get long, and keep your real state in files. Claude Code already implements that answer — /context to see the problem, /clear to reset between tasks, /compact with a focus to keep continuity, CLAUDE.md as the brain that survives it all, and subagents to keep big reads out of your window. Learn those five and context rot stops being the thing that quietly wrecks your afternoon.