# From Cosmetic to Structural: A Paired Experiment on Metric-Guided Agentic Refactoring

DevFeed: [From Cosmetic to Structural: A Paired Experiment on Metric-Guided Agentic Refactoring](<https://devfeed.tech/articles/from-cosmetic-to-structural-a-paired-experiment-on-metric-guided-agentic-refactoring-101739.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2610.33343>)

Author: Nadim Hagatulah, Markus Borg, Emma S\\"oderberg

Published: 2026-10-27T04:00:00Z

Content type: article

Language: en

Sources: [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [Tech Debt](<https://devfeed.tech/topics/tech-debt.md>), [Static code analysis](<https://devfeed.tech/topics/static-code-analysis.md>), [AI in frontend development](<https://devfeed.tech/topics/ai-in-frontend-development.md>)

Tags: [abstract](<https://devfeed.tech/tags/abstract.md>), [agent](<https://devfeed.tech/tags/agent.md>), [agentic](<https://devfeed.tech/tags/agentic.md>), [agents](<https://devfeed.tech/tags/agents.md>), [ai](<https://devfeed.tech/tags/ai.md>), [ai-teammates](<https://devfeed.tech/tags/ai-teammates.md>), [analysis](<https://devfeed.tech/tags/analysis.md>), [arxiv](<https://devfeed.tech/tags/arxiv.md>), [better](<https://devfeed.tech/tags/better.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [code](<https://devfeed.tech/tags/code.md>), [code-quality](<https://devfeed.tech/tags/code-quality.md>), [code-smell](<https://devfeed.tech/tags/code-smell.md>), [coding](<https://devfeed.tech/tags/coding.md>), [coding-agents](<https://devfeed.tech/tags/coding-agents.md>), [compare](<https://devfeed.tech/tags/compare.md>), [competitive-programming](<https://devfeed.tech/tags/competitive-programming.md>), [cs-se](<https://devfeed.tech/tags/cs-se.md>), [experiment](<https://devfeed.tech/tags/experiment.md>), [metric](<https://devfeed.tech/tags/metric.md>), [refactoring](<https://devfeed.tech/tags/refactoring.md>)

## AI overview

In a paired experiment on 24,620 single-file C++, Java, and Python solutions, giving the open-source agent gptme static-analysis feedback through CodeScene's MCP server shifted refactoring from cosmetic edits toward structural changes. Guided runs increased effective refactorings by 21-26 percentage points, but outcomes depended on initial CodeHealth: below language-specific break-even scores of 4.9-7.1, the guided changes increasingly risked regression. Guidance also shifted failures toward logical test failures, introduced new coupling smells, and used about 3-5 times as many tokens and twice as many interaction turns. The findings are limited to the described benchmark and agent setup.

## Source excerpt

arXiv:2610.33343v1 Announce Type: new Abstract: The role of coding agents is expanding beyond writing new code toward maintaining existing systems as AI teammates. Yet recent studies show that agent refactorings favor superficial, consistency-oriented edits over structural transformations needed to resolve Technical Debt (TD). We investigate if explicit static-analysis feedback closes this gap. Through the CodeScene MCP server, we give an open-source agent (gptme) access to code smell reports and CodeHealth (CH) scores (1--10, higher is better), and compare guided against unguided refactorings in a paired experiment covering $24{,}620$ single-file competitive programming solutions in C++, Java, and Python. We find that guidance shifts the agent from performing cosmetic edits toward structural operations, raising the rate of effective refactorings by $21$--$26$ percentage points. The benefit depends on initial code quality, with language-dependent break-even points at CH $4.9$--$7.1$, below where the structural transformations pushed by guidance increasingly risk regression, indicating where the agent needs more support to refactor. Guided runs also shift the failure profile toward logical test failures, introduce new coupling smells, and consume $\sim$$3$--$5\times$ more tokens over $\sim$$2\times$ as many interaction turns. Our results indicate that AI teammates can benefit from similar static-analysis feedback that human developers already use, enabling structural transformations toward more effective TD remediation, at a higher token cost and more interaction turns.