
Your AI Has Amnesia
You wrote the rules. Your AI followed them. Then it quietly stopped.
The Brief
This article explains why AI coding assistants forget instructions during long conversations, grounded in the 'Lost in the Middle' research on long-context degradation. It introduces Claude Enforcer, an open-source tool that addresses context drift through on-demand skills, shell-script hooks, and isolated subprocesses.
- Why does my AI coding assistant forget instructions?
- Language models weight the beginning and end of their input most heavily. As conversations grow, early instructions drift into the middle of the context window, where research shows they get deprioritized. Degradation can begin when the context is only 20 to 40 percent full.
- What is context drift in AI?
- Context drift occurs when an AI stops reliably following instructions loaded at the start of a conversation. The instructions remain in context but get overlooked as newer messages push them into positions the model attends to less. It is rooted in the 'Lost in the Middle' phenomenon documented by Stanford researchers in 2023.
- What is Claude Enforcer?
- Claude Enforcer is an open-source, MIT-licensed tool for Claude Code that builds enforcement layers around context drift. It uses on-demand skills, shell-script hooks that block actions regardless of model memory, and isolated subprocesses that evaluate with fresh context. It installs with one command.
- How do hooks prevent AI instruction drift?
- Hooks are shell scripts that run before the AI acts, outside the model's context window. They intercept actions and check them against rules programmatically. Because hooks operate externally, they enforce rules regardless of what the model remembers or has forgotten during a long conversation.
I spent a Saturday morning writing rules for my AI coding assistant. Careful ones. Don't touch the production database. Always run tests before committing. Use this specific account ID, not that one. I tested them. They worked. By Monday afternoon, it had ignored half of them.
I didn't do anything wrong. The architecture did.
Researchers at Stanford published a paper in 2023 called "Lost in the Middle" that explains why.1 They found that language models weight the beginning and end of their input most heavily. Information in the middle gets overlooked. Not deleted. Not corrupted. Just quietly deprioritized, the way a long meeting makes you forget what was said at the 30-minute mark even though you were paying attention the whole time.
Some layers hold. Others fade.
The fascinating part? Later research suggests the degradation starts earlier than you'd think. Not when the context window is full, but when it's only 20 to 40 percent occupied.2 Your carefully written rules are sitting right where the model stops looking first.
Developers who use Claude Code, Anthropic's command-line AI assistant, run into this constantly. One developer tracked his skill activation rates over a month of intensive use. His finding was sobering. About 50 percent. A coin toss.3 The instructions were loaded. The model just drifted past them.
The Briefing Room Problem
Claude Code reads a file called CLAUDE.md at the start of every conversation. Think of it as a briefing room. Your project's architecture, your coding conventions, your "never do this" rules. The problem is that briefing rooms fade. Every message you send, every file you read, every tool call you make pushes those initial instructions further into the middle of the context. The very place the research says gets ignored.
The instinct is to write better instructions. More specific. More emphatic. But the problem isn't clarity. It's physics. Long context degrades attention the way a long hallway dims light. You can make the bulb brighter, but the hallway is still long.
What Holds
This got me thinking about what does persist. Not in the conversation, but outside it. I started building what became Claude Enforcer, an open-source tool that layers enforcement around the drift problem.4
The first layer is on-demand skills. Instead of a 500-line briefing that fades, you keep a lean set of essentials and invoke specialized instructions when you need them. Type /deploy when deploying. The context stays relevant because it arrives fresh.
The second layer lives entirely outside the model's context. Shell scripts that run before the AI acts. A hook doesn't care what the model remembers. If Claude tries to edit your .env file, the hook blocks it. Every time. Regardless of what happened in the conversation above.
The third layer is the one that surprised me. You can spawn a subprocess that starts with clean context and reads your rules directly, uncontaminated by the long conversation that caused the drift. It's the difference between asking a colleague who's been in the meeting all day versus pulling in someone fresh.
The tools that hold are the ones mounted outside the conversation.
The whole thing installs with one command and runs a first audit in about thirty seconds. It tells you where your instructions are drifting and what to do about it.
The rules you wrote were good. They just need a place to live where amnesia can't reach them.
References
Footnotes
-
Liu, N.F., et al. (2023). "Lost in the Middle: How Language Models Use Long Contexts." Transactions of the Association for Computational Linguistics. arXiv ↩
-
Veseli, B., et al. (2025). "Context Window Utilization and Performance Degradation in Large Language Models." Referenced in practitioner analyses of context quality thresholds. ↩
-
Spence, S. (2025). "Claude Code Skills Activation Rates." scottspence.com ↩
More to Explore

The Pilot Graveyard
AI tuberculosis detection worked beautifully in Kenya. Then the grant ran out and nobody could pay for the subscription.

Your Page's Resume
You let the crawlers in. What they found looks nothing like your website.

The Two Indias
India attracted $200 billion in AI investment the same week its biggest tech firms added seventeen employees. Nobody on stage mentioned the gap.
Browse the Archive
Explore all articles by date, filter by category, or search for specific topics.
Open Field Journal