cd /news/artificial-intelligence/sonarsource-study-finds-clean-code-c… · home topics artificial-intelligence article
[ARTICLE · art-50893] src=runtimewire.com ↗ pub= topic=artificial-intelligence verified=true sentiment=· neutral

SonarSource study finds clean code cuts coding-agent token use, not pass rates

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.

read3 min views1 publishedJul 8, 2026
SonarSource study finds clean code cuts coding-agent token use, not pass rates
Image: Runtimewire (auto-discovered)

Priyansh Trivedi and Olivier Schmitt, researchers affiliated with SonarSource, submitted a May 19th arXiv preprint that asks a question already showing up in AI coding budgets: does cleaner code make autonomous coding agents better, or simply cheaper to run?

In 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.

That 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.

SonarSource builds code quality tools, so it is not a neutral observer. The authors' affiliation is relevant context when interpreting the results.

The experiment holds the task fixed and varies the code

Most 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.

The 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.

The 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.

Pass rate did not change; cost and navigation did

The paper's headline result: code cleanliness did not change whether Claude Code completed the task.

The 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.

Read it as preprint-scale evidence, not a universal law

This is early work. arXiv is a preprint venue; Rutgers University Libraries describes arXiv as a preprint archive and notes it does not perform peer review.

Scope-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.

The AI budget angle is stronger than the capability angle

The 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.

A 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.

If 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.

── more in #artificial-intelligence 4 stories · sorted by recency
── more on @sonarsource 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/sonarsource-study-fi…] indexed:0 read:3min 2026-07-08 ·