Claude Code /clear vs /compact: When to Reset and When to Summarize

David IyaDavid Iya September 14, 2026 7 min read
A clean minimalist desk with an open laptop, a fresh empty notebook, and papers being cleared away in warm morning light, a calm sense of a reset workspace
Original image, Claude Code Club

What is the difference between /clear and /compact in Claude Code?

Both commands free up room in the context window, but they do opposite things with your conversation. /clear throws the whole conversation away and gives you a blank slate - the agent no longer remembers a single thing you said in that session. /compact keeps the conversation alive by replacing it with a short summary of what happened, so the agent still knows what you were working on but takes up far less room doing it.

Put simply: /clear is a reset, /compact is a save-and-shrink. You reach for /clear when you are done with one thing and moving to something unrelated. You reach for /compact when you are in the middle of a task, the window is filling up, and you want to keep the thread without losing your place.

What /clear actually does

/clear empties the conversation history for the current session. After you run it, the agent behaves as if you just opened the project - it has no memory of the questions you asked, the files it read, or the decisions you made a moment ago. What it does NOT wipe is your project setup: your CLAUDE.md file, your settings, and any files you point it at are all still there to be reloaded when the next task needs them.

This is why a reset costs less than most beginners assume. You are not deleting your project or your instructions. You are clearing the short-term chatter of one task so the next task starts clean, with a full window and no leftover context nudging the agent in the wrong direction.

What /compact actually does

/compact asks the agent to write a concise summary of the conversation so far, then replaces the full back-and-forth with that summary. The result is a much smaller footprint that still carries the important thread: what you are building, what has been tried, and where you left off. You keep working in the same session, on the same task, with room to spare.

The tradeoff is fidelity. A summary is not the full transcript, so fine detail can get flattened - an exact variable name, a subtle edge case you discussed once, a specific line the agent quoted earlier. For most work the summary keeps enough to continue smoothly. For work where a precise detail matters, restate that detail in your next prompt right after compacting so it survives the shrink.

The rule I use to decide, every session

I do not overthink it. The decision comes down to one question: am I still on the same task, or have I moved to a new one?

  1. New, unrelated task = /clear. I finished the login page and now I am writing a cold email. Nothing from the login work helps the email, and leftover context only risks confusing the agent. Blank slate.
  2. Same task, window filling up = /compact. I am halfway through a feature, the agent has read a dozen files, and the window is getting tight. I want to keep going without losing the thread, so I summarize and continue.
  3. Same task, plenty of room left = do nothing. Compacting early throws away detail you did not need to lose. Only compact when you are actually running low.

I call this the CCC context reset habit: clear between tasks by default, compact only mid-task under pressure. It keeps every session starting sharp and stops the slow drift that happens when one long conversation tries to hold three unrelated jobs at once.

Why a bloated conversation hurts output

As a conversation grows, two things get worse. First, you run out of room - a full window forces the agent to drop older context on its own, often the exact context you wanted kept. Second, and more subtle, a long thread full of half-finished tangents makes the agent slower and less focused, because it is weighing every past message when it decides what to do next. Managing context deliberately is a core part of keeping long sessions on track - see [Claude Code context management: how to keep long sessions on track](/blog/claude-code-context-management).

Which command fits the moment

SituationUseWhy
Switching to an unrelated task/clearLeftover context only confuses the new task; start fresh
Mid-task, window filling up/compactKeep the thread, drop the bulk, keep going
Mid-task, plenty of roomNeitherCompacting early loses detail you still have room to keep
Agent keeps citing outdated info/clearStale conversation is the cause; a reset removes it

Make context resets a habit before your next build

Start every new task with a clean window and you will notice the agent stays sharper for longer. Clear between unrelated jobs, compact when a single task outgrows its window, and restate any critical detail right after you compact. It is a thirty-second habit that removes a whole category of confusing, off-target output.

Free Claude Code drops, straight to your inbox

Short, practical drops on skills, MCP, agents, prompts, and more. No spam, unsubscribe anytime.

Frequently asked questions

What is the difference between /clear and /compact in Claude Code?

/clear wipes the conversation to a blank slate - the agent forgets everything you discussed in that session. /compact summarizes the conversation and keeps going, so the agent remembers the gist while using far less of the context window. Use /clear between unrelated tasks and /compact mid-task when the window is filling up.

Does /clear delete my project or my CLAUDE.md file?

No. /clear only empties the current conversation history. Your project files, settings, and CLAUDE.md are untouched and reload when your next task needs them. That is why a reset is cheaper than it feels - you are clearing one task's chatter, not your setup.

When should I use /compact instead of /clear?

Use /compact when you are still on the same task and want to keep the thread but the context window is running low. It summarizes what has happened so far and lets you continue with room to spare. If you were switching to an unrelated task instead, /clear is the better choice.

Does /compact lose information?

Some. A summary is not the full transcript, so fine detail can get flattened - an exact variable name or a subtle edge case discussed once. For most work the summary keeps enough to continue. If a precise detail matters, restate it in your next prompt right after compacting so it survives.

Last reviewed by David Iya on September 14, 2026

David Iya

Written by

David Iya

Forbes 30 Under 30 · Y Combinator

Keep reading

Claude CodeBuilding

How to Build a Booking System With Claude Code (A Weekend Build)

To build a booking system with Claude Code, describe the core loop in plain language - a visitor sees open slots, picks one, and the slot locks so nobody double-books - then let Claude scaffold the calendar, the database, and the confirmation flow while you steer the decisions. This is a full walkthrough of a real weekend build: what to hand Claude first, the double-booking bug that will bite you, and how to ship it live from the desktop app without touching a terminal.

David Iya 11 min
Read article
Claude CodeWorkflows

How to Resume a Claude Code Session (Pick Up Right Where You Left Off)

You can resume a Claude Code session so the agent remembers the whole thread - what you were building, the files it read, the decisions you made - instead of starting cold. Continue your most recent session or pick an older one from the list, in the desktop app or the terminal. Here is exactly how, and how to avoid the mistake that loses your context.

Duncan Rogoff 7 min
Read article

Ready to build it yourself?

Join Claude Code Club, the #1 community for learning claude code, for $9/month.

← Back to the blog