Context is a budget
Every message, file read and command output takes up room in the context window. A focused context gives you sharper answers, faster turns and lower cost. A cluttered one gives you a confused agent that remembers the wrong things. Claude Code does a lot of this management for you, and auto-compaction kicks in when space runs low, but knowing three commands puts you in control.
/context: see what's in there
/context shows a grid of what's using space: system prompt and tools, memory files like CLAUDE.md, skills, MCP tools and the conversation. Use /context all for per-item detail, such as which CLAUDE.md files loaded and what each MCP tool costs.
Check /context when a session feels slow or "forgetful", after connecting a new MCP server, or when your CLAUDE.md has grown. It's also the quickest way to confirm a file you expected actually loaded.
/compact: summarize and keep going
/compact replaces the conversation so far with a summary, freeing room while preserving the thread. Its superpower is focus instructions: tell it what matters.
/compact keep the final schema design and the list of failing tests; drop the explorationAfter compaction, Claude Code re-reads your project-root CLAUDE.md, so standing instructions survive.
/clear: start fresh
/clear starts a brand-new, empty conversation. Use it between unrelated tasks. Finished the auth bug and moving on to the CSS refactor? /clear. Old context about auth would only distract. You can name the session you're leaving, as in /clear oauth-migration, and resume it later.
/btw: the side-question trick
Need a quick answer ("what's the flag for verbose output again?") without stuffing it into your main thread? /btw asks a side question that isn't added to the conversation history.
/btw what's the difference between git merge --squash and rebase?Habits of context pros
- One task per session. Use
/clearliberally. It's free. - Delegate heavy reading. "Use a subagent to find every caller of
chargeCard" keeps hundreds of lines of search results out of your main context. - Don't paste giant logs. Save them to a file and let Claude
grepit, or pipe them in:cat build.log | claude -p "why did this fail?" - **Keep
CLAUDE.mdlean.* It loads on *every request (Lesson 7).
Write the command that compacts the conversation while keeping the API design decisions
Check your understanding
When should you use /clear instead of /compact?
What makes /compact far more useful?
What does /btw do?
What's re-read automatically after compaction?