Claude Code /compact vs /clear: When to Use Each

Use /clear when you switch to unrelated work, because it starts a new conversation with empty context.

Use /compact when you want to keep working on the same task, because it replaces the conversation with a summary to free up space.

Both commands reduce what Claude has to read on every message, which saves tokens and helps Claude focus. They just do it in different ways.

This article explains what each command does, when to use it, and what happens to your files, memory, and instructions.

/clear vs /compact at a glance

/clear/compact
What it doesStarts a new, empty conversationSummarizes the current conversation
Claude remembersNothing from the old conversationA summary of it
Best forSwitching to unrelated workContinuing a long task
Old conversationSaved, and you can resume itReplaced by the summary

When to use /clear

Run /clear when the next task has nothing to do with the last one:

/clear

Old conversation takes up space and costs tokens on every message, and it can distract Claude from the files you need next.

Your old conversation isn’t deleted. You can bring it back with /resume. To make it easier to find, give it a name as you clear:

/clear release-prep

/clear also has two aliases: /reset and /new.

When to use /compact

Run /compact when you’re deep into a task and want to keep going:

/compact

You can tell Claude what to keep in the summary:

/compact focus on the auth bug fix

This works better than letting Claude guess what’s important, so it’s a good idea to run it before starting a long new step.

Claude Code compacts automatically

You don’t have to wait for problems. When your conversation gets close to the context limit, Claude Code compacts it automatically, so a full context window doesn’t end your session.

To compact earlier, set how full the context can get before it runs:

/autocompact 500k

To see how much of your context is being used, run /context.

What survives compaction?

After compaction, Claude Code reloads some things from disk, so they’re not lost in the summary:

ContentAfter compaction
Project-root CLAUDE.mdReloaded from disk
Auto memoryReloaded from disk
Your plan from plan modeReloaded from disk
Files Claude read or editedUp to five of the most recent are re-read
Skills Claude usedReloaded, but large skills are cut short
Everything else in the conversationSummarized

Since CLAUDE.md is reloaded, put instructions you always want Claude to follow there. See where Claude Code memory is stored for how to set it up.

Compact only part of the conversation

You can also summarize just part of the conversation. Run /rewind, choose a message, then pick one of these:

  • Summarize from here: summarizes everything after that message
  • Summarize up to here: summarizes everything before that message and keeps later messages as they are

How to get back a cleared conversation

Run /resume and choose the old conversation from the list. If you named it with /clear <name>, search for that name.

In the same Claude Code session, you can also open the rewind menu with /rewind and pick the previous conversation from there.

Conclusion

Use /clear between unrelated tasks and /compact to keep going on a long one. Either way, your instructions in CLAUDE.md stay in place.

Keeping your context small also makes Claude faster and uses less of your plan. See why Claude Code is so slow for more tips.