CodeTaste: Can LLMs Generate Human-Level Code Refactorings?

TL;DR

CodeTaste benchmark evaluates LLMs' ability to perform human-like code refactorings, combining correctness and preference alignment, revealing current models' gaps.

cs.SE 🔴 Advanced 2026-03-04 53 views
Alex Thillen Niels Mündler Veselin Raychev Martin Vechev
AI Software Engineering Code Refactoring Large Models Benchmark

Key Findings

Methodology

This work constructs CodeTaste by mining large-scale multi-file open-source refactoring data from GitHub, integrating static analysis rules and test suites to evaluate model performance. It employs a propose-then-implement pipeline, combining static rule matching and dataflow reasoning to measure detailed and preference-based refactoring. Two tracks—detailed instructions and open preference—test models, revealing high performance (~70%) in detailed tasks but less than 8% in autonomous preference detection.

Key Results

  • Models achieve up to 69.6% alignment in detailed instruction tasks, with over 95% test pass rate, indicating strong functional correctness. In contrast, in autonomous preference tasks, average alignment is below 8%, highlighting a significant gap in understanding human developer preferences.
  • On complex multi-file tasks, models modify an average of 91.52 files and 2605 lines, demonstrating the benchmark's challenging nature. Static analysis rules cover diverse code patterns, validating semantic understanding.
  • Introducing multi-round inference and preference-guided selection improves alignment, showing the importance of iterative reasoning and preference signals for better model performance.

Significance

This study fills a critical gap in evaluating AI's capability for code refactoring, especially in preference understanding and long-term maintainability. It provides quantitative metrics for aligning AI outputs with human developer preferences, advancing automated code maintenance, debt reduction, and AI-assisted development. The benchmark offers a foundation for future research aiming at more autonomous and preference-aware code engineering tools.

Technical Contribution

We propose CodeTaste, combining static analysis rules and dataflow reasoning to quantify preference alignment. The propose-then-implement framework, coupled with preference signals, significantly enhances the model's ability to produce human-like refactorings. The benchmark supports large-scale, multi-language, multi-file evaluation, pushing forward the application of LLMs in complex software engineering tasks.

Novelty

This is the first comprehensive benchmark covering multi-file, multi-language refactoring with explicit preference alignment metrics. Unlike existing single-file or syntactic benchmarks, it emphasizes semantic understanding and preference matching, marking a step towards more intelligent, context-aware AI code assistants.

Limitations

  • Models still struggle with autonomous preference detection due to limited expressiveness of static rules and reasoning depth, especially in complex semantic scenarios.
  • Evaluation is limited to open-source repositories; industrial applicability and robustness remain untested.
  • Static analysis rule creation relies on manual effort, which could introduce biases; automatic rule learning is needed for scalability.

Future Work

Future directions include integrating dynamic analysis and semantic understanding, enabling models to autonomously discover developer preferences. Exploring multi-turn interactions and reinforcement learning could further improve preference alignment. Expanding the benchmark to industrial datasets and multi-modal signals will facilitate real-world deployment.

AI Executive Summary

Artificial intelligence has rapidly infiltrated software engineering, transforming code generation, repair, and refactoring. Despite impressive advances, current models face challenges in understanding long-term preferences and maintaining code quality over iterations. Existing benchmarks focus mainly on syntactic correctness or single-file tasks, leaving a gap in evaluating models' ability to autonomously recognize and align with human developer preferences in complex, multi-file scenarios.

This paper introduces CodeTaste, a novel benchmark designed to evaluate large language models' capability to perform human-like code refactoring. By mining extensive multi-file refactoring data from GitHub repositories, the authors create a challenging evaluation environment that combines static analysis rules with dataflow reasoning to assess semantic correctness and preference alignment. The benchmark features two evaluation tracks: one with detailed instructions, where models are tasked with implementing specific refactorings, and another with vague, preference-based prompts, testing models' ability to infer developer intent.

