/compact vs /clear in Claude Code: when to use which
Use /clear when you start a new task and /compact when one task has a long history. A decision table, what auto-compact keeps and what a summary loses.
Contents
Use /clear when you start something new: it begins a fresh conversation with empty context and costs nothing. Use /compact when you're still on the same task but the history has grown long: it swaps the history for a summary so you can keep going. Run /context first to see what's actually filling the window.
/compact vs /clear at a glance#
| Situation | Use | Why |
|---|---|---|
| Starting an unrelated task | /clear |
Old context costs tokens on every message and distracts Claude |
| Same task, long history, near auto-compact | /compact <focus> |
Keeps the thread; you choose what the summary keeps |
| Went down a wrong path | /rewind |
Returns to an earlier point, and its prefix is still cached |
| Corrected Claude twice on the same thing | /clear, then a better prompt |
Anthropic's advice: the context is full of failed attempts |
| A quick side question | /btw |
The answer never enters the conversation |
| You'll want this conversation later | /clear <name>, later /resume |
The old conversation is kept and named |
The rule underneath all of it, from Anthropic's best practices: "Claude's context window fills up fast, and performance degrades as it fills." Both commands exist to keep the window small and on topic.
What /clear does#
/clear "starts a new conversation with empty context" (commands reference). It's also available as /reset and /new. Your CLAUDE.md, auto memory and tools load fresh, as at the start of any session.
Nothing is deleted. Pass a name, /clear auth-refactor, to label the old conversation in the /resume picker, or restore it from the rewind menu while Claude Code is still open.
It's also the cheapest command there is. Anthropic's cost guide: "When you want a fresh start instead of continuity, /clear costs nothing."
What /compact does, and what it costs#
/compact replaces your history with a summary. You can tell it what to keep: /compact focus on the failing tests and the API shape. Without a focus, the summary keeps what the model guesses matters.
To write that summary, Claude Code sends one request containing your whole history. While the prompt cache is warm, most of that is read cheaply. After a break longer than the cache lifetime there's no cache left to read, so it's all processed again as uncached input, which is why Anthropic says /compact "costs the most when you resume an old session." Compact at a natural break while you're still working, not first thing after lunch.
What a summary keeps, and what it loses#
Anthropic's context window page lists what happens to each kind of content after a compact:
| Content | After compaction |
|---|---|
| Project-root CLAUDE.md, unscoped rules, auto memory | Loaded again from disk |
| The plan from plan mode | Loaded again from disk |
| Files Claude read or edited | Up to five re-read, most recently changed first. A file over 5,000 tokens comes back as a reference only |
| Skills you used | Re-injected, capped at 5,000 tokens each and 25,000 in total |
CLAUDE.md in subfolders, rules with paths: |
Summarised away, loaded again when Claude touches a matching file |
| Everything else: exact errors, command output, the back-and-forth | Only what made it into the summary |
The last row is the one that bites. A summary says "the build failed on a type error in the client", not the 40 lines of compiler output. If the exact text matters, keep it in the focus, or save it to a file before you compact.
The subfolder row matters in a monorepo like ours. Our server package has its own 196-line CLAUDE.md that loads only when Claude works on a file in that folder. After a compact, its rules are gone from the window until Claude opens a server file again. Anything that must hold through a compact belongs in the root file.
You can also steer every compact from CLAUDE.md, with a section Anthropic's cost guide suggests:
# Compact instructions
When you are using compact, please focus on test output and code changes
Auto-compact: when it runs and how to steer it#
Claude Code compacts on its own as the window fills, so a full context doesn't end your session. Per the model configuration docs, as of 22 October 2026:
- Models with a native 1M window (Opus 4.7 and later, Sonnet 5 and later, Haiku 5.5, the Fable models) compact at about 967K tokens by default.
- Opus 4.6 and Sonnet 4.6 without extended context compact at 200K.
- With
CLAUDE_CODE_DISABLE_1M_CONTEXT=1, the 1M models compact at 200K too.
To compact earlier, run /autocompact 500k (from Claude Code v2.1.221). It takes 100K to 1M; since v2.1.288 it saves the value for the current model only. --autocompact sets it for one session, and CLAUDE_CODE_AUTO_COMPACT_WINDOW overrides both in scripts.
To compact only part of the conversation, open /rewind, pick a message and choose Summarize from here or Summarize up to here.
One error to know: Autocompact is thrashing means a file or tool output filled the window again right after each compact. Ask Claude to read the file in parts, or /clear if you don't need the old conversation. It is one of several forms of Prompt is too long, and our guide to that error goes through each one and its fix.
Check /context first#
/context draws the window as a coloured grid, by category, with suggestions. Two readings tell you which command you need:
- Messages is the biggest row. The conversation is the problem:
/compactif you're mid-task,/clearif you're not. - The answers have got worse, not just longer. That's the context filling up (see why Claude Code gets worse in long sessions).
- Everything else together is bigger. What loads at startup (CLAUDE.md, MCP tools, skills) leaves too little room. Neither command fixes that; trimming does. What to cut is listed in why Claude Code uses so many tokens.
How Shuriken does it#
In Shuriken every chat is its own Claude Code session, and every chat except the project's Main chat works on its own branch in its own worktree. So "new task" usually means a new chat, which is a /clear that keeps the old chat in the list, untouched, to come back to. That's how parallel agents work, and our guide to running Claude Code agents in parallel explains the setup.
Inside a chat, the context ring opens a map much like /context: what fills the window, how far it is to auto-compact, and hints such as "Close to auto-compact". It has a Compact button with an optional "Keep…" field for the focus, so you can compact on your terms without typing the command.
To see what's filling each chat's context as you work, download Shuriken.
Try the free tool: Claude limit reset tracker
Sources
- Commands: /clear, /compact, /context, /rewind, /autocompact (Claude Code docs) (accessed 22 October 2026)
- Explore the context window: what survives compaction (Claude Code docs) (accessed 22 October 2026)
- Model configuration: default auto-compact thresholds (Claude Code docs) (accessed 22 October 2026)
- Best practices for Claude Code: manage context (Claude Code docs) (accessed 22 October 2026)
- How Claude Code uses prompt caching: compacting (Claude Code docs) (accessed 22 October 2026)
- Manage costs effectively: /clear costs nothing, compact instructions (Claude Code docs) (accessed 22 October 2026)
Frequently asked questions
Does /clear delete my conversation?
No. /clear starts a new conversation with empty context, and the old one stays on disk. Bring it back with /resume, and name it first with /clear <name> or /rename so it's easy to find.
What does /compact actually send?
One request that carries your whole history and asks for a summary. The summary then replaces the history, so later requests carry it instead. While the prompt cache is warm most of that history is read from cache; after a long break it is all processed again.
When does Claude Code auto-compact?
On models with a native 1M window, at about 967K tokens by default. Opus 4.6 and Sonnet 4.6 without extended context compact at 200K. You can compact earlier with /autocompact, for example /autocompact 500k.
Does CLAUDE.md survive /compact?
Yes. The project-root CLAUDE.md, unscoped rules and auto memory are loaded again from disk. CLAUDE.md files in subfolders and path-scoped rules come back only when Claude touches a matching file again.