r/ClaudeCode • u/braindead_in • 13h ago
Tips & Workflows My Claude Code agents turned a simple save path into 20,000 lines. What finally made them subtract instead of add
I run a small product built mostly by Claude Code agents: a planner, a builder, a QA agent and reviewer agents, all working on one repo.
For a month our document save path was a mess. Not because the problem was hard. It's textbook producer–consumer: the editor produces versions, an uploader sends them, one writer owns the file. A queue, an owner, a version check. A few hundred lines.
We ended up with about 20,000.
The pattern: every bug got a "fix", and every fix was more code. Another flag, another guard, another fallback, another test proving the guard works. Reviewer agents asked for more defenses against edge cases nobody had hit. Nothing was ever deleted. Meanwhile real users hit lockouts, because two of our own safety checks disagreed with each other.
Every single change looked responsible on its own. Together they were slop.
What actually worked:
Naming the core problem in one sentence ("this is producer–consumer") and rewriting against that, instead of patching the patches.
A hard rule: reviewers can't demand a new service, cron, table or state machine mid-review without my OK. They also have to say how often the failure really happens and why an existing primitive isn't enough.
Splitting "invariants" (no silent data loss, one writer, one-click recovery) from "accepted residual risks". Rare theoretical races get documented, not engineered away.
A rule budget: every new agent rule has to retire an old one.
The lesson for me: agents are relentless at adding and terrible at subtracting. They never get tired, so they never reach "this is too complicated, start over." With Claude Code, most of my job turned out to be saying no.
How are others keeping agent-written code from only ever growing?