DEV Community

Cover image for When to /clear or /compact a Claude Code session
Georgi Kalchev
Georgi Kalchev

Posted on Originally published at aiskills402.com

When to /clear or /compact a Claude Code session

Clear when a task is done, compact with a focus when it goes on, finish a step first when a deploy is unchecked. We read the docs and tested 30 snapshots.

Clear once the work is done and whatever comes next is unrelated. Compact, with a focus text, when the same task must go on but the context has grown heavy. Finish the current step first when a deploy or a migration has not been checked yet. Otherwise keep going. Before any fresh session, write down whatever exists only in the conversation, because the new session starts empty. Do not wait for auto-compact: on a model with a native 1M window it does not trigger before about 967 000 tokens (model configuration). And the agent cannot type the command for you, so its job is to save everything and then hand you the exact line to enter.

Read the full report on AISkills402: https://aiskills402.com/blog/claude-code-clear-or-compact?utm_source=devto&utm_medium=social

Top comments (1)

Collapse
 
brethofai profile image
BrethofAI •

"Write down whatever exists only in the conversation" is the step everyone skips at the end of a long day, and it's the one that decides whether /clear costs you anything. Disclosure: I build brethof-brain, which keeps every word of the session and curates the current state from it, so a fresh session starts with what bears on its first prompt. Even without a tool, a five-line hand-off note before /clear covers most of it.