In Claude Code, /compact is the command that summarizes your current conversation to free up context so you can keep working in the same session. Think of context as Claude's short-term memory for this chat: everything you've said, every file it has read, every result it has produced all sit in that memory. It has a limit. The /compact command in Claude Code takes the long back-and-forth and replaces it with a tight summary, keeping the important decisions while clearing out the bulk, so you keep your momentum instead of starting over.
What /compact actually does
When you run /compact, Claude reads back through the conversation and writes a structured summary of it. That summary then stands in for the full history. You'll see a short "Conversation compacted" message, and the summarizing itself happens quietly in the background. The key point: you're still in the same session. You haven't lost your place. Claude keeps the thread of what you were doing, just in a much smaller footprint.
Running /compact summarizes the session and frees up room to continue.
What survives, and what gets summarized
This is the part that reassures most people. Compaction doesn't wipe your project's ground rules. Your project CLAUDE.md (the file that tells Claude how your project works), Claude's saved memory, and your connected tools all reload automatically after a compact. What gets condensed is the running conversation itself: the long chain of messages, file reads, and results. So the setup Claude relies on stays intact while the chatter shrinks.
Your project setup reloads automatically. Only the conversation itself is condensed.
Steering the summary with focus instructions
By default Claude decides what's worth keeping. But you can point it. The command optionally takes focus instructions right after it, and Claude leans the summary toward what you name. If you're deep in one thread and don't want the important decisions dropped, say so.
Focus instructions tell the summary what to hold onto. Click to copy.
/compact vs /clear
These two commands are easy to mix up, and picking the wrong one costs you. The difference is simple: /compact keeps you in the same conversation with a shorter memory of it, while /clear starts a brand-new conversation with empty context. Use compact when you want to continue what you're doing. Use clear when you're genuinely moving on to a new task.
A real example
Say you've been working with Claude for an hour building out a report. You've walked through the data, made a dozen formatting decisions, and fixed a few problems along the way. The session is getting long, and you notice things slowing down. You're not done, though: there's still more to build, and you don't want to re-explain everything.
So you run compact, and to be safe you steer it:
Claude writes a summary that holds onto those decisions, frees up the room the long back-and-forth was taking, and you carry on. No lost thread, no starting over. That's the whole point: a long working session stays fast, and the decisions that matter come with you.
/compact yourself just lets you do it on purpose, at a good stopping point, before performance starts to slip.When to reach for it
A useful habit: run /compact when the session starts feeling heavy or slow, or right before you kick off a big new piece of work inside the same conversation. Both are moments where freeing up context pays off. If instead you're switching to something unrelated, /clear is the cleaner choice.
