mlsanityData to 14 Oct 2026

What Were You Thinking? An LLM-Driven Large-Scale Study of Refactoring Motivations in Open-Source Projects

arXiv 2509.07763 ↗First posted 9 Sep 2025cs.SE cs.AI cs.PLcited by 4

Not on the map. Why?

Abstract (arXiv)

Context. Code refactoring improves software quality without changing external behavior. Despite its advantages, its benefits are hindered by the considerable cost of time, resources, and continuous effort it demands. Aim. Understanding why developers refactor, and which metrics capture these motivations, may support wider and more effective use of refactoring in practice. Method. We performed a large-scale empirical study to analyze developers refactoring activity, leveraging Large Language Models (LLMs) to identify underlying motivations from version control data, comparing our findings with previous motivations reported in the literature. Results. LLMs matched human judgment in 80% of cases, but aligned with literature-based motivations in only 47%. They enriched 22% of motivations with more detailed rationale, often highlighting readability, clarity, and structural improvements. Most motivations were pragmatic, focused on simplification and maintainability. While metrics related to developer experience and code readability ranked highest, their correlation with motivation categories was weak. Conclusions. We conclude that LLMs effectively capture surface-level motivations but struggle with architectural reasoning. Their value lies in providing localized explanations, which, when combined with software metrics, can form hybrid approaches. Such integration offers a promising path toward prioritizing refactoring more systematically and balancing short-term improvements with long-term architectural goals.

Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Builds on 22 of its 84 references that are in the map. First posted on arXiv 9 Sep 2025.

Builds on

22 of 84 references.

References · 22

  1. 2016XGBoost: A Scalable Tree Boosting Systemcited by 5,166
  2. 2022Large Language Models are Zero-Shot Reasonerscited by 4,374
  3. 2020A Review of Generalized Zero-Shot Learning Methodscited by 159
  4. 2024Marco-o1: Towards Open Reasoning Models for Open-Ended Solutionscited by 144
  5. 2024Evaluation of OpenAI o1: Opportunities and Challenges of AGIcited by 127
  6. 2024Using AI-Based Coding Assistants in Practice: State of Affairs, Perceptions, and Ways Forwardcited by 45
  7. 2023Refactoring Programs Using Large Language Models with Few-Shot Examplescited by 28
  8. 2020Code Smells and Refactoring: A Tertiary Systematic Review of Challenges and Observationscited by 18
  9. 2022The impact of feature importance methods on the interpretation of defect classifierscited by 12
  10. 2016Why We Refactor? Confessions of GitHub Contributorscited by 10
  11. 2024An Empirical Study on the Potential of LLMs in Automated Software Refactoringcited by 10
  12. 2021A Critical Comparison on Six Static Analysis Tools: Detection, Agreement, and Precisioncited by 9
10 more
  1. 2024Beyond Words: On Large Language Models Actionability in Mission-Critical Risk Analysiscited by 9
  2. 2024On Large Language Models in Mission-Critical IT Governance: Are We Ready Yet?cited by 9
  3. 2024EM-Assist: Safe Automated ExtractMethod Refactoring with LLMscited by 8
  4. 2018An Insight into the Pull Requests of GitHubcited by 4
  5. 2020Recommendation of Move Method Refactoring Using Path-Based Representation of Codecited by 4
  6. 2024Evaluating Time-Dependent Methods and Seasonal Effects in Code Technical Debt Predictioncited by 3
  7. 2024A Novel Refactoring and Semantic Aware Abstract Syntax Tree Differencing Tool and a Benchmark for Evaluating the Accuracy of Diff Toolscited by 2
  8. 2025A Call for Critically Rethinking and Reforming Data Analysis in Empirical Software Engineeringcited by 2
  9. 2021Why Developers Refactor Source Code: A Mining-based Studycited by 1
  10. 2021How Do I Refactor This? An Empirical Study on Refactoring Trends and Topics in Stack Overflowcited by 1

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 4.

4 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026CodeTaste: Can LLMs Generate Human-Level Code Refactorings?
  2. 2024An Empirical Study on the Code Refactoring Capability of Large Language Models
  3. 2026"Refactoring Runaway": Understanding and Mitigating Tangled Refactorings in Coding Agents for Issue Resolution
  4. 2026RefactorAssist: Agentic Refinement for Reliable Code Refactoring
  5. 2025MANTRA: Enhancing Automated Method-Level Refactoring with Contextual RAG and Multi-Agent LLM Collaboration
  6. 2025RefAgent: A Multi-agent LLM-based Framework for Automatic Software Refactoring
  7. 2026REFINE: A Multi-Agent LLM Approach for Evidence-Guided Code Refactoring
  8. 2026Leveraging Language Models to Discover Evidence-Based Actions for OSS Sustainability