Agentic Code Maintainability

Agentic code maintainability is the idea that code quality should be evaluated not only by whether humans can read and modify it, but also by how efficiently coding agents can navigate, edit, verify, and stop revisiting it. The SonarSource minimal-pair study is useful because it holds the agent and tasks fixed while changing the codebase: six behaviorally equivalent clean/messy repository pairs, 33 public-surface tasks, and 660 Claude Code trials on Claude Sonnet 4.6.source: code-cleanliness-coding-agents-2026.md

The headline result is asymmetric: cleaner code did not improve task success, but it reduced the agent's operational footprint. Pass rate was effectively unchanged (91.3% on cleaner variants vs. 92.1% on messier variants), while cleaner code used 7.1% fewer input tokens, 8.5% fewer output tokens, 11.1% fewer reasoning characters, and 34% fewer file revisitations. This makes maintainability economically relevant even when benchmark pass rate is saturated: the agent may still get the answer, but it spends less context, fewer turns, and less navigation churn doing so.source: code-cleanliness-coding-agents-2026.md

The strongest behavioral signal was not simply file size or fewer files read. On cleaner code, agents often read a somewhat wider set of files and then committed to changes; on messier code, they more often returned to files already edited. In agent terms, clean code seems to reduce backtracking and local uncertainty rather than magically increase capability.source: code-cleanliness-coding-agents-2026.md

The effect depends on task shape. Multi-module tasks showed the clearest savings: input tokens fell 10.7% and file revisitations fell 50.8% on cleaner variants. Cognitive-hotspot tasks were more ambiguous: extracting a god method into helpers can make each local piece simpler while increasing the number of locations an agent must inspect. That connects this page to dry-principle and loop-dependent-software: refactoring for agents is not automatically "more abstraction"; it is better navigability under the actual task distribution.source: code-cleanliness-coding-agents-2026.md

Methodologically, the paper is a useful complement to test-time-compute-evaluations. Traditional coding-agent evaluations mostly ask whether the final patch passes tests. This benchmark records footprint metrics as first-class outcomes: input/output tokens, reasoning characters, conversation turns, time before first edit, files read, file revisits, and lines edited. For harness-engineering, that suggests maintainability belongs inside the agent's cost model, not only inside human code-review norms.source: code-cleanliness-coding-agents-2026.md

Limitations matter. The study uses one main configuration: Claude Code with Claude Sonnet 4.6, on Java/Python codebases, with tasks authored by the authors and graded only by their hidden tests. It does not test whether agents produce cleaner code when starting from cleaner code, whether savings compound over long project histories, or whether the same effects transfer to GPT/Gemini-style agents and other harnesses. Still, the cleanest takeaway for ai-assisted-software-development is pragmatic: clean code may not make agents more correct in the short run, but it can make them cheaper, less loopy, and easier to supervise.source: code-cleanliness-coding-agents-2026.md

Related pages: ai-assisted-software-development, harness-engineering, test-time-compute-evaluations, loop-dependent-software, dry-principle, modern-engineering-values.

Resources