Guides

Claude Code /compact vs /clear vs a new session

Run /compact when you’ll keep working on the same task and want Claude to keep its decisions but drop the noise. Do it at a natural break, with a focus, before auto-compaction picks a worse moment. Run /clear when you switch to unrelated work, or after you’ve corrected Claude twice on the same thing. Start a new, named session for a separate line of work you’ll come back to. And if you just want to abandon the last few turns, /rewind is cheaper than either.

The short answer

SituationUse
Same task, long conversation/compact focus on … at a natural break
Switching to unrelated work/clear
Corrected Claude twice on the same issue/clear, then a better prompt with what you learned
A separate workstream you’ll return toA new session, named with /rename, resumed with claude --resume
The last few turns went the wrong way/rewind to an earlier turn
A quick side question/btw, which never enters the history
Leaving for more than an hour mid-task/compact before you go

How full is the context?

Everything goes into the context window: your messages, every file Claude reads and every command’s output. As it fills, Claude starts losing track of earlier instructions and makes more mistakes, which is why the official best practices call context the most important resource to manage. To see where you stand:

What /compact does, and what survives it

/compact replaces the conversation history with a summary and carries on from there. Your files on disk don’t change, only what Claude remembers of the conversation. After compaction:

You decide what the summary keeps by giving it a focus: /compact focus on the auth bug fix. For a permanent rule, add a line to CLAUDE.md such as “When compacting, always keep the list of modified files and the test commands”. To compact only part of a conversation, run /rewind, pick a message and choose Summarize from here or Summarize up to here.

When to compact: at a break, not mid-task

Auto-compaction runs when the window fills, which is often in the middle of something. In a Reddit thread on what threshold people compact at, most answers say the same thing: compact by hand at the end of a task, because an automatic compaction mid-task comes at the worst possible time. The documentation gives the same advice.

Timing also changes the cost. Compaction sends one extra request that repeats the conversation. While the prompt cache is warm, that request mostly reads from the cache and costs a fraction of the context size. After a break longer than the cache lifetime, nothing is cached and the summary reprocesses the whole history. On a Claude subscription the cache lasts an hour; with an API key or extra usage, five minutes (prompt caching). So:

/clear: a clean slate

/clear resets the conversation completely. CLAUDE.md and your settings still load, so you lose only the conversation. Use it:

A new session instead

A separate session is better than /clear when you’ll come back to the old work. Name it with /rename, pick it up later with claude --continue or claude --resume, and treat sessions like branches: one per line of work. A fresh session is also better for reviewing code, because it isn’t biased toward what it just wrote. Several sessions at once each need their own git worktree so they don’t edit the same files.

/rewind and /btw: the cheaper options

If the last few turns went down a path you want to drop, /rewind (or Esc twice) back to an earlier turn. Rewinding truncates the conversation to a point that is already cached, so it costs less than building a new summary. For a question you don’t want in the history at all, /btw answers it on the side.

Auto-compact settings

Seeing context across sessions

We make Meowdoro, a focus timer in the MacBook notch that shows Claude Code and Codex sessions while you work, so this is a disclosure. Each Claude Code session in it has a small ring for how full its context is. Past a threshold, 50% by default, the ring turns orange, and when your break starts, the break card names the session: a good moment to compact while you rest. It reads only the token counters, never the conversation (how it works). For the break itself, see pomodoro with AI coding agents.

Questions

Does /compact lose my code?

No. Files on disk don’t change. Claude keeps a summary of the conversation and re-reads up to five of the files it was working on.

What do I do when Claude Code says the context limit is reached?

The window is full, and with auto-compact off Claude Code can’t go on until you shrink it. Run /compact to keep working on the same task with a summary, or /clear if you’re moving on.

Is /compact or a new session better for a long task?

For one task, compact at its natural steps and keep going. When the task is done, or turns into something different, start fresh. A written spec or plan in a file carries over to a new session better than any summary.

Does CLAUDE.md survive /compact and /clear?

Yes. The project-root CLAUDE.md is re-read from disk after compaction and loads at the start of every conversation, including after /clear.

Sources: the Claude Code documentation on best practices, the context window, prompt caching, sessions, settings and environment variables, read on October 26, 2026. Claude Code changes often; if something here no longer matches, write to meow@meowdoro.com.