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

Jeff Liu··3 min read·AI Agents
The AGENT Rule Refactor: Cutting 45 Files Halved My Context Load

Key Takeaways

  1. 1Loading 170KB (~25,000 tokens) of rule context per session caused measurable quality degradation in AI agent output.
  2. 2Reducing from 45 to 30 rule files and 170KB to 72KB immediately improved output quality — not by adding rules, but by removing redundancy.
  3. 3Context overload mirrors human cognition: Miller's Law states working memory holds 4-7 items before performance drops.

I've been building with AI agents for months. Custom rules, workspace knowledge, skill files, honestly probably too much of all of it. At one point I had 45 rule files telling my 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 I couldn't quite 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. So I did the thing that made it worse, I kept adding more rules to fix the problems the other rules were causing.

The measurement

Then I actually measured it. Each session was loading roughly 170KB of rule context, about 25,000 tokens, before I even said anything.

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.

I've come to think 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 I actually cut

So I made myself delete half of them. Not randomly. I went through every file and asked 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 making me feel like I covered my bases?

If it was redundant, it got cut. If two rules overlapped, I merged them. If a file was over 5KB, I split it 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 I stopped treating "add another rule" as the fix and started 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 began as a cleanup on my own platform and became a discipline I reuse on every build, client work included. Less context, followed carefully, beats more context skimmed. The rule cleanup alone saved about three days of accumulated drift, which is a good return for deleting files.

FAQ

When an AI agent loads excessive context (e.g., 170KB / 25,000 tokens of rules), it becomes overwhelmed and starts filling in gaps rather than admitting uncertainty. This mirrors Miller's Law in human cognition — working memory can only hold 4-7 items before performance degrades.

The author reduced from 45 files (170KB) to 30 files (72KB), saving ~25,000 tokens per session. The key is not a magic number but eliminating redundancy, merging overlapping rules, and keeping individual files under 5KB so they only load when relevant.

Context overload occurs when an AI model receives more instructional context than it can effectively process. The model begins skimming, missing contradictions between rules, and confidently generating incorrect outputs — often called hallucination.

Related Articles

More insights on trending topics and technology

Newsletter

We read 100+ sources so you don't have to.

One email. Delivered weekly. The AI and tech stories actually worth your time.