Is clean code relevant in the AI age? I was asked this question in my last Agentic Coding class.
After all AI can understand the code anyway, whether its clean or not. And as long as the tests pass and the code works, then why should you care?
Here is why you should care: AI Agents don't understand the codebase the same way that humans do. When you give a feature that an AI agent needs to implement, it figures out the codebase in three ways:
- Documentation (AGENTS.md / CLAUDE.md)
- Listing filenames (glob)
- Searching files for keywords (grep) and reading them
If your documentation has good overviews, and if your files are neatly modularised, then this becomes a simple process -- Find the relevant directory or file, read it into context and make the change.
But if your code is messy, files are huge with multiple features in them, the code is not modularised, naming of functions and variables is bad, code is duplicated ... then two things happen:
- The agent will not find all the right places to make the change or make the wrong changes 👉🏽 Bugs
- The agent needs to read many huge files to make the change 👉🏽 massive token costs
All the things that help humans navigate a codebase, also help agents:
- Good documentation helps agents zero into the right files straight away
- Clear variable, function and parameter names help agents understand the code much faster
- Well organised code that requires changes to be made in a single, small, well-contained file help agents implement features much more reliably
- Changes that require reading multiple large files and making changes in multiple places are a challenge for AI agents
Remember: Unlike a human that learns the codebase over time, an AI Agent starts from zero every time you start a session. Even if it's been working on that codebase for weeks. And it will face the same problems every single time.
So, is clean code relevant in the AI age? Unless you want to blow up your token budget and ship bugs, then absolutely yes.
(pic from "Software Fundamentals Matter More Than Ever" by Matt Pocock)
Recent Articles
- • AI Agents Need Hard Boundaries Apr 24, 2026
- • Managing Context in Agentic Coding Apr 22, 2026
- • AI Agents Need to Learn to Forget Apr 20, 2026
- • Are enterprise coding agents getting unaffordable? Apr 17, 2026