How Claude Code's Context Eviction Is Silently Destroying Developer Work
What happens when your AI coding assistant forgets everything mid-task — and how to stop it.
Aman Singh·
4 min read·
You're three hours into a Claude Code session. It's refactoring your backend, writing tests, fixing bugs. Everything is going perfectly. Then slowly — almost imperceptibly — it starts making decisions that contradict instructions you gave an hour ago. You didn't change anything. Claude didn't warn you. It simply forgot.
This is context eviction. And it's costing developers hours of work every day.
What Is the Context Window?
Claude Code doesn't work like ChatGPT where each message is fresh. It runs in long sessions — reading files, running commands, tracking changes — all inside one giant running memory called a context window.
Think of it like a whiteboard. Every file Claude reads, every error it sees, every rule you give — it all gets written there. Claude Sonnet holds around 200,000 tokens. Claude Opus holds up to 1,000,000. That sounds enormous until you're deep inside a real codebase — then it fills up faster than you expect.
When the whiteboard hits 95% full, something triggers automatically: context compaction.
What Is Context Compaction?
Claude Code takes your entire conversation history, sends it to a separate internal model call, compresses it into a shorter summary, and replaces the original with that summary. You don't get a warning. You don't get asked. The session continues as if nothing happened.
The problem: the summary is imperfect. Specific decisions, subtle preferences, nested rules, and exact reasoning from earlier in your session — all of it gets compressed, truncated, or silently dropped.
What Survives — and What Doesn't
Survives compaction:
Your root CLAUDE.md file
Main project structure
Recent messages
Gets lost or badly summarised:
Specific decisions made earlier in the session
Nested CLAUDE.md rules in subdirectories
Preferences you mentioned in passing
The reasoning behind earlier architectural choices
Real Developer Experiences
A developer ran an always-on Claude Code agent for 200 minutes. After compaction triggered, it forgot a security rule set at the beginning of the session and introduced a vulnerability it had explicitly been told to avoid. No warning was given. The session logs showed nothing unusual.
In March 2026, Claude Code's source code was accidentally exposed publicly — 1,900 files, 512,000+ lines of TypeScript. The leak revealed the internal compaction logic in detail. The dev community spent weeks analysing exactly how context eviction works under the hood, and confirmed what many had suspected: the summarisation process is lossy by design.
Meanwhile, Microsoft began cancelling thousands of internal Claude Code licences, with its Experiences & Devices team winding down usage by June 30, 2026. Context management friction was cited alongside the push to consolidate on GitHub Copilot CLI.
5 Rules to Protect Your Work
- Write everything important in CLAUDE.md. This file survives compaction. Any rule, preference, or constraint you care about must live here — not just in your chat messages.
- Run /context regularly. This shows you exactly what's consuming your context window. Check it before long sessions.
- Exit at 80% full. When you hit 80% context usage, exit and restart fresh. This single habit prevents the performance degradation that kills productivity on large projects.
- Use /compact manually before it auto-triggers. Running it yourself lets you control what gets summarised rather than leaving it to the automatic process at 95%.
- Break big tasks into phases. Treat the context window as something to actively protect rather than passively fill. Plan each phase, complete it, then start a fresh session.
The Bigger Picture
Context management tools are improving fast. Persistent project memory, plan mode, and automatic compaction are all getting smarter. In 2026, more of the orchestration burden sits with the tool rather than the developer.
But the fundamental constraint remains: context windows are finite, and the compaction process is imperfect. The developers who understand this will ship faster and lose less work than those who don't.
Claude CodeAI Coding ToolsDeveloper ProductivityContext WindowAnthropic
Written by Aman Singh
Software Developer
Responses (0)
Log in to join the conversation
No responses yet. Be the first to share your thoughts.

