Code for Machines, Not Just Humans: Quantifying AI-Friendliness with Code Health Metrics
Markus Borg, Nadim Hagatulah, Adam Tornhill, Emma S\"oderberg

TL;DR
This paper explores how code quality metrics designed for human understanding can also predict the success of AI-driven code refactoring, promoting AI-friendly coding practices.
Contribution
It introduces the concept of AI-friendly code and demonstrates that CodeHealth metrics correlate with semantic preservation during AI-based refactoring.
Findings
CodeHealth correlates with semantic preservation after AI refactoring.
Human-friendly code is more compatible with AI tooling.
Maintaining high code quality benefits both humans and AI systems.
Abstract
We are entering a hybrid era in which human developers and AI coding agents work in the same codebases. While industry practice has long optimized code for human comprehension, it is increasingly important to ensure that LLMs with different capabilities can edit code reliably. In this study, we investigate the concept of ``AI-friendly code'' via LLM-based refactoring on a dataset of 5,000 Python files from competitive programming. We find a meaningful association between CodeHealth, a quality metric calibrated for human comprehension, and semantic preservation after AI refactoring. Our findings confirm that human-friendly code is also more compatible with AI tooling. These results suggest that organizations can use CodeHealth to guide where AI interventions are lower risk and where additional human oversight is warranted. Investing in maintainability not only helps humans; it also…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsEthics and Social Impacts of AI · Software Engineering Research · Artificial Intelligence in Healthcare and Education
