Context rot: why the AI forgets your instructions
At the start of the session, the assistant is brilliant: it follows your instructions, respects your style, gets your architecture. Two hours later it reintroduces a bug you'd fixed together, ignores a rule you set up front, and starts going in circles. You didn't do anything wrong — you've just met context rot, and it's very manageable once you see where it comes from.
Why it derails: context is working memory, not a hard drive
A language model doesn't "remember" your session the way you picture it. On every turn, it rereads everything that fits in its context window — your messages, its replies, the files it opened, the output of each command. That window is large, but finite. And everything competes for the same room.
Two things happen as the session grows:
- Dilution. Your opening instructions drown under hundreds of lines of diffs and logs piled up since. Models attend less reliably to what's buried in the middle of a long context — a well-known effect sometimes called lost in the middle.
- Eviction. When the window fills up, the oldest turns get summarized or dropped to make room. Your carefully worded early constraint can literally fall out of the window, or be compressed into a summary that loses half of it.
In other words: the AI isn't ignoring you — it may no longer have what you said in front of it. Think RAM, not a hard drive.
The doom loop: when the AI goes in circles
The most maddening case is the doom loop: an error, an attempted fix, a new error, another attempt… and round it goes. Why does it get stuck?
Because the recent context fills up with the model's own failures. Each turn, it conditions itself on that pile of failed attempts and ends up copying its own confusion. Add contradictory state — it read one version of a file, you've changed it since, and both live in the window — and it no longer knows which one is true.
The tell to recognize: it repeats a solution already rejected, re-breaks what was working, or offers ever more convoluted variants of the same fix. When you see that, there's no point explaining it a sixth time. The problem is no longer your wording — it's in the window.
Keep your rules outside the window
The most robust defense is to not depend on the model's memory for your durable constraints. Rules files exist for exactly this: the tool feeds them to the model itself, each session, without you having to paste them back in.
Depending on your tool: CLAUDE.md for Claude Code, .cursor/rules for Cursor, and AGENTS.md, a shared convention emerging across assistants. You put the stable stuff in, not the one-off:
- the stack and project conventions ("always strict TypeScript," "no inline CSS");
- how to run the tests and the linter;
- the architectural boundaries to respect, naming, the repo's known traps.
One catch, precisely: a bloated rules file eats the same context budget and dilutes itself. More rules doesn't mean better rules — I trim mine the moment it gets chatty. The goal is a short, sharp signal the model rereads effortlessly.
Start fresh, without starting over
Here's the most counterintuitive reflex, and the most effective: when a session is spinning its wheels, don't push — open a new one. The accumulated context is no longer an asset, it's become the problem; clearing it gives the model back the clarity it had at the start.
"But I'll lose everything!" No — as long as you've externalized the state somewhere other than the chat:
- Commit often. Git is your permanent memory; the chat is disposable. If the work is in commits, you can reset without fear.
- Write a handoff summary. Before you cut, ask for a short status: what we're doing, what's done, what's left, the decisions made, the current blocker. A few lines is enough.
Then you start the new session seeded with that summary plus your rules file. The model starts fresh, but oriented. It's exactly like handing off to a colleague: you don't reread them the whole history, you give them the state and the heading.
In short
Context rot isn't a flaw in your prompting — it's a property of the tool: a finite working memory that dilutes and gets overwritten as you fill it. Three habits keep you on course — park your constraints in a rules file, commit so the chat becomes disposable, and start fresh with a summary when things stall. Work in short, framed sessions instead of one confused marathon: that's what vibecoding like a pro looks like.