Clean Code in the Age of Coding Agents
- title
- Clean Code in the Age of Coding Agents
- type
- summary
- summary
- Code structure matters more with agents โ context windows are finite, messy code wastes tokens
- tags
- llm, coding-agent, software-quality
- sources
- clean-code-coding-agents
- created
- 2026-04-10
- updated
- 2026-05-13
A short yanist.com post making one point: clean code isn't less important when you're working with coding agents, it's more important. The argument is that LLM context windows are the machine equivalent of human cognitive load, so the same organizational principles that help a human navigate a codebase also help an agent. Messy code forces the agent to read more files than it needs, burning context space on irrelevant code and wasting tokens on orientation instead of output.
The framing draws on Robert Martin's Clean Architecture split between code's value (does it do the right thing) and its structure (is it organized so you can change it later). Value is easy to see โ the feature works or it doesn't. Structure is harder to notice and its costs compound: each poorly organized module makes the next feature slightly harder to add, and each patch on top of a messy abstraction makes bugs slightly more likely. Martin made this argument for human teams; the post extends it to agent-assisted development by noting that agents suffer from the same structural costs, just expressed as context pollution rather than developer confusion.
The practical advice is thin but concrete: tell the agent how you want code organized, not just what you want it to do. Maintain consistent style across the repo so the agent picks up conventions from context rather than needing them spelled out every time. Review agent output for structure, not just correctness โ agents default to generating code that works, not code that's organized.
This is the constructive complement to several other pieces in the wiki. cult-of-vibe-coding argues you should read the code yourself (Cohen's audit-discuss-execute loop). no-silver-bullet-llms argues the bottleneck is design and specification, not code generation speed. building-syntaqlite-ai documents what happens when you delegate design to the agent and lose your mental model. This post is gentler โ it doesn't argue against using agents, just that the humans using them still own the structural decisions. The agent generates the code; you maintain the architecture. That division of labor only works if the architecture is clean enough for the agent to navigate efficiently.
Bryan Cantrill's "The Peril of Laziness Lost" supplies the deeper reason why agents default to mess: work costs them nothing, so they have no drive to simplify. The "virtuous laziness" of human time constraints is what produces the clean code this post advocates maintaining.
The piece is lightweight โ it states the argument without evidence or case studies. But the core observation (context windows are finite โ structure determines how much useful work fits in a single context) is correct and connects the "clean code" tradition to the LLM-agent world in a way that the original Martin/Fowler writing obviously couldn't.
For one published architectural pattern that explicitly markets itself on this premise, see porto-sap โ its current README leads with the claim that single-responsibility classes-per-file make codebases more Copilot-friendly, which is this post's argument turned into a folder convention.
- acai.sh
- impeccable
- mindwalk
- vera
- 1Password โ What We Learned Using AI Agents to Refactor a Monolith
- Acceptance Criteria IDs (ACIDs)
- Agent-built deterministic tools
- Agentic Coding is a Trap
- Git is not fine
- Your Clippy config should be stricter
- Control the Ideas, Not the Code
- Editor-as-UI pattern
- little-coder โ Scaffold-Model Fit on Aider Polyglot
- LLM as Average Democratizer
- No Silver Bullet
- In Defense of Not Understanding Your Codebase
- Notes on Software Quality (Hobday)
- The Peril of Laziness Lost
- Porto SAP
- You Should Read "Programming as Theory Building"
- Programming as Theory Building
- Scaffold-Model Fit
- Specsmaxxing โ Acceptance Criteria as the Primary Artifact
- Stop Using Pull Requests
- Structured Output Benchmark (SOB)
- A Text Editor as a User Interface (Dave Gauer)
- Typed De Bruijn indices for LLMs
- With AI, You Barely Need a Frontend Framework