All insights

Coding agents

How to Clear Context in Claude Code: /clear vs. /compact

Use /clear in Claude Code to start fresh, /compact to summarize and continue, or Ctrl+L to redraw the terminal. Learn what happens to your session and how this differs from API context.

Illustration for Claude code clear context

To clear the conversation you’re working in, type /clear at the Claude Code prompt and submit it. It starts a fresh conversation; it is not a shell command. Anthropic’s Claude Code documentation describes /clear as the choice when switching to unrelated work. (code.claude.com)

Choose the right option

What you want Use What it does
Start fresh for a different task /clear Clears the active conversation and starts a new one. Your CLAUDE.md and project files remain available. (support.claude.com)
Continue the same task with less conversation history /compact Summarizes the conversation to free context space. The summary may not preserve every detail, so check that important decisions and next steps are represented. (code.claude.com)
Refresh the terminal display Ctrl+L Redraws the screen; it does not clear conversation history. Shortcuts can vary by terminal and platform. (code.claude.com)

Quick rule: If your next request would make sense in a brand-new conversation, use /clear. If you still need the current task’s progress, use /compact instead. (support.claude.com)

What happens to the old conversation?

/clear resets the active conversation, but it does not delete your project files or CLAUDE.md. Claude Code saves sessions locally as you work, and its session documentation says you can return to a session after running /clear.

To reopen a saved session from your terminal, use claude --resume to open the session picker, or claude --continue to reopen the most recent session in the current directory. From inside a session, /resume switches to another one. These are ways to return to a saved session—not a way to continue the newly cleared conversation with its old active context. (code.claude.com)

Before clearing, copy any unique decisions, open questions, or task-specific notes you’ll need in the new conversation. For example, preserve the selected approach and the next test to run; don’t assume a compacted summary or a fresh session will carry every conversational detail forward.

Does /clear reset production API context?

No: /clear is a Claude Code session command, not an API request or API-wide reset. For direct Claude API Messages requests, Anthropic says the developer constructs each turn and manages conversation state. So, in an API integration, your application controls what conversation history it sends; clearing a Claude Code session does not itself clear that separately managed history. (code.claude.com)

Sources

Commands — Claude Code Docs

Explore the context window — Claude Code Docs

Manage sessions — Claude Code Docs

Interactive mode — Claude Code Docs

Models, usage, and limits in Claude Code — Claude Help Center

Claude Platform Documentation

Contact us