The Economic Benefit of Refactoring

AI wrote a giant mess, and the comments say bosses still won’t pay to clean it up

TLDR: An AI-built app grew into a bloated mess, and the author says cleaning it up made the AI cheaper and more effective to use. Commenters seized on that as proof that cleanup work matters, while also dunking on managers and joking that even robots need humans to tell them not to be sloppy.

A Thoughtworks CTO let AI coding tools build a 150,000-line app almost entirely on their own, then watched the software equivalent of a junk drawer become a mansion. The biggest jaw-dropper? One part of the app ballooned to 17,155 lines, stuffed with repeated copy-paste work. After cleaning that section up, he found a very modern payoff: the AI needed fewer words to understand the code, which meant lower cost and less waste. In plain English, tidying up the code made the robot helper cheaper and easier to work with.

But the real fireworks were in the comments, where developers basically turned this into group therapy. One crowd yelled, “We’ve BEEN saying this!” and used the post as ammo against managers who treat cleanup work like a luxury spa day. Another camp loved the data but delivered a brutal roast of today’s AI tools: they’re apparently great at making a giant file even bigger, but not so great at realizing it should be split up. That sparked the hottest mini-debate: is this really a story about AI, or just the same old lesson that good tests and good structure save everyone’s sanity?

There was even some dry meme energy. The punchline, as one commenter put it, was basically: “Refactoring reduces token consumption.” Translation: programmers have discovered that cleaning your room also lowers your AI bill. Revolutionary? Maybe not. Extremely satisfying to say in a meeting? Absolutely.

Key Points

  • The article was published on 30 July 2026 as part of Thoughtworks' *Exploring Gen AI* series.
  • Giles Edwards-Alexander built an application to support his work while exploring agentic engineering.
  • The application is described as about 150,000 lines of code, primarily in Rust, with additional TypeScript and Terraform.
  • The code was written entirely by AI agents, mainly Claude Code and partly Cursor, with minimal manual code review by the author.
  • A data access layer in the generated system grew from over 6,000 lines to 17,155 lines and contained repeated HTTP and JSON handling patterns.

Hottest takes

"maybe if those pesky managers read this article" — defrim
"Claude is happy to produce a very large Rust file" — vaylian
"the punchline: 'Refactoring reduces token consumption'" — sltr
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.