Clean Code Won't Help Your AI Agent Pass — But It'll Burn Fewer Tokens
Original source
Does code cleanliness affect coding agents? A controlled minimal-pair study
Hacker News →A controlled study tested whether code cleanliness changes how well autonomous coding agents perform, using a minimal-pair design: repositories matched on architecture, dependencies, and external behavior but differing only in static-analysis violations and cognitive complexity. The researchers built pairs in both directions—degrading clean repos and cleaning messy ones—then defined 33 tasks across six pairs, graded through hidden tests at each application’s public interface. Running 660 trials with Claude Code, they found cleanliness had no effect on the agent’s pass rate.
What cleanliness did change was cost and efficiency. On cleaner code, agents consumed 7–8% fewer tokens and revisited files 34% less often. In other words, messy code doesn’t stop an agent from getting the job done, but it makes the agent wander more and spend more compute to arrive at the same result.
The takeaway is that traditional maintainability principles still matter in AI-driven development, just not where you’d expect. Rather than gating correctness, code quality shapes the operational footprint—the computational bill and navigational overhead of the agent. The authors position cleanliness alongside model choice, harness design, and prompting as a lever that materially affects agent behavior, which has practical implications for teams paying per token at scale.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.