Developer Tools

Clean code doesn't boost AI agent pass rates but cuts tokens 8%

Study finds Claude Code uses 34% fewer file revisits on clean repos

Deep Dive

A new paper from Priyansh Trivedi and Olivier Schmitt at SonarSource investigates a practical question: does code cleanliness impact how AI coding agents perform? The team built minimal-pair repositories—identical in architecture, dependencies, and external behavior but differing in static-analysis rule violations and cognitive complexity. They created 33 tasks across six such pairs and ran 660 trials using Anthropic's Claude Code. The result: pass rates were unchanged between clean and messy code, but operational efficiency shifted significantly. Agents working on cleaner code used 7–8% fewer tokens and reduced file revisits by 34%, suggesting structural quality affects an agent's navigational cost without hurting task completion.

The study, submitted to arXiv (2605.20049), positions code cleanliness alongside model choice, harness design, and prompting as a factor that shapes agent behavior. By isolating cleanliness via controlled pairs that can be either degraded or cleaned, the authors offer a reproducible benchmark for future research. Their conclusion: “traditional maintainability principles remain highly relevant in the era of AI-driven development.” For teams deploying autonomous coding agents, this means investing in clean code infrastructure now pays dividends in reduced compute and faster agent iteration—even if success rates don't budge.

Key Points
  • 660 trials with Claude Code across 33 tasks in 6 minimal-pair repos
  • Clean code did not change task pass rates but cut token usage by 7–8%
  • File revisitations dropped 34% on cleaner repositories

Why It Matters

Investing in clean code now reduces AI agent operational costs by up to 34%

📬 Get the top 10 AI stories daily