TJ Larkin

AI workflows

Why do AI coding agents write too much code, and how do you fix it?

Short answer

Because agents add rules, restrictions and code far more readily than they delete. My team's custom agent system grew to 70,000 lines duplicating an open-source tool that already worked, which explained the random failures. Told to start over from zero, the coding agent cut less than 1% in two days. You have to insist on deletion.

We wrote 70,000 lines of code for an agent system that already existed and already worked as an open-source tool. That explained why so many random things just crapped out.

"These agents just don't like to cut code. It's almost like they treat code like it's their baby."

What happened when I told it to start over?

I told the coding agent we were starting over from zero: delete everything and rebuild only what's needed. Two days later, it had gone from 53,740 lines to 53,629. That's well under 1%. Asking once isn't enough. You have to insist, and keep insisting.

Why does this keep happening?

After repeated audits of my AI build system over a year, the diagnosis is always the same:

  • Too much code. Agents build more than the job needs.
  • Too many restrictions. Every problem gets a new rule or guard, so more and more things "need" to happen that don't.
  • Conflicting language. Rules in different files say different things, and the agent follows whichever it reads.
  • Symptom fixes. One agent found it had made about 14 earlier "fixes" to my survey software, each tuning a single query, when the real cause was an undersized database server. A $5 a month upgrade solved it.

As a non-technical founder, I talk plainly and rely on the system. That only works if the system is simple.

How do I stop it before it starts?

My rule is existing capability before new capability. Before custom code, go down this list:

  1. Use the current system correctly.
  2. Fix the root cause.
  3. Change a configuration or setting.
  4. Use something upstream or open source that already does it.
  5. Simplify or delete.
  6. Only then, write custom code.

Custom code is normal inside real products, like lightbreak, greetform and larkfeed. The higher bar is for internal plumbing: orchestration, memory and agent infrastructure. That's exactly where my 70,000 lines went. And never solve a narrow problem in a way that damages the larger system.

What do I say to the agent?

Before adding anything, tell me:
- Does something we already have, or an existing tool, solve this?
- What can we delete instead of add?
- Are any of our rules now conflicting?
I want fewer, clearer rules and less code. Deletions are wins.

When should I rebuild instead of patch?

When the cruft outweighs the product. My newsletter builder started about 16 months earlier in the early Replit days and collected so much dead code that, when I asked a current model whether to upgrade or restart, the answer was start over. With current models, a rebuild can be cheaper than patching forever.

Keep your agent instruction files lean for the same reason. Rules bloat just like code.

Answered by TJ Larkin. From team calls and AI build-system reviews in 2026. Last updated .

Related answers

TJ Larkin / Answers / AI workflows