How do I clear the Claude Code context?

/clear

Starts an empty context. The old conversation stays recoverable.

Answer

Type /clear to start with an empty context. The previous conversation is saved, not deleted — resume it with /resume. Use /compact instead when you are mid-task and running out of room: it replaces the history with a structured summary, keeping what you decided and what broke while freeing the tokens the detail was using.

What it does

The context is everything Claude can see at once: your instructions, the conversation so far, the files it read, the output of commands it ran. It has a fixed size, and every exchange fills more of it. Running out is handled for you — Claude Code compacts the conversation into a summary and carries on — so clearing is a choice you make when the old context is no longer worth carrying, not a repair you are forced into.

/clear gives you an empty one.

/clear

The previous conversation is not thrown away. Claude Code saves it, and you can come back with /resume, or — while the same Claude Code process is still running — from the previous-session entry in the rewind menu, which /rewind opens. A name you set with --name or /rename carries into the new conversation; an AI-generated title does not.

/compact is the other option, and it is not the same thing:

/compact

It replaces the conversation history with a structured summary — your requests and intent, key technical concepts, files changed with code fragments, errors and their fixes — and keeps you in the same thread.

What survives compaction:

  • the system prompt, unchanged
  • project CLAUDE.md and global rules,

reloaded from disk

  • auto memory — the notes Claude writes for itself as it works — reloaded
  • skills you actually invoked, reloaded within their token limits

What does not: path-scoped rules, nested CLAUDE.md files, and the descriptions of skills you never invoked. Path-scoped rules — instructions that only load for matching files — come back when Claude next reads one.

The pattern is worth noticing: anything Claude Code can re-read from a known file — your CLAUDE.md, the skills already in play — comes back. Anything that depended on where you happened to be in the work does not.

When to use it

/clear when the next task has nothing to do with the last one. Starting clean is cheaper than carrying context that will only be noise, and easier to reason about than a summary of work you have finished.

/compact when you are mid-task and running out of room. You lose detail but keep the thread: what you decided, what broke, what the files look like now.

Example

Finish one task and start another:

/clear

Free tokens without leaving the task:

/compact

Go back to what you cleared:

/resume

That last one has a deadline: the saved conversation is a file on disk, kept for 30 days by default. Clear something you might want in three months and it will not be there. Widen the window in settings.json:

{
  "cleanupPeriodDays": 90
}

Common mistakes

Thinking /clear deletes the conversation. It clears the context, not the record. /resume finds it again.

Using /clear mid-task to save tokens. That throws away the working context you still need. /compact is the one that keeps it, in condensed form.

Expecting a compacted session to remember everything. The summary is lossy by design. Details you will need later belong in a file, not in the scrollback.

Expecting the AI-generated title to survive /clear. Only a name you set yourself carries over.