Results reveal that models excel in detailed, well-specified tasks, achieving up to 70% alignment with human refactorings. However, in autonomous preference detection, the best models only reach below 8% alignment, exposing a significant gap. To address this, the authors propose a propose-then-implement framework that leverages multiple candidate plans and preference signals to select the best fit, substantially improving alignment scores.

This work advances the understanding of AI's capabilities in complex software engineering tasks, emphasizing the importance of preference modeling and multi-round reasoning. It provides a comprehensive evaluation platform that can guide future development of more autonomous, preference-aware coding agents. Despite these advances, challenges remain in scaling automatic rule generation, improving semantic understanding, and validating industrial robustness. The authors suggest integrating dynamic analysis and reinforcement learning as promising future directions, aiming to bring AI-assisted software maintenance closer to practical deployment.

Deep Analysis

Background

The integration of AI into software engineering has evolved from simple code completion to complex automated repair and refactoring tools. Early models like CodeBERT and GPT-3 demonstrated capabilities in code understanding and generation, primarily in single-file, task-specific contexts. Recent large models such as Codex and GPT-4 have shown potential in multi-task scenarios, but their evaluation remains limited to syntactic correctness or small-scale benchmarks. Existing benchmarks like CodeRefactor and SWE-Refactor focus on single-file edits, lacking the complexity of real-world, multi-file, multi-language projects. As software systems grow in complexity, the need for models that can understand and perform semantic, preference-aligned refactorings across large codebases becomes critical. This work addresses this gap by creating a comprehensive, multi-file, multi-language benchmark that evaluates models' ability to recognize and implement developer preferences in complex refactoring tasks.

Core Problem

Current AI models excel at generating syntactically correct code but struggle with autonomous recognition of human developer preferences, especially in large, multi-file projects. Existing benchmarks do not adequately measure a model’s ability to infer and align with developer intent, limiting their practical utility. The core challenge lies in designing evaluation metrics and datasets that reflect real-world complexity, including semantic understanding, multi-file coherence, and preference modeling. Without such benchmarks, progress in creating truly autonomous, preference-aware coding agents remains constrained. Addressing this requires integrating static analysis, dataflow reasoning, and preference signals into a unified evaluation framework.

Innovation

This paper introduces CodeTaste, a benchmark that combines large-scale open-source refactoring data with static analysis rules and dataflow reasoning to evaluate models' semantic understanding and preference alignment. Key innovations include:

1) Mining multi-file refactoring instances from GitHub, capturing real developer behavior.

2) Generating detailed task descriptions and static rules to evaluate semantic correctness.

3) Implementing a propose-then-implement framework that leverages multiple candidate plans and preference signals.

4) Supporting multi-language, multi-file, large-scale evaluation, surpassing prior single-file, syntactic benchmarks.

These innovations enable a more realistic assessment of models' capabilities in complex software engineering tasks, emphasizing preference understanding and long-term maintainability.

Methodology

  • �� Data collection: Mining 100 high-quality multi-file refactoring commits from GitHub repositories across six languages.
  • �� Task generation: Using LLMs to create detailed refactoring instructions, including rationale and target patterns.
  • �� Environment setup: Building reproducible, containerized environments with test suites and static analysis rules.
  • �� Static rule creation: Automatically generating additive and reductive rules to capture desired and undesired patterns.
  • �� Model inference: Running models within environments, generating patches via propose-then-implement, with multi-round reasoning and preference signals.
  • �� Evaluation: Validating correctness via test suites and measuring preference alignment through static rule matching.
  • �� Metrics: Alignment scores, functional correctness, rule coverage, and file/line modifications.
  • �� Ablation studies: Testing the impact of multi-round inference, preference signals, and static rules on performance.

Experiments

