Clean code in the age of coding agents
yanis_t
49 points
82 comments
April 09, 2026
Related Discussions
Found 5 related stories in 62.2ms across 4,075 title embeddings via pgvector HNSW
- Slowing Down in the Age of Coding Agents larve · 15 pts · March 24, 2026 · 65% similar
- We should revisit literate programming in the agent era horseradish · 195 pts · March 08, 2026 · 65% similar
- Components of a Coding Agent MindGods · 204 pts · April 04, 2026 · 61% similar
- Some uncomfortable truths about AI coding agents borealis-dev · 70 pts · March 27, 2026 · 60% similar
- Custom programming languages make agents good matsur · 17 pts · March 12, 2026 · 59% similar
Discussion Highlights (13 comments)
Insensitivity
> LLMs are pretty good at picking up the style in your repo. So keeping it clean and organized already helps. At least in my experience, they are good at imitating a "visually" similar style, but they'll hide a lot of coupling that is easy to miss, since they don't understand the concepts they're imitating. They think "Clean Code" means splitting into tiny functions, rather than cohesive functions. The Uncle Bob style of "Clean Code" is horrifying They're also very trigger-happy to add methods to interfaces (or contracts), that leak implementation detail, or for testing, which means they are testing implementation rather than behavior
fooker
I’ll go against the prevailing wisdom and bet that clean code does not matter any more. No more than the exact order of items being placed in main memory matters now. This used to be a pretty significant consideration in software engineering until the early 1990s. This is almost completely irrelevant when we have ‘unlimited’ memory. Similarly generating code, refactoring, implementing large changes are easy to a point now that you can just rewrite stuff later. If you are not happy about how something is designed, a two sentence prompt fixes it in a million line codebase in thirty minutes.
jake-coworker
I generally agree - I think anyone who's seriously experimented with agentic coding has encountered both: 1 - Surprising success when an agent can build on top of established patterns & abstractions 2 - A deep hole of "make it work" when an LLM digs a whole it can't get out of, and fails to anticipate edge cases/discover hidden behavior. The same things that make it easier for humans to contribute code make it easier for LLMs to contribute code.
BeetleB
Ever since AI coding became a thing, Clean Code advocates have been trying to get LLMs to conform. I was hoping this submission would declare "Success!" and show how he did it, but sadly it's devoid of anything actionable. I'm not a fan of Clean Code[1], but the only tip I can give is: Don't instruct the LLM to write code in the form of Clean Code by Robert Martin. Itemize all the things you view as clean code, and put that in CLAUDE.md or wherever. You'll get better luck that way. [1] I'm also not that anti-Uncle-Bob as some are.
ambewas
in my experience, as long as you set up a decent set of agent definitions & a good skillset, and work in an already pretty clean codebase with established standards, the code quality an agent outputs is actually really good. Couple that with a self-correcting loop (design->code->PR review->QA review in playwright MCP->back to code etc), orchestrated by a swarm coordinator agent, and the quality increases even further.
CharlieDigital
I have a bit more practical approach here (write up at some point): the most important thing is to rethink how you are instructing the agents and do not only rely on your existing codebase because: 1) you may have some legacy practices, 2) it is a reflection of many hands, 3) it becomes very random based on what files the agent picks up. Instead, you should approach it as if instructing the agent to write "perfect" code (whatever that means in the context of your patterns and practices, language, etc.). How should exceptions be handled? How should parameters be named? How should telemetry and logging be added? How should new modules to be added? What are the exact steps? Do not let the agent randomly pick from your existing codebase unless it is already highly consistent; tell it exactly what "perfect" looks like.
nlh
I'm guessing a lot of similar debates were had in the 1970s when we first started compiling C to Assembly, and I wonder if the outcome will be the same. (BTW: I was not around then, so if I'm guessing wrong here please correct me!) Over time compilers have gotten better and we're now at the point where we trust them enough that we don't need to review the Assembly or machine code for cleanliness, optimization, etc. And in fact we've even moved at least one abstraction layer up. Are there mission-critical inner loops in systems these days that DO need hand-written C or Assembly? Sure. Does that matter for 99% of software projects? Negative. I'm extrapolating that AI-generated code will follow the same path.
j45
It's important to remember humans have shipped slop too, and code that isn't clean. When the training is across code with varying styles, it is going to take effort to get this technology performing in a standardized way, especially when what's possible changes every 3 months.
gz09
our CLAUDE.md / AGENTS.md specifically calls out good engineering books, which I think does help: From https://github.com/feldera/feldera/blob/main/CLAUDE.md : - Adhere to rules in "Code Complete" by Steve McConnell. - Adhere to rules in "The Art of Readable Code" by Dustin Boswell & Trevor Foucher. - Adhere to rules in "Bugs in Writing: A Guide to Debugging Your Prose" by Lyn Dupre. - Adhere to rules in "The Elements of Style, Fourth Edition" by William Strunk Jr. & E. B. White e.g., mentioning Elements of Style and Bugs in Writing certainly has helped our review LLM to make some great suggestions about English documentation PRs in the past.
esilverberg2
Our company makes extensive use of architectural linters -- Konsist for Android and Harmonize for Swift. At this point we have hundreds of architectural lint rules that the AI will violate, read, and correct. We also describe our architecture in a variety of skills files. I can't imagine relying solely on markdown files to keep consistency throughout our codebase, the AI still makes too many mistakes or shortcuts.
embedding-shape
4. Iterate on a AGENTS.md (or any other similar file you can reuse) that you keep updating every time the agent does something wrong. Don't make an LLM write this file, write it with your own words. Iterate on it whenever the agent did something wrong, then retry the same prompt to verify it actually steers the agent correctly. Eventually you'll build up a relatively concise file with your personal "coding guidelines" that the agent can stick with with relative ease.
zamalek
The last two weeks with Claude has been a nightmare with code quality, it outright ignores standards (in CLAUDE.md). Just yesterday I was reviewed a PR from a coworker where it undid some compliant code, and then proceeded to struggle with exactly what the standards were designed to address. I threw in the towel last night and switched to codex, which has actually been following instructions.
Verdex
Heres the thing about clean code. Is it really good? Or is it just something that people get familiar with and actually familiarity is all that matters. You can't really run the experiment because to do it you have to isolate a bunch of software engineers and carefully measure them as they go through parallel test careers. I mean I guess you could measure it but it's expensive and time consuming and likely to have massive experimental issues. Although now you can sort of run the experiment with an LLM. Clean code vs unclean code. Let's redefine clean code to mean this other thing. Rerun everything from a blank state and then give it identical inputs. Evaluate on tokens used, time spent, propensity for unit tests to fail, and rework. The history of science and technology is people coming up with simple but wrong untestable theories which topple over once someone invents a thingamajig that allows tests to be run.