arXiv:2609.01236cs.SESep 2026

Manuscript Offprint

arXiv:2609.01236

Continuous Autonomous Refactoring: A Research Roadmap for AI-Driven Code Quality Maintenance

Xin Sun, Daniel Ståhl, Kristian Sandahl, Christoph Kessler

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Xin Sun, Daniel Ståhl, Kristian Sandahl, Christoph Kessler

Department of Computer and Information Science

Linköping University, Sweden

{xin.sun, daniel.stahl, kristian.sandahl, christoph.kessler}@liu.se

Abstract—Large language models have shown promising capabilities in code refactoring, but existing approaches remain limited to method-level tasks. In this paper, we envision LLM-based refactoring as a continuous component of software maintenance rather than a tool invoked only for occasional manual refactoring. Under this vision, AI agents continuously monitor, evaluate, and improve codebases against explicit and evolving notions of software quality. We present a roadmap organized around five dimensions: the multi-objective optimization problem, quality definition and evaluation, multi-timescale integration of heterogeneous signals, architecture and design pattern, and trust in autonomous refactoring. We further identify integration into continuous delivery pipelines and cost considerations as cross-cutting concerns. For each dimension, we analyze the underlying challenges and pose open research questions. These dimensions define a research agenda for advancing autonomous refactoring from isolated code improvements to system-level quality maintenance.

Index Terms—autonomous refactoring, software quality, large language models, continuous delivery

I. INTRODUCTION

The emergence of large language models (LLMs) has brought substantial changes to software engineering. These models demonstrate strong capabilities in generating and modifying source code from natural language prompts [1]. Such capabilities lead to a growing interest in using LLMs not only to implement new features but also to improve existing codebases through code refactoring, aiming to improve code quality and manage technical debt [2].

Recent work suggests that LLMs can effectively perform code refactoring on relatively straightforward tasks, reducing local complexity, repairing specific defects, and improving performance efficiency while preserving functional behavior [3]. However, in more complex settings, LLM-based refactoring often encounters failures. At the repository level, generated changes may unintentionally violate functional correctness or cause substantial degradation in certain quality dimensions while improving others [4].

Consider a team maintaining a large-scale enterprise system spanning several million lines of code across hundreds of modules. Static analyzers flag thousands of code smells, but the team knows many are intentional: a deeply nested function preserves a real-time latency constraint, and a duplicated validation block remains in two services because extracting a shared library previously caused integration failures. An LLM-based tool might simplify a single method in isolation, but no existing system can determine which warnings should be addressed, balance a cross-module refactoring against an upcoming release deadline, or recognize that a redundant adapter layer preserves backward compatibility with an external API. This gap highlights the need to reassess how close we are to system-level automated software refactoring and what research methods are required to achieve it.

In this paper, rather than asking how to ensure quality in AI-generated code, we pose a different question: How could AI agents continuously and autonomously maintain code quality against an explicit, evolving specification of “good”? This reframing shifts quality from a constraint on code generation to a primary and ongoing objective. In this view, continuous autonomous refactoring becomes the default mode of software maintenance. AI agents monitor, evaluate, and improve codebases against evolving quality criteria, instead of a one-time intervention applied to isolated code snippets. This paradigm shift raises research questions that go beyond current capabilities and form the basis of the roadmap we present in this paper.

We present a research roadmap toward realizing the vision of continuous autonomous refactoring, organized around five primary dimensions: the multi-objective optimization problem, the problem of definition and evaluation, multi-timescale integration of heterogeneous signals, architecture and design pattern challenges, and the trust problem. Beyond these core dimensions, we further discuss integration into continuous delivery pipelines as a cross-cutting concern and cost considerations for industry adoption as a practical concern for industry adoption. Each dimension addresses a distinct group of challenges that must be resolved before autonomous refactoring can scale beyond isolated tasks. Together, they define the research questions that can be taken by the community to make this vision a reality.

References (34)