Claude Code has a feature called auto-compact that quietly destroys your session quality.
The Problem
I was three hours into a multi-file refactoring session, had just finished explaining which modules needed interface changes and which were already done. Auto-compact fired at 80% context. When Claude came back, it had no idea which files had been edited and which still needed changes. It suggested modifying a file I’d finished an hour earlier and forgot a constraint I’d repeated twice. I had to re-explain the entire task from scratch.
The community calls this “lobotomization” and it’s accurate. Post-compaction Claude loses track of what repo you’re in, forgets constraints you set, drops skills you invoked. The quality drop is immediate and obvious.
A note on terminology: throughout this post I reference /flush, /project, and other slash commands. These are custom Claude Code skills I built (stored as markdown files in ~/.claude/commands/), not built-in features. /project loads a project’s saved state (CLAUDE.md with Working/Blocked/Next, domain topic files, recent daily logs) so Claude knows what happened last session. /flush captures the current session state to multiple places (daily log, project state, MEMORY.md, topic files) so the next session can pick up where this one left off. Think of /project as “load game” and /flush as “save game.” The skill files are simple markdown prompts that Claude follows as instructions.
The Technical Reality
Community analysis of Claude Code’s minified source found a hardcoded buffer that triggers compaction. The exact value has changed across versions (it was ~13k in early 2026, reportedly ~33k in later builds), but the mechanism is the same:
var jbA = 13000;
function lwB() {
let T = UhT(); // Available input (context - max_output_tokens)
let R = T - jbA; // Subtract 13k buffer
return R; // This is where auto-compact triggers
}
Buffer Reserved = max output tokens + safety buffer.
| Output Token Setting | Buffer Reserved | Usable Context |
|---|---|---|
| 64k (max) | 77k (38.5%) | 123k |
| 32k (default) | 45k (22.5%) | 155k |
| Auto-compact off | None | 200k |
With default settings, you’re losing 22.5% of your context window to a safety buffer you may never need.
These numbers reflect the ~13k buffer from early 2026 builds. If the buffer has increased in your version, the usable context will be lower. The principle holds regardless: auto-compact reserves a meaningful chunk of your context window.
Why This Matters
Research on iterative context rewriting (arXiv 2510.04618) calls it “context collapse”: when LLMs rewrite their own context iteratively, accuracy drops. Claude Code’s auto-compact does exactly this.
Compaction is lossy compression. You’re asking an LLM to decide what’s “important” and discard the rest. For the kind of work I do (multi-file refactors, constraint-heavy debugging sessions, anything where I’ve spent twenty minutes explaining what not to touch), that’s a bad tradeoff.
The Fix
Add one line to ~/.claude.json:
{
"autoCompactEnabled": false
}
Or run /config in an active session and toggle “Auto-compact enabled” off.
The New Workflow
With auto-compact disabled, you get the full 200k context window with no buffer held in reserve. No surprise compaction mid-task. The session stays coherent until you decide otherwise.
When I do need to reclaim context, I use /compact with explicit instructions: /compact "focus on the authentication refactor, discard the earlier debugging". This way I control what survives instead of letting Claude guess. More often, though, the better move is /export to save the conversation, then start a fresh session and have Claude read it back in. Fresh context, curated history, no lossy summarization.
I also dropped my flush threshold from 75% to 60%. When context hits 60%, Claude prompts me to run /flush before continuing. This captures the session state while there’s still room to maneuver.
The Tradeoff
Disabling auto-compact means sessions will hit the context limit. You’ll need to manually compact, export and restart, or finish the task before running out. I’d rather use that 45k toward skills, rules, and context I deliberately set up than reserve it for an automatic summarization that makes Claude worse.
Anthropic’s own guidance has moved toward recommending auto-compact stay enabled, and for simple single-task sessions that’s reasonable. For constraint-heavy work where I’ve built up significant context (multi-file refactors, debugging with specific rules about what not to touch), the automatic summarization loses too much.
Claude Code now supports 1M token context windows on some plans, which reduces the urgency of this problem. But context hygiene still matters at any window size. A 1M window fills up the same way a 200k window does, just slower. Knowing when to flush deliberately versus letting auto-compaction guess is a workflow discipline, not a context size question.
Session Management (Beyond Compaction)
The Context % Statusline
I have a custom statusline script that shows [XX%] at every prompt so I always know how much context is left. The script reads context_window.used_percentage from Claude Code’s JSON input and renders it inline:
# ~/.claude/statusline-command.sh
PERCENT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
printf "