What it does
/compact summarizes your conversation history and compresses it into a smaller context footprint. When you invoke it, Claude Code reads your full transcript, synthesizes the key facts and decisions into a concise summary, and loads that summary into your next turn instead of the full conversation thread. This frees up tokens for new work without losing the important context—previous findings, design decisions, debugging steps, and memory snapshots all roll up into the summary.
The tool auto-triggers when you approach the context window ceiling, but you can also invoke it manually. The compressed summary is persistent; future turns in the same session load the summary first, then any fresh conversation context on top of it.
When to use it
Manual /compact is useful when:
- You've just completed a big task (multi-file refactor, feature implementation, bug hunt) and now want to start a fresh phase of work without dragging the full history along
- Your conversation has accumulated lots of back-and-forth on a problem that's now solved, and you want to reclaim space for new investigation
- You're switching focus—moved from frontend to backend, or from a specific bug to a new feature—and want the summary to reflect the shift so future context doesn't bloat
Auto-trigger happens when:
- The conversation approaches ~80% of the context limit. Claude Code detects this and proactively summarizes to give you runway for continued work without hitting the hard ceiling.
The key insight: you're not losing information, you're trading tokens for continuity. The summary captures decisions, key findings, and prior state; details about specific file edits or output logs get distilled away.
Try it yourself
Type /compact in the terminal when you have a long conversation running and want to see the summary, or just keep working and let it trigger automatically as the context grows. The summary appears as a system message, and you can verify it captured the important decisions by skimming the output.
Gotchas
- Summaries are lossy. Details about exact line numbers or specific error messages may not survive compression. If you need that precision later, the full transcript is still in your session history—you can scroll back or reference it explicitly.
- Auto-trigger is transparent. You won't be asked when it happens; it just silently summarizes and keeps going. Check
/statusor the system message if you want to see when compaction occurred. - One-shot info doesn't survive well. If you fetched a URL or ran a one-time diagnostic command early in the session, the output may be summarized away. If you need it again, run it again or ask the summary to recall it.
- Compaction resets line numbers. After compaction, references to "line 42 in the earlier transcript" become meaningless. Always use file paths and grep patterns instead.
- Can't undo. Once compacted, the full history of that span is gone from the session (though Anthropic's servers keep audit logs). Don't compact mid-task if you think you'll need to rewind.
Use /compact strategically at phase boundaries, not randomly mid-investigation.
Try it yourself
Type the command in the fake terminal. Nothing leaves your browser.