New: SEO Blog Writer, a readable, checked blog post for your site every week. Pay once, download straight away.

See it
AI Skill Up
Browse skills

When to use /compact in Claude Code, and when to start fresh

Compacting frees context by summarising the conversation, and loses detail. When /compact is right, how to steer what it keeps, and when /clear is better.

Every Claude Code session has a context window, and long sessions fill it. When it gets close, Claude Code compacts automatically, often in the middle of something. Choosing the moment yourself is usually better, and choosing between compacting and starting over is the real decision.

What compacting does

It summarises the conversation so far and replaces it with the summary. Context drops, and the session continues. What is lost is detail: exact error messages, the reasoning behind a choice, a file's contents Claude read earlier.

Steer the summary

/compact keep the failing test names, the decision to use a worktree, and the list of files still to change

Instructions after the command tell the summary what matters. Without them, it guesses.

Compact, clear, or new session

SituationBest move
Mid-task, context past half, still need the history/compact with instructions
Task done, next task unrelated/clear
Session has gone in circlesWrite a short summary yourself, then /clear
Different project or branchA new session in that folder

Pick the moment

The best time to compact is at a boundary: tests pass, a step is committed, a decision is made. The worst is mid-debug, when the details you are about to lose are the ones you need. That is why seeing context usage all the time helps; see seeing your Claude Code context usage.

Reduce what fills it

Some of the context is not conversation: project instructions and installed skills' descriptions are read every turn. Trimming those gives every session more room. See CLAUDE.md too long.

Capsule Status Line keeps context on screen as a capsule that turns amber at 60% and red at 85%, so you compact at a boundary you chose instead of when the window forces it.

Questions

What does /compact do?

It replaces the conversation so far with a summary, freeing context for the rest of the session. You can add instructions after the command to say what the summary should keep.

What is the difference between /compact and /clear?

/compact keeps a summary of the conversation and continues. /clear discards it and starts a fresh conversation in the same session, with only your project instructions loaded.

Does Claude Code compact automatically?

Yes. When context gets close to full, Claude Code compacts on its own. Compacting yourself at a natural break gives you control over when it happens and what it keeps.

Or skip the afternoonand drop one in.