NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

MaintainCoder: Maintainable Code Generation Under Dynamic Requirements

Zhengren Wang, Rui ling, Chufan Wang, Yongan Yu, Sizhe Wang, Zhiyu li, Feiyu Xiong, Wentao Zhang

Abstract

In the software lifecycle, maintenance accounts for 60–80% of total costs. However, current Large Language Model (LLM) code generation benchmarks prioritize one-shot functional correctness, often resulting in brittle, monolithic code that is difficult to adapt. We introduce MaintainCoder, a multi-agent framework designed to generate maintainable code by mimicking the human software development lifecycle. We also present MaintainBench, a benchmark specifically designed to evaluate code adaptability across functional extensions, interface changes, and data structure transformations. Our evaluation demonstrates that MaintainCoder significantly outperforms state-of-the-art models in dynamic maintainability metrics, providing a path toward reducing technical debt in AI-assisted programming.

Introduction

The current paradigm in AI code generation research is heavily focused on "functional correctness"—whether a generated snippet passes a static set of test cases at the moment of creation. This narrow focus has led to a "Maintainability Crisis." LLMs often produce code that is functionally correct but architecturally brittle: monolithic blocks that work for a specific prompt but become prohibitively expensive to modify when requirements evolve. This results in significant technical debt, where short-sighted design decisions lead to exponential future costs. The authors argue that the field lacks both the tools to generate maintainable code and the benchmarks to measure it.

Methods: The MaintainCoder Framework

To address the limitations of one-shot generation, MaintainCoder utilizes an orchestrated pipeline of specialized agents that mirror the human software development lifecycle (SDLC). Instead of direct code generation, the system follows a structured architectural approach:

  1. Requirements Analysis Agent: Decomposes the problem and identifies core functionalities.
  2. Design Pattern Selection Agent: Acts as a software architect, selecting appropriate patterns (e.g., MVC, Strategy) to ensure low coupling and high cohesion.
  3. Framework Design & Evaluation Agents: These agents collaborate to create and refine an architectural blueprint before implementation begins.
  4. Code Generation & Optimization Agents: These agents implement the blueprint into production-ready Python code, adhering to PEP 8 standards and performing iterative debugging.
The MaintainCoder multi-agent pipeline mirrors the human software development lifecycle to prioritize architectural integrity.

MaintainBench: Measuring Change

To evaluate how well code handles evolution, the authors developed MaintainBench. This benchmark systematically applies four types of requirement changes to existing problems: functional extensions, interface modifications, data structure transformations, and error handling enhancements.

Traditional static metrics like the Maintainability Index (MI) or Cyclomatic Complexity (CC) often fail to reflect actual maintenance effort. Consequently, the authors propose dynamic metrics as more reliable indicators of adaptability:

  • Pass@5: Correctness after a requirement change.
  • AST_sim: Structural similarity of the abstract syntax tree, indicating how much of the core architecture remained robust after modification.

Experimental Results

MaintainCoder was evaluated against state-of-the-art models including GPT-4o, Claude 3.7, and DeepSeek-V3 across five datasets ranging from entry-level to competition-level difficulty.

Maintainability evaluation results on competition-level datasets (CodeContests-Dyn and xCodeEval-Dyn).

Key findings include:

  • Dynamic Maintainability: On the APPS-Dyn dataset, MaintainCoder improved post-modification correctness (Pass@5) by 15-30 percentage points compared to baselines.
  • Structural Adaptability: The framework achieved significantly higher AST_sim scores, proving that its modular approach preserves core logic during evolution.
  • Initial Correctness: Surprisingly, architectural thinking also improved initial performance. On xCodeEval, MaintainCoder (using GPT-4o-mini) achieved a 57% initial pass rate, an 11% absolute increase over the base model.

Conclusion

MaintainCoder demonstrates that integrating classical software engineering principles into multi-agent frameworks can mitigate technical debt in AI-generated code. While the computational cost of a multi-agent pipeline is higher than single-turn prompting, the long-term reduction in maintenance effort presents a compelling trade-off for real-world software development. Future work will focus on expanding these methods to repository-scale challenges and diverse programming languages.

Summary updated

BibTeX
@inproceedings{wang2025maintaincoder,
  author = {Zhengren Wang and Rui ling and Chufan Wang and Yongan Yu and Sizhe Wang and Zhiyu li and Feiyu Xiong and Wentao Zhang},
  title = {{MaintainCoder: Maintainable Code Generation Under Dynamic Requirements}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=TIbQixHEFD},
}
Figure