Yeda AI Tips · #103

Español

That Ugly Code Is Load-Bearing

That ugly code you're about to delete? It might be load-bearing. AI agents love to tear down fences they don't understand — a "simplify this file" prompt will happily strip the retry loop that guards a flaky vendor API, or the timezone special-case that took someone three production incidents to get right. Accumulated complexity sometimes has a reason, and sometimes doesn't. Your job is to find out which — before the diff lands.

The rule: Chesterton's Fence

In 1929, G.K. Chesterton described a reformer who finds a fence across a road and wants it gone. His answer: "If you don't see the use of it, I certainly won't let you clear it away. Go away and think." Only when you can explain why the fence was put up have you earned the right to remove it.

The principle maps one-to-one onto code review of AI-generated deletions. The agent didn't build the fence, has no memory of the incident that motivated it, and optimizes for "cleaner" — the exact profile of Chesterton's careless reformer. The fix isn't to ban deletions; it's to demand the archaeology first.

The 3 questions before any deletion

Before removing anything weird, answer these — and make your agent answer them too:

QuestionCommand that answers it
Why was it written?git blame -w -C <file>, then git show <commit> for the message and linked issue
How did it evolve?git log -L <start>,<end>:<file> (or -L :<funcname>:<file>) — every commit that touched those lines
What depends on it?git grep <symbol> across tracked files, plus your editor's find-references

If any answer is "no idea," you're not ready to simplify. Read more context first, then cut with confidence.

Reading the blame like a detective

Power-user: make the agent do the archaeology

Resources

Building an AI feature? Yeda AI designs, audits, and ships production LLM systems.

Talk to us · Read the blog