# /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.

Source: https://shuriken.sh/guides/claude-code-compact-vs-clear

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.

By Shuriken Updated 27 October 2026 5 min read

**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](https://code.claude.com/docs/en/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](https://code.claude.com/docs/en/commands)). 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](https://code.claude.com/docs/en/costs): "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](https://shuriken.sh/guides/prompt-caching-in-claude-code) 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](https://code.claude.com/docs/en/context-window) 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:

markdown
# Compact instructions

When you are using compact, please focus on test output and code changes

Shuriken moves a running chat to another of your own accounts when one reaches its limit, on every device.

[Download](https://shuriken.sh/download)

## 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](https://code.claude.com/docs/en/model-config), 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](https://shuriken.sh/guides/claude-code-prompt-is-too-long) 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: /compact if you're mid-task, /clear if 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](https://shuriken.sh/guides/claude-code-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](https://shuriken.sh/guides/why-claude-code-burns-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](https://shuriken.sh/features/parallel-agents) work, and our guide to [running Claude Code agents in parallel](https://shuriken.sh/guides/run-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](https://shuriken.sh/download).

Try the free tool: [Claude limit reset tracker](https://shuriken.sh/tools/limit-resets/claude)

Share

[X](https://x.com/intent/post?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Fclaude-code-compact-vs-clear&text=%2Fcompact%20vs%20%2Fclear%20in%20Claude%20Code%3A%20when%20to%20use%20which)[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Fclaude-code-compact-vs-clear)[Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fshuriken.sh%2Fguides%2Fclaude-code-compact-vs-clear&t=%2Fcompact%20vs%20%2Fclear%20in%20Claude%20Code%3A%20when%20to%20use%20which)[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Fclaude-code-compact-vs-clear&title=%2Fcompact%20vs%20%2Fclear%20in%20Claude%20Code%3A%20when%20to%20use%20which)[E-mail](mailto:?subject=%2Fcompact%20vs%20%2Fclear%20in%20Claude%20Code%3A%20when%20to%20use%20which&body=https%3A%2F%2Fshuriken.sh%2Fguides%2Fclaude-code-compact-vs-clear)

## Sources

- [Commands: /clear, /compact, /context, /rewind, /autocompact (Claude Code docs)](https://code.claude.com/docs/en/commands) (accessed 22 October 2026)
- [Explore the context window: what survives compaction (Claude Code docs)](https://code.claude.com/docs/en/context-window) (accessed 22 October 2026)
- [Model configuration: default auto-compact thresholds (Claude Code docs)](https://code.claude.com/docs/en/model-config) (accessed 22 October 2026)
- [Best practices for Claude Code: manage context (Claude Code docs)](https://code.claude.com/docs/en/best-practices) (accessed 22 October 2026)
- [How Claude Code uses prompt caching: compacting (Claude Code docs)](https://code.claude.com/docs/en/prompt-caching) (accessed 22 October 2026)
- [Manage costs effectively: /clear costs nothing, compact instructions (Claude Code docs)](https://code.claude.com/docs/en/costs) (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.

Source switching

One account runs dry. The next one takes over.

Add the Claude, Codex and Gemini accounts you own. At your switch point, your chats move to another of them and keep going.

[Download](https://shuriken.sh/download)

[Other platforms](https://shuriken.sh/download#main)

## Keep reading

- [How to switch Claude accounts without logging out: Guide 27 Oct 2026 7 min read Three ways to use several Claude accounts in Claude Code without /logout and /login: one config per account, a switcher CLI, or a harness.](https://shuriken.sh/guides/switch-claude-accounts-without-logging-out)
- [Claude's 5-hour limit, explained: Guide 27 Oct 2026 6 min read Claude's 5-hour window starts with your first message and resets five hours later. An idle account has no window running, so it saves nothing up.](https://shuriken.sh/guides/claude-5-hour-limit-explained)
- [Claude usage limit reached? What to do next: Guide 27 Oct 2026 6 min read There's no early reset for Claude's 5-hour or weekly limit. Wait, pay for usage credits, switch to an API key, or carry on with another account you own.](https://shuriken.sh/guides/claude-limit-reached-what-to-do)
- [Claude's weekly limit, explained: Guide 27 Oct 2026 6 min read Paid Claude plans have a weekly limit on top of the 5-hour window. When it resets, how model limits fit in, and why parallel agents reach it in two days.](https://shuriken.sh/guides/claude-weekly-limit-explained)
- [Claude Code 429 error: what it means and how to fix it: Guide 27 Oct 2026 5 min read A Claude Code 429 rate limit error means you hit an allowance, not an outage: your plan's window, your API tier or a spend cap. Which one, and what to do.](https://shuriken.sh/guides/claude-code-429-rate-limit-error)
- [How to check your Claude Code usage: Guide 27 Oct 2026 6 min read To check Claude Code usage, type /usage or open Settings › Usage on claude.ai. Both read one pool: your 5-hour session and your weekly limit.](https://shuriken.sh/guides/check-claude-code-usage)
- [Codex usage limits explained (2026): Guide 27 Oct 2026 5 min read How Codex limits work on ChatGPT Plus and Pro: the 5-hour and weekly windows, the 2026 changes, checking yours with /status, and using several accounts.](https://shuriken.sh/guides/codex-usage-limits)
- [Anthropic API rate limit tiers: how to move up: Guide 27 Oct 2026 5 min read Anthropic API rate limit tiers set a monthly spend cap and per-minute limits. The tiers in October 2026, how to move up, and what Claude Code hits first.](https://shuriken.sh/guides/anthropic-api-rate-limit-tiers)

## Free tools

- [Claude limit reset tracker](https://shuriken.sh/tools/limit-resets/claude)
- [Codex limit reset tracker](https://shuriken.sh/tools/limit-resets/codex)
