Skip to content
Agents & Orchestration Intermediate

Context Management (Compaction)

Manage the 200K token context window with manual and auto compaction

Command

"color:#9CA3AF;font-style:italic"># Inside an interactive session:
$ /compact Focus on API design decisions and test results
  
"color:#9CA3AF;font-style:italic"># Check what's consuming context:
$ /context
  
"color:#9CA3AF;font-style:italic"># Hard reset (lose everything except CLAUDE.md):
$ /clear

Response

| Command  | Effect                                    |
|----------|-------------------------------------------|
| /compact | Summarizes conversation, keeps working state |
| /compact [focus] | Summarizes with emphasis on topics  |
| /clear   | Wipes conversation, re-reads CLAUDE.md    |
| /context | Shows context window breakdown             |

Parsing Code

059669">">// Add to CLAUDE.md 059669">">for automatic compaction focus:
059669">">// # Compact instructions
059669">">// When you are using compact, please focus on
// test output and code changes

Gotchas

! Auto-compaction triggers at ~80-90% context window utilization
! CLAUDE.md survives compaction — it's re-read from disk every time

Related Recipes