Legacy software systems form the backbone of modern digital infrastructure, yet their long-term maintainability is threatened by outdated language constructs, monolithic structure, and poor documentation. While recent Large Language Models (LLMs) demonstrate strong capabilities in code generation and transformation, their application to automated refactoring is limited by semantic drift and lack of formal verification. This paper presents Refactor Flow, an AI-assisted hybrid refactoring framework that integrates Abstract Syntax Tree (AST)–based structural validation with LLM-driven semantic modernization to enable behaviour-preserving code translation and refactoring. The system targets legacy Python codebases and supports modernization, modularization, and cross-language translation while enforcing syntactic and semantic correctness through deterministic verification layers. Through controlled experiments on legacy repositories, Refactor Flow achieves high semantic preservation, improved structural quality, and superior test pass rates compared to IDE refactorers, rule-based systems, and LLM-only baselines. The results demonstrate that hybrid symbolic–probabilistic refactoring offers a viable path toward safe, scalable legacy code modernization.
Aditya Bagari (Sun,) studied this question.
Synapse has enriched 5 closely related papers on similar clinical questions. Consider them for comparative context: