Does code cleanliness affect coding agents? A controlled minimal-pair study

166 points · 82 comments on HN · read original →

Points and comments are a snapshot, not live.

Code cleanliness does not affect agent pass rates but reduces token use by 7-8% and revisitations by 34%.

The study introduces an evaluation protocol using minimal pairs of repositories that match on architecture and behavior but differ on static-analysis rule violations and cognitive complexity. Pairs were constructed by agent pipelines that degrade clean code or clean messy code. Across 660 trials with Claude Code and 33 tasks, code cleanliness did not change the agent's pass rate but substantially altered operational footprint: agents on cleaner code used 7-8% fewer tokens and reduced file revisitations by 34%.

What commenters are saying

Commenters split into two camps: those who find code cleanliness noticeably affects agent performance in practice, and those who critique the study's methodology. Critics question the validity of AI-cleaned repos and note that deterministic linters already handle many hygiene issues. One commenter argues that agents mirror their context: messy codebases degrade outputs as much as for humans. Another suggests giving agents deterministic guardrails (linters, CI hooks) improves results, while others note linters miss deeper architectural problems.