Home / Companies / Sonar / Blog / Post Details
Content Deep Dive

Clean Codebase Reduces AI Token Costs by Up to 8.5%

Blog post from Sonar

Post Details
Company
Date Published
Author
Prasenjit Sarkar and Priyansh Trivedi
Word Count
1,463
Language
English
Hacker News Points
-
Summary

Research investigating the impact of code quality on AI-assisted software development reveals that cleaner code significantly reduces the computational resources required for AI agents to perform tasks, although it does not affect the completion rate of those tasks. By creating and testing pairs of repositories with identical functionality but varying code quality, the study found that cleaner code led to a reduction in input and output tokens and a decrease in the agent's reasoning effort. These findings emphasize that well-maintained code not only benefits human developers but also reduces the operational costs associated with AI agents, making code quality a critical factor in managing AI expenses. The study suggests that cleaner code facilitates more efficient processing by AI agents, as they spend less time re-reading and reassessing code, thus highlighting the importance of code quality in AI-centric development environments. Further research is planned to expand the scope of these findings across different large language models and AI systems, with the expectation that the positive effects of clean code will amplify over time.