Controlling Context
Conversation Flow Control
Long conversations with Claude Code accumulate context -- some valuable, some distracting. Claude provides several keyboard commands to manage this context precisely, preventing the degradation that comes from irrelevant information piling up.
| Command | Shortcut | What It Does | When to Use |
|---|---|---|---|
| Interrupt | Escape (once) | Stops Claude mid-response | When Claude is going in the wrong direction |
| Rewind | Escape (twice) | Shows message history, jump to any point | When you need to backtrack past a wrong turn |
| Compact | /compact | Summarizes conversation, preserves knowledge | Long sessions with accumulated clutter |
| Clear | /clear | Deletes all conversation history | Switching to a completely different task |
Four levels of context control
From lightest (Escape) to heaviest (Clear) context intervention
The Escape + Memory Pattern
One of the most powerful patterns is combining Escape with Memory. When Claude keeps making the same mistake -- like using the wrong import path or ignoring a project convention -- you can interrupt it, then use the # shortcut to add a permanent memory so the mistake never recurs.
# Claude keeps importing from the wrong path...
> [Escape to interrupt]
# Add permanent memory to prevent recurrence
> # Always import auth utilities from @/lib/auth, not @/utils/auth
# Claude now remembers this in all future conversations
# because it's written to CLAUDE.mdWhen to Use Compact vs Clear
Use /compact when Claude has built up valuable expertise about your current task but the conversation is full of failed attempts and debugging noise. It summarizes while preserving what Claude learned. Use /clear only when switching to a completely unrelated task where the old context would be harmful.
Key Takeaways
- ✓Escape interrupts, Double Escape rewinds, /compact summarizes, /clear resets -- four levels of control
- ✓Escape + Memory (#) is the most powerful pattern: interrupt mistakes and add permanent rules
- ✓Use /compact for long sessions where Claude has expertise but context is cluttered
- ✓Use /clear only when switching to a completely different, unrelated task
- ✓Good context management prevents the performance degradation that comes from irrelevant context accumulation
Check Your Understanding
Test what you learned in this lesson.
Q1.Claude keeps using the wrong import path despite corrections. What is the most effective fix?
Q2.When should you use /compact instead of /clear?
Q3.What does pressing Escape twice (double escape) do?