All Editorials

The AGENT Rule Refactor: Cutting 45 Files Halved My Context Load

April 11, 20263 min read
The AGENT Rule Refactor: Cutting 45 Files Halved My Context Load

I'd been building with AI agents for months, and the config had sprawled. Custom rules, workspace knowledge, skill files, honestly probably too much of all of it. At one point it was 45 rule files telling the AI how to behave. Naming conventions, code patterns, anti-patterns, deployment checklists, security gates.

Forty-five files. And the AI was getting worse.

It wasn't broken, but the output was getting sloppy in ways that were hard to pin down. It would confidently reference a file path that didn't exist anymore. It would apply a pattern from one rule while ignoring a contradicting rule three files later. Code that technically followed the instructions and completely missed the point. And the reflex made it worse, more rules piled on to fix the problems the other rules were causing.

The measurement

Then I measured it. Each session was loading roughly 170KB of rule context, about 25,000 tokens, before a single word.

That's like handing someone a 50-page employee handbook and then asking them to fix a bug. They skim, they miss things, and whatever they don't see, they guess.

Our brains work the same way. There's a well-known idea in psychology called Miller's Law, that working memory holds only about four to seven things at once before it starts dropping them. Context overload isn't only an AI problem, it's a human one.

That's what a lot of hallucination actually is. Not the model being dumb, just the model drowning in your instructions and filling the gaps with something that sounds right. People do the same thing. When we don't know something, we don't always say "I don't know," we reach for the answer that pattern-matches to confidence.

What actually got cut

So I cut half of them. Not randomly. Every file got the same three questions. Is this contradicting another rule? Are two files saying nearly the same thing slightly differently? Is this actually reducing hallucination risk, or just there to feel like the bases were covered?

If it was redundant, it got cut. If two rules overlapped, they got merged. If a file ran over 5KB, it got split into smaller pieces that only load when they're relevant.

45 files became 30. 170KB became 72KB. Around 25,000 tokens saved per session.

The output improved immediately. Not because the rules were bad, but because fewer rules meant the model could actually follow the ones that mattered.

The pattern underneath

This turned out to be bigger than one config folder. The real lesson is that context is a budget, and past a point more of it makes the output worse, not better. That shows up anywhere signal competes with volume. Recruiters spend about six seconds on a resume, per an eye-tracking study from The Ladders, and they scan right past twenty bullet points to find the two that matter. Same failure mode as 45 rule files. Too much information, not enough signal.

So the fix stopped being "add another rule" and became budgeting context on purpose. Every agent system I stand up now starts lean, splits large rules so they load only when relevant, and gets audited for redundancy the same way. It started as a cleanup on one platform and became a discipline that carries into every build. The cleanup alone saved about three days of accumulated drift, a good return for deleting files.

The Signal

Everything worth knowing in AI.

One email a week.