Clean code doesn't boost agent pass rates, but it cuts navigation costs
你不需要为 AI 把代码擦得像样板间,但你需要让它找得到路
A SonarSource paper ran 660 controlled trials with Claude Code + Claude Sonnet 4.6 on clean vs messy code pairs. Pass rates differed by less than 1 percentage point, but clean code cut input tokens by 7.1%, output tokens by 8.5%, and file revisitation by 34%. Multi-module tasks saw input tokens drop 10.7% and revisitation drop 50.8%. HN commenters noted the pairs were auto-generated, not real-world degraded code, and the authors admitted they didn't run full regression tests. The real takeaway: clean code doesn't raise success rates, it lowers the context cost of search, verification, and review. The highest-ROI practices are single sources of truth, removing dead code and stale patterns, explicit module boundaries, and executable lint/test feedback loops for agents.
Why it matters: SonarSource ran 660 controlled trials with Claude Code. Counterintuitive result: clean code didn't improve pass rates, but cut token use by 7-8% and file revisits by 34%. Concrete numbers, clear experimental design, HN discussion as corroboration. HKR all hit. Deduction: tasks...