Anatomy of Context Management
0β80%+ usage playbook, auto-compact, memory strategies, reset rituals.

The 0β80%+ usage playbook for Claude Code β auto-compact tuning, memory strategies, and reset rituals that keep your AI teammate sharp.
TL;DRβ
- Context = everything Claude remembers right now (messages, files, tool outputs, thoughts).
- The window is finite. When it fills, quality drops and the session breaks.
- Watch the meter: 0β60 % work normally Β· 60β80 % compact Β· 80 %+ reset.
- Auto-compact is your best friend β tune it in
.claude/settings.json. - Memory strategies: ephemeral, summaries, project (
CLAUDE.md), session, vector. - Reset rituals: soft (compact + summarize) and hard (
/clear+ reload essentials).
Why this mattersβ
Think of context as RAM for your AI teammate. Stuff too much in, and everything slows down, hallucinates, and crashes. Curate it like a senior engineer curates their desk: only what you need, where you need it, when you need it.
Bottom line: Context is your most precious resource. Manage it deliberately.
The Big Pictureβ
Bottom line: Sources fill β meter rises β compact, summarize, or reset.
What Is Context, Really?β
Context is the live working memory of the session. It includes:
| Source | What it contains | Impact |
|---|---|---|
| User messages | Your prompts & clarifications | LowβMed |
| Loaded files | Files read or @-referenced | π΄ High |
| Tool outputs | Bash, Grep, MCP, web fetch | π΄ High |
| Search results / web | Page content pulled in | π MedβHigh |
| Claude's thoughts | Reasoning trace | π‘ Med |
| System prompts & rules | CLAUDE.md, settings | Low (but always loaded) |
| Long outputs / diffs / logs | Logs, stack traces | π΄ High |
π‘ Tip: Load only what you need. Summarize the rest. Drop irrelevant.
Context Usage Meter β What the Numbers Meanβ
| Zone | Range | What it means | What to do |
|---|---|---|---|
| π’ Green | 0β60 % | Plenty of headroom | Work normally, add details freely |
| π‘ Yellow | 60β80 % | Time to compact | Start auto-compact, remove stale info |
| π Orange | 80β90 % | High risk | Models get forgetful, errors creep in |
| π΄ Red | 90 %+ | Critical | Context overflow risk β RESET NOW |
π‘ Tip: Watch the meter in the status bar. Don't wait for problems.
Auto-Compact β Your Best Friendβ
Auto-compact watches usage and automatically summarizes and prunes older content when thresholds are hit. Tune it in .claude/settings.json:
{
"env": {
"MAX_THINKING_TOKENS": "100000",
"CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "50",
"NO_COLOR": "1"
},
"features": {
"autoCompact": true,
"autoCompactMode": "balanced",
"autoCompactMinPct": "50",
"autoCompactMaxPct": "75"
}
}
Settings referenceβ
| Setting | What it does |
|---|---|
MAX_THINKING_TOKENS | Upper bound for thinking/output tokens |
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE | Start compacting when usage hits this % |
autoCompact | Enable automatic summarization & pruning |
autoCompactMode | aggressive Β· balanced Β· conservative |
autoCompactMinPct | Never compact below this % |
autoCompactMaxPct | Hard ceiling that forces compact |
π‘ Tip: A 50 % override is the sweet spot for most teams. Aggressive only if you regularly hit 80 %.
Mode trade-offsβ
| Mode | Pros | Cons |
|---|---|---|
aggressive | Long sessions, low cost | More fidelity loss |
balanced β | Default recommended | Predictable trade-off |
conservative | Maximum fidelity | Runs out of context faster |
Memory Strategies β Keep What Mattersβ
Different facts deserve different homes:
| Type | What it is | Lifetime | Where |
|---|---|---|---|
| Ephemeral (short-term) | Active task chatter | Session only | Context window |
| Summaries | Condensed long threads | Session or docs | In-session or docs/sessions/ |
| Project memory | Conventions, decisions, patterns | Permanent | CLAUDE.md |
| Session summaries | End-of-session capture | Permanent | docs/sessions/YYYY-MM-DD.md |
| Vector memory | Long-term semantic recall | Permanent | Vector DB or filesystem |
π‘ Tip: Right-size memory β active (window) β medium (summaries) β durable (project).
The memory hierarchy in codeβ
βββββββββββββββββββββββββββββββ
β ACTIVE CONTEXT (window) β β 0-80% target
βββββββββββββββββββββββββββββββ€
β SESSION SUMMARIES (docs/) β β persisted on /clear
βββββββββββββββββββββββββββββββ€
β CLAUDE.md (project memory) β β always loaded
βββββββββββββββββββββββββββββββ€
β VECTOR DB / search index β β retrieved on demand
βββββββββββββββββββββββββββββββ
What to Keep vs. Dropβ
Reduce noise without losing value:
| Strategy | When to use | Example |
|---|---|---|
| Summarize | Long exchanges | "Summarize our work so far." |
| Extract | Key facts, decisions, actions | "List decisions & action items." |
| Collapse | Long outputs | Replace with placeholder: <large log collapsed> |
| Archive | Reference later | Move details to docs/notes/2026-05-12.md |
| Chunk & Index | Recall later | Store in vector memory |
| Focus | Narrow scope | "Focus mode: next 3 steps only." |
π‘ Tip: Compress early, not late. Small compactions beat giant ones.
Reset Rituals β Clean Breaks That Unlock Qualityβ
Soft Reset (Lighten the Load) β 5 stepsβ
Use when 60β80 %. Keeps the thread alive.
- Summarize current work in one paragraph.
- Archive details to
docs/sessions/<date>.md. - Clear irrelevant context (close files, drop outputs).
- Re-state the goal in one sentence.
- Continue with a leaner window.
Hard Reset (Start Fresh) β 5 stepsβ
Use at 80 %+ or when quality has clearly degraded.
/clearβ wipe session.- Restate the goal in one sentence.
- Re-load only essential files.
- Re-attach key context (links to docs, decisions).
- Rebuild from a clean slate.
π‘ Tip: When quality drops, reset. Don't fight a dirty context.
Step-by-Step Setupβ
1. Enable auto-compact in .claude/settings.jsonβ
{
"env": { "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "50" },
"features": {
"autoCompact": true,
"autoCompactMode": "balanced",
"autoCompactMinPct": "50",
"autoCompactMaxPct": "75"
}
}
2. Add session-end summarizer hookβ
"hooks": {
"SessionEnd": [
{ "matcher": "*",
"hooks": [{ "type": "command", "command": "./scripts/save-summary.sh" }] }
]
}
scripts/save-summary.sh:
#!/usr/bin/env bash
DATE=$(date +%Y-%m-%d)
mkdir -p docs/sessions
echo "# Session $DATE" > "docs/sessions/$DATE.md"
echo "_Auto-saved by Claude Code_" >> "docs/sessions/$DATE.md"
3. Add a /status slash commandβ
.claude/commands/status.md:
---
description: Show current context usage & session stats
usage: /status
---
Report:
- Context usage % and zone (green/yellow/orange/red)
- Window tokens used / total
- Auto-compact state & last compact age
- Files loaded
- Tool calls so far
- Memories active
- Session age
- Suggested next ritual (none / soft / hard reset)
4. Add a /memory slash commandβ
.claude/commands/memory.md:
---
description: Inspect memory & session summaries
usage: /memory
---
Show:
- Active context window items (top consumers)
- Recent session summaries (docs/sessions/)
- Project memory entries (CLAUDE.md)
- Vector memory hits (if enabled)
5. Make /status a muscle-memory habitβ
Run it every ~10 minutes during long sessions.
Monitoring & Toolsβ
| Tool | Purpose |
|---|---|
| Status bar | Live % usage & mode |
/status | Detailed context stats |
/memory | Inspect memory & summaries |
/clear | Wipe current session context |
Logs (.claude/logs/) | Historical usage trace |
| Hooks | Auto-compact & alerts |
Example /status outputβ
Context Usage: 68% (YELLOW)
Window Tokens: 68,340 / 100,000
Auto-Compact: ON (trigger 50%)
Files Loaded: 12
Tool Calls: 43
Memories: 3
Last Compact: 2m ago
Session Age: 47m
Next Ritual: β οΈ Consider soft reset
Variants for Different Team Settingsβ
π€ Solo developerβ
Keep it light. autoCompactMode: balanced + /status every 15 min.
{ "features": { "autoCompact": true, "autoCompactMode": "balanced" } }
π₯ Small team (2β10)β
Standardize session-end summaries so handoffs work.
"hooks": {
"SessionEnd": [{ "matcher": "*",
"hooks": [{ "type": "command", "command": "./scripts/save-summary.sh" }] }]
}
Commit docs/sessions/ so the team sees the trail.
π’ Enterprise / regulatedβ
- Cap costs: lower
MAX_THINKING_TOKENS, setautoCompactMode: aggressive. - Audit memory: log every compact + reset to SIEM.
- PII discipline: never persist sensitive context to disk.
{
"env": { "MAX_THINKING_TOKENS": "50000", "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "40" },
"features": { "autoCompactMode": "aggressive" }
}
π Open-source / communityβ
- Document the team's context conventions in
CONTRIBUTING.md. - Provide a
/onboardcommand that loads only the essentials. - Use vector memory for the codebase index so context stays lean.
Bottom line: Same playbook, escalating discipline.
Anatomy of a Single Reset β Soft Reset, Zoomed Inβ
Step 1 β Summarize:
"We refactored auth flow. Tests green. PR open."
Step 2 β Archive:
Save the summary + key decisions to:
docs/sessions/2026-06-26.md
Step 3 β Clear:
Drop loaded files: legacy/auth-old.ts, old logs
Keep: src/auth/*.ts, CLAUDE.md
Step 4 β Re-state goal:
"Ship auth refactor PR #421 by EOD."
Step 5 β Continue:
Next 3 steps: review feedback, update docs, request review.
Common Patterns & Recipesβ
Pattern 1 β "Summarize and continue" promptβ
Summarize what we've done so far in 5 bullets.
Save decisions to docs/sessions/<date>.md.
Then continue with: <next goal>.
Pattern 2 β Drop heavy artifactsβ
Drop the contents of legacy/old-service.ts from context.
Replace with: "<archived, see git log>".
Pattern 3 β Focus modeβ
Focus mode: only consider files under src/auth/.
Ignore tests and docs for the next 3 steps.
Pattern 4 β Auto-compact override mid-sessionβ
/config set CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=40
Pattern 5 β Session checkpointβ
Checkpoint: save current state, key files, and goal to
docs/sessions/checkpoint-<timestamp>.md so I can resume tomorrow.
Pattern 6 β Vector memory recallβ
Search project memory for "auth decision rationale 2026".
Load only the top 3 results.
Habits That Keep You in the Greenβ
- π― Define the goal early β and keep it visible.
- π Load files just-in-time β not all at once.
- π Summarize frequently β small > large compactions.
- ποΈ Archive details to docs/ or memory.
- π Ask for focused outputs β "the 3 most important issues".
- βοΈ Use auto-compact and tune the threshold.
- π Reset when quality drops (don't be stubborn).
- β Review what matters β not everything.
πͺ Golden Rule: Curate ruthlessly. Keep context small, relevant, and current.
Anti-Patterns β (Context Killers)β
- ποΈ Dumping entire codebases into context.
- π Keeping solved threads alive for sentimental reasons.
- π¬ Long chats with no value β every turn is tokens.
- π Massive logs inline β collapse them.
- π Ignoring the usage meter until it's red.
- π Never resetting β fighting a dirty context.
- π―οΈ Verbose outputs β ask Claude to be concise.
- π€ Trusting questions over signals β believe the meter.
β οΈ These lead to hallucinations, slowdowns, and session failures.
Troubleshootingβ
| Symptom | Cause | Fix |
|---|---|---|
| Slow responses | Window > 70 % | Compact or soft reset |
| Hallucinations / wrong facts | Stale context | Hard reset + reload essentials |
| Repeating itself | Lost focus | Re-state goal in one sentence |
| Forgets file you mentioned | Auto-compacted it out | Re-attach with @file |
| Cost spike | High MAX_THINKING_TOKENS | Lower cap, enable auto-compact |
| Auto-compact too aggressive | Mode too tight | Switch to balanced |
| Session crashes at 100 % | No auto-compact | Enable + lower threshold |
Quick Checklist (before any long session)β
- β Goal restated in one sentence
- β Only needed files loaded
- β
Recent decisions captured in
CLAUDE.md - β Irrelevant info dropped
- β Summaries updated
- β Next steps clear
- β Usage < 60 %
π‘ Tip: Run this checklist when you feel Claude slowing down.
Getting Started (6 steps)β
- Watch your usage meter (stay < 60 %).
- Define the goal in one sentence.
- Load only essential files.
- Summarize & compact regularly.
- Persist important info to
CLAUDE.md. - Reset when quality drops.
Minimal Starter Configβ
{
"env": {
"MAX_THINKING_TOKENS": "100000",
"CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "50"
},
"features": {
"autoCompact": true,
"autoCompactMode": "balanced",
"autoCompactMinPct": "50",
"autoCompactMaxPct": "75"
},
"hooks": {
"SessionEnd": [
{ "matcher": "*",
"hooks": [{ "type": "command", "command": "./scripts/save-summary.sh" }] }
]
}
}
Glossaryβ
- Context window β Total tokens Claude can "see" right now.
- Auto-compact β Automatic summarization to free space.
- Soft reset β Compact + archive + continue.
- Hard reset β
/clear+ reload essentials. - Ephemeral memory β Lives only in the session.
- Project memory β Persisted in
CLAUDE.md. - Vector memory β Semantic search over long-term knowledge.
- Session summary β Compact record of what happened.
- Compaction threshold β The % usage at which auto-compact triggers.
Further Readingβ
- Search: "Claude Code context window management"
- Search: "LLM context compression techniques"
- Search: "retrieval augmented generation memory strategies"
- Search: "long-running AI agent session design"
πͺ Rememberβ
Context is your most precious resource.
- π§Ή Keep it lean
- π― Keep it relevant
- π Keep it current
- π Compact often
- π Reset fearlessly
- π Measure always
- π Deliver better