Claude Code /clear vs /compact: managing the context window
/clear starts a new conversation with empty context; the old one stays on disk and /resume brings it back. /compact keeps the same conversation but replaces its history with a summary, optionally with focus instructions. Claude Code also compacts on its own near the limit. Use /clear between unrelated tasks and /compact to keep going on the same one.
Claude Code’s context window holds everything Claude knows in a session: CLAUDE.md, memory, skill descriptions, every file it read, every tool result and every reply. /clear and /compact are the two commands for making room in it. /clear throws the context away and starts a new conversation; /compact keeps the conversation and shrinks it to a summary.
The facts below come from Anthropic’s commands, context window, model configuration and costs docs (November 2026).
/clear and /compact side by side
/clear |
/compact |
|
|---|---|---|
| What it does | Starts a new conversation with empty context | Summarizes the conversation so far to free context |
| The old history | Stays on disk; /resume brings it back |
Replaced by a structured summary in the same conversation |
| Arguments | /clear [name] labels the old conversation in /resume |
/compact [instructions] tells the summary what to keep |
| Aliases | /reset, /new |
none |
| Session | A new session with a new session ID | The same session |
| Token cost | None | One large request: it reads everything it summarizes |
| Use it when | You switch to unrelated work | You continue the same task and the history is getting long |
/clear: a new conversation
/clear starts a new conversation with empty context, so the next prompt carries only what loads at startup (CLAUDE.md, memory, skill descriptions) and nothing from the previous task. Anthropic’s costs docs give the reason to use it often: stale context costs tokens on every following message, because Claude Code sends the full conversation with every request.
The previous conversation is not deleted. Pass it a name, as in /clear login-bug, and it shows under that name in the /resume picker. In the same Claude Code process, the rewind menu can also restore it. The /usage Session totals restart from zero after /clear.
/compact: the same conversation, summarized
/compact replaces the conversation history with a summary and keeps going in the same session. Focus instructions decide what the summary keeps:
/compact focus on the auth bug fix and the failing testsYou can also put standing instructions in the project’s CLAUDE.md, which Anthropic’s costs docs show as a section of its own:
# Compact instructions
When you are using compact, please focus on test output and code changesTo compact only part of the conversation, run /rewind, pick a message and choose Summarize from here or Summarize up to here.
What survives compaction
Compaction summarizes the conversation, but a lot is loaded again from disk. A selection from the context window docs:
| After compaction | What happens |
|---|---|
| System prompt and output style | Still apply |
| Project-root CLAUDE.md and unscoped rules | Re-injected from disk |
| Auto memory | Re-injected from disk |
| A plan written in plan mode | Re-injected from disk |
| 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 only |
| Invoked skill bodies | Re-injected, capped at 5,000 tokens per skill and 25,000 in total |
Rules with paths: and nested CLAUDE.md files |
Summarized away; reloaded when Claude touches a matching file again |
| Background commands and subagents | Keep running |
The practical lesson: an instruction that must outlive compaction belongs in the project-root CLAUDE.md or an unscoped rule, not in a chat message.
Auto-compact: when Claude Code compacts on its own
Claude Code compacts automatically as the conversation approaches the limit, so a full context window does not end the session. Where it happens depends on the model:
| Model | Default auto-compact point |
|---|---|
| Native 1M-token models (Fable, Sonnet 5 and later, Haiku 5.5, Opus 4.7 and later) | About 967K tokens |
| Opus 4.6 and Sonnet 4.6 without extended context | 200K tokens |
Any model with CLAUDE_CODE_DISABLE_1M_CONTEXT=1 |
200K tokens |
To compact earlier, set an auto-compact window between 100K and 1M tokens:
/autocompact 500k # this model, saved in your user settings/autocompact auto # back to the tuned defaultFor every model, set "autoCompactWindow": 200000 in ~/.claude/settings.json; for one launch, claude --autocompact 300k. A context or auto-compact warning is not a usage limit, only a sign that the conversation is close to that point.
How to see how full the context is
/contextshows current context usage as a colored grid, broken down by category, with suggestions for heavy tools, memory bloat and capacity warnings.- A custom status line can show context usage on every screen;
/statuslinesets one up from a description. /usageshows the session’s token totals and, on a subscription, plan usage.
Which one to use
- Finished a task, starting something unrelated:
/clear. Rename first (/rename) or pass a name to/clearif you may come back. - Same task, long history, Claude still needs the thread:
/compactwith a focus line. - Before a long new phase of the same task:
/compactyourself, so the summary keeps what you choose instead of what the automatic pass guesses. - A side task that reads a lot (logs, docs, a test run): a subagent, so the reading stays in its context and only a summary comes back.
Context across many sessions with hivemux
hivemux is a tmux sidebar that shows every Claude Code session — running, waiting for you, or done — and lets you jump to the one that needs you. A resting Claude’s line shows how much context that Claude carries (for example 142K), so you can see which session is due for a /clear or /compact without opening each one.
In a hivemux team, the same number drives a diet. After each answer hivemux notes how many tokens of context a role carries; a role past its line (120K by default, 160K for dev in the built-in template) brings its notes up to date once it rests, runs /clear and carries on from the notes under the same name, so the other roles keep messaging it. An answer you have not read holds the diet (until the role is half again past its line), and one that asked you something is shown again after the fresh start. The team page shows each role’s context against its line and has a Diet now button (hivemux team diet <role>).
In the bee office, a bee is a project plus the Claude’s name in it, so a Claude stays the same bee across /clear and a new conversation.
FAQ
What is the difference between /clear and /compact in Claude Code?
/clear starts a new conversation with empty context, as a new session with its own ID; the previous conversation stays on disk. /compact keeps the current conversation but summarizes its history to free context, so Claude still knows what you were doing, in less detail.
Does /clear delete my conversation?
No. /clear starts a new conversation and leaves the old one on disk. Run /resume to go back to it, or pass a name (/clear login-bug) so it is easy to find in the /resume picker.
When does Claude Code auto-compact?
When the conversation nears the model's context limit. Per Anthropic's model docs, models with a native 1M-token window compact at about 967K tokens by default, and Opus 4.6 or Sonnet 4.6 without extended context at 200K. /autocompact 500k sets an earlier point for the current model.
How do I see how much context Claude Code is using?
Run /context for a live breakdown by category, shown as a colored grid with suggestions. A custom status line can show context usage all the time; /statusline sets one up.
Does /compact use tokens?
Yes. /compact reads the whole conversation it summarizes, so compacting a large context is itself a large request. /clear costs nothing, which makes it the cheaper choice when you do not need the history.