Skip to content

Clean code may not make coding agents pass more, but it makes them wander less

Original: Does code cleanliness affect coding agents? A controlled minimal-pair study View original →

Read in other languages: 한국어日本語
LLM Jul 6, 2026 By Insights AI (HN) 1 min read 2 views Source

A controlled study from SonarSource asks a practical question for teams using coding agents: does code cleanliness change how well an agent works? The headline result is deliberately narrow. Across 33 tasks and 660 Claude Code trials, cleaner code did not change the final pass rate. It did, however, change the operational footprint: agents used 7-8% fewer tokens and revisited files 34% less often when working in cleaner repositories.

The study uses minimal pairs rather than comparing unrelated projects. Each pair is matched on architecture, dependencies, and external behavior, while differing in static-analysis violations and cognitive complexity. Some pairs were produced by degrading clean repositories; others by cleaning messy ones. That setup tries to isolate repository quality from the agent’s base capability.

The Hacker News discussion focused on what the experiment can and cannot prove. Commenters questioned whether hidden task tests are enough if the study does not also check for unrelated regressions in the rest of the repository. That critique matters: the result should not be read as “clean code has no effect.” A more careful reading is that pass rate stayed flat under this protocol, while the cost and navigation pattern changed.

For engineering teams, that distinction is useful. Linters, dead-code removal, lower cognitive complexity, and clearer structure may not turn a weak agent into a strong one. They can still reduce the number of tokens burned and the amount of backtracking required to finish a task. In agent-heavy development, maintainability becomes part of runtime economics, not just a human preference.

Share: Long

Related Articles