2026-06-04
/clear vs /compact: Two Ways to Fight a Growing Context WindowEvery Claude Code session has a context window — a ceiling on how much conversation it can hold at once. Long sessions push you toward that ceiling, and what happens next matters.
Context window — the total amount of text (your messages + Claude's replies + any files read) that Claude can "see" at one time. Beyond this limit, older content gets cut off or the session errors out.
Tokens — the units Claude counts. Roughly 1 token per 0.75 English words. A long coding session can burn tens of thousands.
Summarisation — compressing a long conversation into a shorter written summary that preserves the key facts without keeping every line verbatim.
You have two escape hatches when a session gets heavy. They are not interchangeable.
/clear is a hard reset. It deletes the entire conversation from Claude's memory. Fast, clean, and sometimes exactly right — but Claude forgets everything: what you were building, the decisions you made, the errors you already ruled out.
/compact does something smarter. It asks Claude to summarise the conversation so far into a compressed version, then replaces the full history with that summary. You keep the thread of what you were doing. Claude still knows the goal, the constraints, and the progress. You just shed the transcript weight.
Type either command directly in the Claude Code session prompt:
/clear
/compact
That's it. No arguments needed. /compact will pause briefly while Claude writes the summary, then confirm the context has been replaced.
You can optionally give /compact a focus hint:
/compact Focus on the data model decisions and the unresolved bug in the auth flow.
This steers what Claude treats as worth keeping when it writes the summary.
Reach for /compact when:
- You're mid-task and want to keep going without starting over
- You've had a long back-and-forth debugging session and context is getting expensive
- You want Claude to retain the "why" behind decisions already made
Reach for /clear when:
- You've finished one task and are starting something unrelated
- The session has gone sideways and you want a clean slate
- You suspect earlier context is actively confusing Claude's responses
Don't use /compact reflexively. If the summary Claude writes is vague or misses something critical, you're now working from bad notes. After compacting, skim what Claude kept — you'll see the summary it produced. If something important is missing, add it back in your next message before diving in.
Open an existing Claude Code session that's been running for a while — even just 20–30 exchanges. Run /compact and read the summary Claude produces. Ask yourself: does this capture what actually matters? If not, what would you add? That tells you exactly what to include in a focus hint next time.
Don't miss what's next. Subscribe to My Claude Daily Learning: