Claude Code · Updated 2026-10-19
Claude Code /compact vs /clear vs context compression
Use /clear when you switch to an unrelated task, /compact when you are mid-task and the window is filling, and context compression for bulky tool output that should never have entered the window raw. They act on different things: history, summary, and individual results.
What does /clear do?
It wipes the conversation and starts fresh. Your CLAUDE.md and project files remain available; only chat history goes. Anthropic's help center calls it the most effective lever for both quality and cost when you change tasks. Source: Claude Help Center.
What does /compact do?
It summarizes the conversation so far into a shorter recap so you can continue. You can steer it, for example /compact focus on the auth bug fix. Claude Code also compacts automatically near the limit. Source: Claude Code docs, context window. A summary is a rewrite, so exact values such as paths, error strings or IDs can be lost. If a session has already gone off track, many practitioners suggest saving state manually and clearing instead of compacting.
Where does context compression fit?
Neither command touches the size of a single tool result as it arrives. A large test log or file read lands in history in full, and then is either carried forward or summarized later. Compression acts earlier: the hosted SuperCompress model reads the output and your request and keeps only the original lines that answer it, so the bulky result is smaller from the start.
For Claude Code, supercompress setup writes UserPromptSubmit and PostToolUse hooks plus an MCP server. After large tool calls the hook compresses the new output against your request and passes the kept lines to Claude as extra context. You keep your normal Claude Code login.
Which one should I use?
| Situation | Use |
|---|---|
| Starting an unrelated task | /clear |
| Same task, window filling | /compact with focus instructions |
| Repeated huge test, build or file output | Question-aware compression of tool output |
| Static instructions are huge | Shorten CLAUDE.md, move detail into files read on demand |
They stack. Compression reduces what goes in, /compact handles what accumulates, /clear resets between tasks.
How do I set it up?
Install the CLI and run setup, then restart Claude Code.
npm install -g supercompress-proxy && supercompress setupMore in reducing Claude Code token usage and the coding agents guide.
Frequently asked questions
Should I use /compact or /clear in Claude Code?
Use /clear when switching tasks and /compact when continuing the same task as the window fills.
Does /compact lose information?
It summarizes, so details can be dropped. Give it focus instructions and keep exact values you need in a file.
Does SuperCompress replace /compact?
No. It compresses individual bulky outputs against your question. /compact still helps with accumulated history.
Will SuperCompress change my Claude Code login?
No. It adds an MCP server, instructions and hooks, and supercompress uninstall removes only what it added.