All articles

/clear vs /compact: Managing Your Context Window

Claude Code keeps everything you say and do in a single running conversation. That memory is called the context window, and it fills up. When it gets crowded, replies slow down and Claude can lose the thread. Two commands help: /clear and /compact. They do different jobs.

/clear wipes the slate

Use /clear when you finish one task and start something unrelated. It resets the conversation so old, irrelevant detail stops taking up room.

/clear

Reach for it between jobs. Fixing a bug, then writing docs? Clear in between. There's no reason to carry the bug hunt into the docs work.

/compact keeps the thread

Use /compact when you're mid-task and don't want to lose the plot, but the chat has grown long. It summarizes the conversation so far, keeping the important bits and dropping the noise.

/compact

You can steer what it keeps by adding instructions:

/compact focus on the database schema decisions

That tells Claude which details matter so the summary protects them.

A simple rule

Ask yourself one question: do I still need this history? If yes, /compact. If no, /clear. If you just want to see how full things are before deciding, run /context to check the current state. Clearing early and often keeps each task clean, and compacting at the right moment saves a long, valuable session from getting sluggish.

Comments

Be the first to comment.