Use /compact to Free Up Context Space When Your Session Gets Long
The longer your Claude Code session runs, the more context gets consumed by conversation history — every prompt, every file read, every tool call. Eventually Claude slows down or loses track of earlier details. That's when /compact saves the day.
> /compact
This tells Claude to compress the entire conversation into a concise summary, then continue from that summary. You keep the context of what you've been working on — decisions made, files changed, the current task — but free up a huge chunk of the context window for new work.
You can also pass a focus hint to guide what gets preserved in the summary:
> /compact focus on the auth refactor and the migration changes
This ensures the summary prioritizes the parts you care about most, letting less relevant conversation history (like earlier debugging tangents) get compressed more aggressively.
A few signs it's time to compact:
- Claude starts "forgetting" changes it made earlier in the session
- Responses get noticeably slower
- You're deep into a multi-step task and need room to keep going
/costshows you're approaching the context limit
Claude Code also auto-compacts when it detects the context window is nearly full, but running /compact proactively gives you more control over what gets preserved versus summarized.
The key difference from /clear: compacting keeps your working context while freeing space, whereas /clear wipes everything and starts completely fresh.
When your session feels sluggish, /compact before you /clear — you'll keep your momentum without losing your place.
via Claude Code
Log in to leave a comment.
When Claude starts referencing files you've since deleted, remembering old code you've already changed, or getting confused by contradictory instructions from a long session — type /clear to wipe the slate clean. Unlike /compact which preserves context, /clear gives you a true fresh start without restarting the CLI.
Not every task needs deep reasoning. Type /fast to switch Claude Code into fast mode — same model, faster output — for quick edits, simple questions, and routine changes. Toggle it off when you need Claude to think harder on complex problems.
Type /cost at any point to see how many tokens you've used in the current session, how much it's costing, and which operations are consuming the most context — so you can make informed decisions about when to /compact, /clear, or switch models.