Related ToolsClaude CodeClaude

Claude Code Has 4 Context Tools - Most Users Only Know Two

Editorial illustration for: Claude Code Has 4 Context Tools - Most Users Only Know Two

Most Claudee Code](/tools/claude-code/) users know two commands: /clear when something goes wrong, and /compact when the session gets sluggish. According to Anthropic's official best practices documentation, there are four distinct tools for managing context - and picking the wrong one for the situation costs you either performance or continuity.

The problem is real. Context windows (the total amount of text the AI can hold in mind at once) sound enormous until you've spent three hours debugging a problem and Claude is hauling around every failed approach, every red herring, every discarded idea from the morning. "Long sessions with irrelevant context can reduce performance," Anthropic writes. That's not a disclaimer - it's a design constraint worth taking seriously.

The Signal That You Need to Act

Anthropic puts a specific number on when to intervene: if you've corrected Claude more than twice on the same issue in one session, the context is cluttered with failed approaches. At that point, you're not working with a fresh assistant - you're working with one that has absorbed your missteps and may keep anchoring to them.

This is the most useful diagnostic in the docs. It's not about session length or how many tokens you've used. It's about whether your working context is helping or hurting.

The Four Tools and When Each One Wins

/compact is the right default when you want continuity. It compresses the conversation by summarizing what happened - you lose the verbatim history but keep the gist. Use this when you're mid-task and things are getting slow but you haven't made fundamental errors. Adding focus instructions (e.g., /compact focus on the authentication module) tells Claude what to prioritize in the summary.

/clear is a hard reset. Everything goes. Use this when you've hit the "corrected twice on the same issue" threshold, when you're switching to a completely different part of a project, or when the session has gone sideways and you'd rather start clean than debug Claude's mental model.

Memory files (a CLAUDE.md file at your project root or in subdirectories) store persistent context that survives between sessions entirely. This is where you put things that should always be true: architecture decisions, code style rules, which patterns to avoid, how to run tests. Claude reads these automatically at session start. If you find yourself re-explaining the same thing every session, it belongs in a memory file.

The fourth tool is the # shortcut for adding notes mid-session without breaking flow. Type # [note] and Claude stores it without treating it as a task instruction. Useful for flagging decisions you want to remember - "# decided not to use Redis here, latency isn't the bottleneck" - without derailing the current thread.

How to Actually Use This

The decision tree is straightforward:

  • Starting a new session on a known project? Make sure your CLAUDE.md is current.
  • Mid-task, session getting slow, no major errors? /compact with focus instructions.
  • Corrected the same mistake twice? /clear and start fresh.
  • Just realized something that should be permanent project knowledge? # to capture it now.

The underlying point from Anthropic's docs is that context management is active work, not something you do once something breaks. The developers who get the most consistent output from Claude Code treat context hygiene the same way they treat version control: a habit, not an afterthought.