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
- How full is it?
- /compact
- When to compact
- /clear
- A new session
- /rewind and /btw
- Auto-compact settings
- Questions
The short answer
| Situation | Use |
|---|---|
| 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 to | A 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:
/contextshows a live breakdown by category, including which CLAUDE.md and memory files loaded, with suggestions.- A custom status line can show the percentage all the time.
- Auto-compaction runs on its own as you approach the limit. Where exactly depends on the model, and
/autocompactwith a token count, such as/autocompact 500k, sets the point yourself.
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:
- Still there: the system prompt, the project-root CLAUDE.md and auto memory (re-read from disk), the plan from plan mode, and background commands and subagents, which keep running.
- Re-read: up to five of the files Claude read or edited, the most recently modified first. A file over 5,000 tokens comes back as a reference without its content.
- Summarized away: everything else, including the details of failed attempts and rules that loaded only for certain paths.
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:
- Before a short break, nothing to do: the cache outlasts a 5- or 15-minute pause on a subscription.
- Before a long break mid-task, compact first. Coming back to a long uncompacted conversation after the cache expired is the expensive case.
- Claude Code may do it for you. With idle compaction, a long conversation left idle is compacted shortly before its one-hour cache expires. By default it applies from 200,000 tokens of context, and
"idleCompaction": falseturns it off.
/clear: a clean slate
/clear resets the conversation completely. CLAUDE.md and your settings still load, so you lose only the conversation. Use it:
- Between unrelated tasks. Old conversation crowds out the files you need next and costs tokens on every message.
- After two failed corrections. The official best practices put it plainly: if you’ve corrected Claude more than twice on the same issue, the context is cluttered with failed approaches, and a clean session with a better prompt almost always does better.
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
- Turn it off:
/config→ Auto-compact, or"autoCompactEnabled": falsein settings. Manual/compactkeeps working, and idle compaction turns off with it. - Compact earlier:
/autocompactwith a token count, or theCLAUDE_AUTOCOMPACT_PCT_OVERRIDEenvironment variable with a lower percentage. - A bigger window: some models support a 1 million token context; compaction works the same way there.
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.