Controlling context
You are halfway through writing tests for the auth module. Claude Code has picked up the patterns from the first two functions, and you are cruising. Then, on the third function, it takes off in the wrong direction — mocking something it should not — and now its context is full of bad reasoning you do not want polluting the next request. This is the situation the controlling-context toolkit exists for. Knowing these commands is the difference between a productive session and one you abandon and restart.
Claude Code keeps roughly 200,000 tokens of context. That is a lot, but it fills up — with exploration, with back-and-forth, with tool results you no longer need. The five techniques below form a progression from quick redirect at one end to full reset at the other.
1. Escape — interrupt and redirect
Press Escape once to interrupt Claude mid-response. It stops whatever it was saying or doing. You can then type a corrected instruction and continue. Use this the moment you see Claude heading somewhere unhelpful — you do not have to let it finish a bad answer before you course-correct.
2. Escape + Memory — stop a mistake from repeating
This one is more powerful than it looks. When Claude makes a specific mistake you know you will see again — "it keeps using var instead of const" or "it keeps mocking the database in unit tests" — combine Escape with memory mode.
-
Press Escape to stop the response.
-
Start your next message with
#and write the rule you want Claude to remember. For example:# In this project, never mock the Prisma client in unit tests — use the test database. -
Claude appends the rule to the appropriate
CLAUDE.mdand now every future request in this project carries that guardrail.
You have just turned a one-time correction into permanent behaviour. This is the highest-leverage context control move in the toolkit.
3. Double Escape — rewind the conversation
Press Escape twice and Claude Code shows you the full list of previous messages in the session. You can jump back to any earlier point — effectively rewinding the conversation to before a chunk of irrelevant debugging.
The trick is that Double Escape keeps what you want and drops what you do not. Compare that to starting over: you would lose everything Claude has learned. Compare it to pressing on: you are carrying dead weight. Rewind gives you the best of both.
Use Double Escape when a specific debugging detour clogged up the conversation but the earlier reasoning is still worth keeping.
4. /compact — summarise the conversation
Running /compact tells Claude to summarise the entire conversation so far and replace the raw history with the summary. Crucially, it preserves Claude's learned knowledge — the patterns it has figured out, the decisions you have made together — while shedding the verbose back-and-forth.
Reach for /compact when Claude has built real expertise in your project across a long session and the conversation is starting to feel sluggish. You want to keep the expertise and lose the transcript.
5. /clear — full reset
/clear deletes the entire conversation history. Fresh slate. No memory of anything that happened in this session (CLAUDE.md still applies, of course).
Use /clear when you are switching to a completely unrelated task. The context from debugging auth has no business hanging around while you write a new feature for the reporting module.
The progression
- Escape — stop a bad response.
- Escape + Memory — stop it and make sure it never happens again.
- Double Escape — rewind past the part that went wrong.
/compact— keep the wisdom, drop the transcript./clear— full reset for a new task.
These are not convenience features — they are the core operators of an AI-assisted development session. The same way you reach for git reset, git stash, and git rebase without thinking about it, you should reach for these without thinking about it.
Key Takeaways
- 1Escape interrupts Claude mid-response — use it the instant you see the answer going wrong.
- 2Combining Escape with memory mode (`#`) turns a one-time correction into a persistent rule in CLAUDE.md.
- 3Double Escape rewinds the conversation to an earlier point, keeping useful context and dropping irrelevant debugging.
- 4`/compact` summarises a long conversation while preserving what Claude has learned, and `/clear` fully resets for a new task.
- 5Claude Code holds roughly 200K tokens of context — managing that budget is a core skill, not a power-user trick.