Context Management
Every session has a finite context window. As it fills, older content gets squeezed and Claude can start to "drift." Managing context deliberately is what keeps long sessions sharp.
The two essential commands
/clear— wipe the conversation and start fresh. Use it when you switch to an unrelated task. Cheapest way to regain a clean, focused context./compact— summarize the conversation so far into a compact form, keeping the gist while freeing space. Use it when you want to continue the same task but the window is getting full.
Auto-compaction
When context approaches the limit, Claude Code can auto-compact so work continues without a hard stop. It's a safety net — but proactively /clear-ing between tasks gives better results than relying on it.
Techniques to stay effective
- One task per session. Don't let an afternoon of unrelated work pile into one context.
- Delegate heavy reading to subagents — they burn their context and return only the conclusion.
- Reference, don't paste. Point Claude at files (
@path) instead of pasting large blobs; keep CLAUDE.md lean. - Watch the budget. A statusline showing context use tells you when to compact.
:::tip Symptom → fix
If Claude starts forgetting an earlier instruction or repeating itself, the window is likely full. /compact (same task) or /clear (new task) usually fixes it instantly. More in Troubleshooting.
:::