You're Using /compact Wrong — Here's What It Actually Does Under the Hood
Most Claude Code users hit /compact like a panic button. But they never ask what actually happens. Here's the full breakdown — when it saves you, when it burns you, and the focus trick nobody uses.
Most Claude Code users hit /compact like a panic button when things get slow. "Context too long? Just compact it!" But they never ask what actually happens when they press enter. And that's exactly why they lose context, waste tokens, and wonder why Claude suddenly "forgot" everything.
I spent the last month using Claude Code 8+ hours a day building production features — auth systems, database migrations, multi-repo PRs. Along the way, I figured out exactly when /compact saves you and when it silently destroys your session.
Here's everything I learned.
What Actually Happens When You Type /compact
Claude has a fixed context window. Every message you send, every file it reads, every terminal output, every tool result — all of it sits in that window. Think of it as a whiteboard. Eventually, the whiteboard fills up.
/compact doesn't just "clean up." It does something specific:
- Claude reads your entire conversation — every message, tool call, and result
- It writes a structured summary: what you're building, decisions made, files changed, current state, what's next
- That summary replaces your full history
- The session continues from the summary — like Claude wrote itself a handoff note, wiped its memory, and read the note back
The raw turn-by-turn history? Gone. Released. Not recoverable.
This is powerful. It's also destructive. Understanding both sides is what separates people who use it well from people who shoot themselves in the foot.
The Massive Token Win Most People Miss
Here's what gets dropped and why it matters:
A single Playwright MCP call can dump 50,000+ tokens of accessibility tree into context. A large file read? 3,000-5,000 tokens. A git diff? Could be 10,000+. After an hour of work, you might have 200,000 tokens of raw tool output sitting in context — and 90% of it is noise.
After /compact, that 50,000-token Playwright dump becomes: "tested the login page, verified the auth guard redirect works, no errors." Maybe 30 tokens.
That's a 1,600x compression on a single tool call.
The summary keeps what mattered (the test passed, the redirect works) and drops what didn't (every role=button and aria-label in the DOM tree).
The Feature Nobody Uses: /compact focus on X
This is the real power move. When you type:
/compact focus on the database migration we're working on
Claude weights the summary toward that specific area. Migration-related decisions, SQL schemas, and file changes get preserved in detail. That random tangent about CSS styling from 30 minutes ago? Compressed to almost nothing.
Why this matters: After a 2-hour session that wandered through 3 different problems, your context is a mess. A plain /compact gives you a generic summary. /compact focus on the current task gives you a clean, focused context with only what you need right now.
I use this every time I switch gears within a session. It's like telling Claude: "Forget the noise, remember the signal."
When /compact Burns You
Here's the part nobody warns you about.
1. You Can't Un-Compact
The summary is Claude's interpretation of what mattered. If a detail seemed unimportant during summarization but turns out critical later, it's gone. There's no "undo." I once compacted after fixing a race condition, then 20 minutes later needed the exact error message from earlier. Claude's response: "I don't have that specific context anymore."
Lesson: If you think you might need exact outputs later, copy them somewhere before compacting.
2. Compacting Small Contexts Is Wasteful
Compacting costs tokens — Claude reads everything and writes the summary. On a 10,000-token conversation, you spend tokens to... save almost nothing. The math only works when context is large (100k+).
Rule of thumb: Don't compact until you're at least 30 minutes into heavy work with lots of tool calls.
3. Summary-of-Summary Drift
After multiple compactions, Claude is summarizing summaries. Each pass loses fidelity — like a photocopy of a photocopy. Two or three compactions in a long session? Fine. Five or six? The picture gets fuzzy. Names get dropped. Decisions lose their "why."
/compact vs /clear — Pick the Right One
This trips up almost everyone:
| Command | What it does | When to use |
|---|---|---|
/compact | Preserves work as a summary | Continuing the same task, reducing bloat |
/clear | Wipes everything completely | Switching to a new, unrelated task |
Using /clear when you meant /compact = you lose all context and start from zero.
Using /compact when you meant /clear = old task bleeds into the new one, confusing Claude.
Wrong tool = wasted tokens or lost context. Every time.
The Auto-Compact Trap
If you never run /compact manually, Claude triggers it automatically when context hits the limit. Here's the problem: auto-compaction is generic. No focus instruction. Just a blanket summary of everything.
It works, but it's the worst version of compaction — Claude decides what to keep, not you. By the time auto-compact fires, your context is maxed out, the summary is rushed, and important details get compressed away.
This is why you should compact manually before hitting the wall. You're always better positioned to tell Claude what matters than Claude is to guess.
My Daily Rhythm (What Actually Works)
After months of daily Claude Code usage, here's the habit that stuck:
- Every 20-30 minutes of heavy work:
/compact focus on [current task] - After big tool dumps (Playwright runs, large file searches, git diffs): compact immediately to flush the noise
- When switching problems:
/clearif it's truly new,/compact focus on Xif it's related - Never let auto-compact fire — if you see the context warning, you waited too long
This keeps sessions fast, accurate, and cheap. No more "Claude forgot what we were doing." No more surprise slowdowns at the 2-hour mark.
The One-Line Mental Model
/compactis Claude writing itself a handoff note, deleting its memory, and reading the note back. Powerful, lossy, and worth using deliberately — especially with focus instructions.
Stop using it as a panic button. Start using it as a tool.
I write about Claude Code, AI development workflows, and building production apps with AI. Follow me on Twitter/X for more deep dives.