Radar · 06/07/2026 · happened on 05/07/2026 · research

Clean code really does help agents (controlled study)

What happened. Priyansh Trivedi and Olivier Schmitt (SonarSource) published a controlled study on a practical question: does clean code change how an agent works? They built six pairs of identical repositories in architecture and external behavior, but different in structural quality: one clean, one full of static analysis violations and high cognitive complexity. They ran Claude Code on 33 tasks across 660 trials. Result: success rate stays the same, but agents working on clean code use 7-8% fewer tokens and reopen 34% fewer files.

Why it matters to you. When you pass a codebase to an agent, code quality doesn’t determine whether it succeeds, but it determines how much it costs and how long it takes. If you refactor first, the agent navigates better, consumes less, and leaves you more room within the context limit. It works the other way too: a messy project won’t stop it, but it costs you more each time. The lesson is that maintainability principles (clear names, low complexity, consistency) still matter, even with an agent writing for you.

Where to look. The study is on arXiv with the full protocol. If you want to apply it to your code, what you need is a linter or static analyzer that measures cognitive complexity and style violations — the paper uses SonarQube. Before refactoring for an agent though, measure first: if the project is already clean, you gain nothing.

Type to search across course, playbooks, skills, papers…