{"slug": "sonarsource-study-finds-clean-code-cuts-coding-agent-token-use-not-pass-rates", "title": "SonarSource study finds clean code cuts coding-agent token use, not pass rates", "summary": "SonarSource researchers found that cleaner code does not improve Claude Code's task pass rates but reduces token usage by 7-8% and file revisitations by 34%, suggesting code quality affects AI coding agent costs rather than capabilities.", "body_md": "[Priyansh Trivedi](https://arxiv.org/search/cs?searchtype=author&query=Trivedi%2C+P&ref=runtimewire) and [Olivier Schmitt](https://arxiv.org/search/cs?searchtype=author&query=Schmitt%2C+O&ref=runtimewire), researchers affiliated with [SonarSource](https://www.sonarsource.com/company/about/?ref=runtimewire), submitted a [May 19th arXiv preprint](https://arxiv.org/abs/2605.20049?ref=runtimewire) that asks a question already showing up in AI coding budgets: does cleaner code make autonomous coding agents better, or simply cheaper to run?\n\nIn 660 Claude Code trials across 33 tasks and six matched repository pairs, the paper reports no change in task pass rate between cleaner and messier code. Cleaner code did, however, reduce the agent's operating footprint: 7% to 8% fewer tokens and 34% fewer file revisitations.\n\nThat distinction matters. The paper does not say clean code makes Claude Code more capable. It says cleaner code changed the cost and navigation pattern of the same agent attempting the same work.\n\nSonarSource builds code quality tools, so it is not a neutral observer. The authors' affiliation is relevant context when interpreting the results.\n\n### The experiment holds the task fixed and varies the code\n\nMost coding-agent benchmarks measure whether a model completes a task on a fixed repository. Trivedi and Schmitt invert that setup. They created what the paper calls minimal pairs: two versions of a repository that match on architecture, dependencies and external behavior, while differing in static-analysis rule violations and cognitive complexity.\n\nThe pairs were built in both directions. Some clean repositories were degraded by agent pipelines. Some messier repositories were cleaned. The authors then wrote tasks against those pairs and evaluated the agent through hidden tests at the public application surface.\n\nThe arXiv version lists six repository pairs, 33 tasks and 660 trials, all run with Claude Code. That setup isolates one variable software teams can actually control: the shape of the codebase under the agent.\n\n### Pass rate did not change; cost and navigation did\n\nThe paper's headline result: code cleanliness did not change whether Claude Code completed the task.\n\nThe efficiency metrics moved instead. Token use fell on cleaner code by 7% to 8%. File revisitation fell the most, dropping 34% on cleaner code. Frequent revisits are a rough proxy for the agent rechecking prior edits.\n\n### Read it as preprint-scale evidence, not a universal law\n\nThis is early work. [arXiv](https://arxiv.org/abs/2605.20049?ref=runtimewire) is a preprint venue; [Rutgers University Libraries](https://www.libraries.rutgers.edu/databases/arxiv-org?ref=runtimewire) describes arXiv as a preprint archive and notes it does not perform peer review.\n\nScope-wise, the results come from one agent configuration, Claude Code, evaluated through hidden tests across six minimal-pair repositories and 33 tasks. The paper reports operational differences, not higher pass rates. Token counts are a common proxy for cost, but real dollar spend also depends on provider pricing and caching behavior.\n\n### The AI budget angle is stronger than the capability angle\n\nThe paper lands at a useful time for founders deciding how much agentic development to allow inside production repositories. The first spending wave around coding agents has been framed around seats, model subscriptions and productivity claims. The second wave is going to be about the hidden metered work inside every agent trajectory: reading files, selecting context, making edits, running tools, re-reading files and retrying.\n\nA 7% to 8% token reduction on a single task is not enough to justify a rewrite. The sharper implication is that repository maintainability may become part of the unit economics of AI-assisted development once agent work scales across thousands of tasks.\n\nIf an agent keeps thrashing in the same files, the issue may be prompt design, model selection or task scope. This paper adds another suspect: the code may be making the agent pay a navigation tax every time it touches it.", "url": "https://wpnews.pro/news/sonarsource-study-finds-clean-code-cuts-coding-agent-token-use-not-pass-rates", "canonical_source": "https://runtimewire.com/article/sonarsource-clean-code-coding-agent-token-study", "published_at": "2026-07-08 10:06:05+00:00", "updated_at": "2026-07-08 10:15:36.808368+00:00", "lang": "en", "topics": ["artificial-intelligence", "large-language-models", "ai-agents", "developer-tools"], "entities": ["SonarSource", "Claude Code", "Priyansh Trivedi", "Olivier Schmitt", "arXiv"], "alternates": {"html": "https://wpnews.pro/news/sonarsource-study-finds-clean-code-cuts-coding-agent-token-use-not-pass-rates", "markdown": "https://wpnews.pro/news/sonarsource-study-finds-clean-code-cuts-coding-agent-token-use-not-pass-rates.md", "text": "https://wpnews.pro/news/sonarsource-study-finds-clean-code-cuts-coding-agent-token-use-not-pass-rates.txt", "jsonld": "https://wpnews.pro/news/sonarsource-study-finds-clean-code-cuts-coding-agent-token-use-not-pass-rates.jsonld"}}