Earlier quoted context omitted.
It actually goes even further than humans, humans can pretty rapidly get inured to things being awkward or messy and stop noticing, but the context for agents is taking up the same space and "attention" every time they're run, and they're creations entirely of context, so the quality and examples matter massively.
> actually goes even further than humans, humans can pretty rapidly get inured to things being awkward or messy and stop noticing, You’ve never had an agent completely lose the plot and forget/confuse its instructions due to the context filling up?
Does code cleanliness affect coding agents? A controlled minimal-pair study
81–90 of 112 posts
Re: Does code cleanliness affect coding agents? A controlled minimal-pair study
#82Earlier quoted context omitted.
Feel the same way myself when working in messy codebases… At some point, the horrible patterns start to rub off…
Every time this subject comes up, there are a bunch of takes along the lines of "would you work on a codebase maintained by agents? they'll mess up the code". And I'm asking myself where these people work, because in 20+ years I've yet to see that pristine state of a project that keeps being pristine after the honeymoon greenfield phase, and 50+ people start working on it. Every project devolves in time, old stuff ge…
Re: Does code cleanliness affect coding agents? A controlled minimal-pair study
#83Re: Does code cleanliness affect coding agents? A controlled minimal-pair study
#84Earlier quoted context omitted.
I’m in the “AI can be great, but it’s not right now” camp. I think that pulling the verification into the harness and having the harness execute it rather than the agent would genuinely make AI go to usable for me. But even prototyping a custom harness requires API billing which is just so expensive…
You can put many agent constraints in precommit hooks if they're static checks. I ask agents to make commits, and e.g. in a Python project have the precommit hook fire off type checks, linting and even architectural things like import boundaries (using `tach`). When an agent is prepped to make commits themselves, it will catch pre-commit failing and correct itself. The existence of static checks themselves might also…
Unless the agent, or the human don't enable the precommit hooks in the first place.
Re: Does code cleanliness affect coding agents? A controlled minimal-pair study
#85Interesting to see this quantified. Clean structure seems to lower the cognitive load for both humans and agents, which probably explains why naming and modularization matter more than we think.
Based on that, it should be a pretty unsurprising conclusion as long as the code quality metrics you are using are reasonable; as long as the quality metric is good (within the context of coding agents), then this is the result we'd expect to see.
Re: Does code cleanliness affect coding agents? A controlled minimal-pair study
#86One trick I've found that works well is to tell it to refactor, e.g for Python: Refactor the Python code to make it more Pythonic, e.g. fewer classes/singletons, especially if it will provide a speedup. The Python code **MUST** follow code organization standards expected of popular open-source Python packages code without causing any benchmark performance regressions. A variant I've used for Rust code: The Rust codeb…
I just say "refactor the codebase" and that also works pretty good! I have my code styling rules in my CLAUDE.md already anyway
Well... that is quite different than just saying "refactor the codebase".
Re: Does code cleanliness affect coding agents? A controlled minimal-pair study
#87"agent pipelines that [...] clean a messy [repository]" This feels like a terrible approach, sufficient to condemn the entire study. Apparently half of the "minimal pairs" in this work were constructed in this way. I simply am not going to trust any conclusion that requires assuming these AI "cleaned" repos are in any way representative of actually-good codebases.
First author here. Please let me offer a clarification. Our notion of "clean" isn't to just ask the agent to write better code. Rather, we give it a list of 50-100s static analyzer rule violations (and code LOC), and ask to remove them. We then check if the rule violations are resolved. Using LLMs to rewrite code to remove these violations is a rather accepted practice. Sonar's existing one-shot LLM based approach [1…
Re: Does code cleanliness affect coding agents? A controlled minimal-pair study
#88One trick I've found that works well is to tell it to refactor, e.g for Python: Refactor the Python code to make it more Pythonic, e.g. fewer classes/singletons, especially if it will provide a speedup. The Python code **MUST** follow code organization standards expected of popular open-source Python packages code without causing any benchmark performance regressions. A variant I've used for Rust code: The Rust codeb…
Re: Does code cleanliness affect coding agents? A controlled minimal-pair study
#89Re: Does code cleanliness affect coding agents? A controlled minimal-pair study
#90Interesting question to study, but I'm extremely skeptical of the experimental design. They used Opus 4.6 to synthetically produce "degraded" or "cleaned" code bases for relative comparison in the experiment. Worse, they don't control for breaking the application's tests. > Pass rate scores the agent’s final state against the hidden tests we wrote for each task. We do not check whether the agent broke unrelated tests…