Agentic AI
Well-Maintained Code Cuts AI Token Costs and Boosts Agent Performance
Research shows that agentic AI gains velocity initially but loses ground as complexity rises—unless code health is kept high, which also reduces processing costs.
InfoQ
Adam Tornhill's work on AI-friendly code at GOTO Copenhagen reveals a paradox: agentic AI agents speed up development by two to three times initially, but those gains evaporate within weeks as code quality deteriorates. The fix lies not in better agents, but in maintaining code health—and the financial payoff is substantial.
The Speed Trap#
Studies of over 1,000 open-source projects showed that velocity surged in the first month when developers switched to agentic workflows. Within two months, however, the initial gains disappeared entirely. The culprit was rapid growth in code complexity—AI systems, when left unchecked, generate code they later struggle to refactor or maintain, creating a form of technical debt spiral.
Developing software with agentic assistance is fundamentally harder than manual coding, according to Tornhill. While agents help teams unblock themselves and reduce coordination overhead, they also tend to operate in what he calls a "self-harm mode," prioritizing task completion over long-term maintainability.
Why Code Health Matters#
The concept of code health encompasses how straightforward it is to read, modify, and maintain a codebase. Research on human developers shows that high-quality code yields striking returns: teams can work up to 10 times faster, defect risk drops by 15 times, and code reviews move twice as quickly.
The economic reality is clear: prototyping accounts for only 5% of software project costs. The remaining 95% occurs after launch, where code quality, maintainability, and architecture dominate both timelines and budgets.
Large language models consistently perform better when working within healthy codebases. Yet the typical codebase scores only 5.15 on health metrics, while AI-friendly code begins at 9.5—a significant gap that blocks enterprise adoption of agentic systems.
Automated Refactoring and Cost Reduction#
Agentic refactoring works best when agents receive objective feedback. Using Claude alone, agents can fix roughly 50% of code health issues in weaker codebases—but performance drops sharply as code improves, with the agent managing only 20% of fixes afterward. AI becomes conservative, making minimal tweaks that don't meaningfully shift code quality.
Integrating an MCP (Model Context Protocol) server that supplies code health metrics changes the equation dramatically. With this feedback loop in place, agents achieve 90–100% fix rates, turning refactoring into a predictable, mechanical process at scale where AI applies codebase-specific patterns intelligently.