The evaluation involved five models, including GPT-5.2, Claude 4.5, and Qwen3, tested on 100 multi-file refactoring tasks. Metrics included test pass rate (>95%), preference alignment (up to 70%), and code modifications (average 91 files, 2605 lines). Experiments demonstrated that multi-round, preference-guided inference significantly improved alignment, with the best models reaching 20%+ in autonomous preference tasks. Cross-language performance was consistent, validating the benchmark's robustness. Ablation studies confirmed the importance of preference signals and iterative reasoning in enhancing model performance.

Results

Models achieved up to 69.6% alignment in detailed instruction tasks, with high functional correctness. In autonomous preference tasks, alignment was below 8%, but multi-round inference and preference signals raised this to over 20%. Static analysis rules covered diverse semantic patterns, validating models' semantic understanding. The proposed framework effectively bridges the gap between detailed instructions and autonomous preference detection, highlighting the importance of iterative reasoning and preference modeling.

Applications

The benchmark can guide development of AI tools for automated code maintenance, refactoring, and debt reduction. It supports training models to autonomously recognize developer preferences, enabling more intelligent code suggestions and long-term software evolution. Industrial applications include automated refactoring in CI/CD pipelines, reducing manual effort and improving code quality. The framework also facilitates research on preference modeling, multi-task learning, and semantic understanding in large models.

Limitations & Outlook

Models still underperform in autonomous preference detection due to limited semantic reasoning and static rule expressiveness. Evaluation mainly uses open-source repositories, limiting industrial robustness validation. Static rules require manual creation, which may introduce biases. Future work should focus on integrating dynamic analysis, automatic rule learning, and real-world industrial datasets to improve robustness and applicability.

Plain Language Accessible to non-experts

想象你在厨房做饭,你有一份食谱(指令),可以严格按照步骤做,也可以只知道大概的方向,自己发挥。模型就像厨师,有时候能按食谱做出好菜,但如果只知道大致想法,它可能做出不太符合厨师长偏好的菜。这个研究就像教厨师理解厨师长的偏好,不仅按食谱做,还能自主发现哪些做法更受欢迎。通过观察厨师的表现,厨师长可以教会厨师更懂味道的做法。最终,厨师能自己判断怎么做出更好吃的菜,模型也是一样,研究希望它能理解偏好,变得更聪明,做出更符合人们想法的代码。

ELI14 Explained like you're 14

想象你在学校的厨房帮忙做饭。有时候你会严格按照食谱做菜,结果还不错,但如果你只知道大概的方向,可能做出来的菜不太合大家的口味。这就像模型写代码,有时候能按指令做得很好,但不知道怎么自己发现哪些改进更受人喜欢。这个研究就像教你理解厨师长的偏好,让你不仅能按食谱做,还能自己发现更好吃的做法。通过反复练习和观察,你会变得更懂得大家喜欢什么,做出更棒的菜。模型也是一样,研究希望它能自主理解偏好,变得更聪明,更贴近人类开发者的想法。

Abstract

LLM coding agents can generate working code, but their solutions often accumulate complexity, duplication, and architectural debt. Human developers address such issues through refactoring: behavior-preserving program transformations that improve structure and maintainability. We investigate whether agents (i) can execute refactorings reliably and (ii) identify the refactorings that human developers actually chose in real codebases. To this end, we construct CodeTaste, a benchmark mined from large multi-file open-source refactorings. To score solutions, we combine repository test suites that measure functional correctness with tailored static checks that verify removal of undesired and introduction of desired code patterns using dataflow reasoning. Our results show a clear gap: agents perform well at implementing refactorings that are specified in detail, but often fail to discover the human refactoring choices when given a focus area for changes. A propose-then-implement decomposition improves alignment, and selecting the best-aligned proposal before implementation can yield further gains. CodeTaste provides an evaluation target and a potential preference signal for aligning coding agents with human refactoring decisions in realistic codebases. We release the benchmark, leaderboard, and code.

cs.SE cs.AI cs.LG