Refactoring with LLMs: Bridging Human Expertise and Machine Understanding
Not on the map. Why?
Abstract (arXiv)
Code refactoring is a fundamental software engineering practice aimed at improving code quality and maintainability. Despite its importance, developers often neglect refactoring due to the significant time, effort, and resources it requires, as well as the lack of immediate functional rewards. Although several automated refactoring tools have been proposed, they remain limited in supporting a broad spectrum of refactoring types. In this study, we explore whether instruction strategies inspired by human best-practice guidelines can enhance the ability of Large Language Models (LLMs) to perform diverse refactoring tasks automatically. Leveraging the instruction-following and code comprehension capabilities of state-of-the-art LLMs (e.g., GPT-mini and DeepSeek-V3), we draw on Martin Fowler's refactoring guidelines to design multiple instruction strategies that encode motivations, procedural steps, and transformation objectives for 61 well-known refactoring types. We evaluate these strategies on benchmark examples and real-world code snippets from GitHub projects. Our results show that instruction designs grounded in Fowler's guidelines enable LLMs to successfully perform all benchmark refactoring types and preserve program semantics in real-world settings, an essential criterion for effective refactoring. Moreover, while descriptive instructions are more interpretable to humans, our results show that rule-based instructions often lead to better performance in specific scenarios. Interestingly, allowing models to focus on the overall goal of refactoring, rather than prescribing a fixed transformation type, can yield even greater improvements in code quality.
Key facts. Cited by 2 papers in the map (data through 14 Oct 2026). Builds on 27 of its 58 references that are in the map. First posted on arXiv 4 Oct 2025.
Builds on
27 of 58 references.
References · 27
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
- 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,626
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2024A Survey on LLM-as-a-Judgecited by 1,423
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 885
- 2022Quantifying Memorization Across Neural Language Modelscited by 763
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
- 2019Generalizing from a Few Examples: A Survey on Few-Shot Learningcited by 463
- 2024Hallucination is Inevitable: An Innate Limitation of Large Language Modelscited by 332
- 2024CodeJudge-Eval: Can Large Language Models be Good Judges in Code Understanding?cited by 30
15 more
- 2023Refactoring Programs Using Large Language Models with Few-Shot Examplescited by 28
- 2024Fine-Tuning and Prompt Engineering for Large Language Models-based Code Review Automationcited by 23
- 2024An Empirical Study on the Code Refactoring Capability of Large Language Modelscited by 19
- 2024An Empirical Study on the Potential of LLMs in Automated Software Refactoringcited by 10
- 2022CodePAD: Sequence-based Code Generation with Pushdown Automatoncited by 7
- 2024Knowledge-Aware Code Generation with Large Language Modelscited by 6
- 2024Together We Go Further: LLMs and IDE Static Analysis for Extract Method Refactoringcited by 5
- 2023RefBERT: A Two-Stage Pre-trained Framework for Automatic Rename Refactoringcited by 4
- 2023COMEX: A Tool for Generating Customized Source Code Representationscited by 3
- 2015JExtract: An Eclipse Plug-in for Recommending Automated Extract Method Refactoringscited by 2
- 2024Refactoring-aware Block Tracking in Commit Historycited by 2
- 2015An Empirical Evaluation of Impact of Refactoring On Internal and External Measures of Code Qualitycited by 1
- 2020Refactoring Graphs: Assessing Refactoring over Timecited by 1
- 2023Opti Code Pro: A Heuristic Search-based Approach to Code Refactoringcited by 1
- 2025Evaluating the Effectiveness of Small Language Models in Detecting Refactoring Bugscited by 1
Built on by
Citing papers per year: 2026: 2.
2 papers.