The context window is the most important resource to manage in Claude Code. As it fills up, Claude loses focus, costs increase, and quality degrades. Here are the three commands for managing it.
/clear: start fresh
Use /clear every time you begin a new task. Do not carry over context from an unrelated previous conversation.
# Finished fixing the auth bug, now moving to the search feature
/clear
Rule of thumb: One chat = one task. Scope each session to a single feature, bug fix, or investigation.
/compact: condense without losing everything
When your session is getting long but you are still working on the same task, use /compact to have Claude summarize the conversation and reduce token usage while preserving key context.
# Been debugging for a while, context getting large
/compact
You can also add a custom focus: /compact focus on the database migration changes
/context: audit what Claude sees
Use /context to visualize exactly what is in Claude’s current context window. This helps you understand what Claude is working with and identify unnecessary context.
Additional tips:
- Escape to stop, not Ctrl+C. If Claude is heading in the wrong direction, press Escape to stop it. Ctrl+C exits Claude Code entirely.
- Avoid pasting huge files when Claude can read them directly with its file tools. Reading is more token-efficient than pasting into chat.