8/23/2026 at 7:52:17 PM
A bunch of these should be enforce with linting, that way people who still hand-craft code get the same kind of feedback, e.g. Always use {}, even on a one-line "if" statement. & Keep function names short. Less than 30 characters.Then this one really is a pattern that creates a lot of churn:
- Add a small, to the point, comment to explain what the block does and why. Use examples when possible. Propose ASCII drawings to explain complete systems.
The what _is_ the code.
by OptionOfT
8/23/2026 at 10:26:11 PM
I forbid my agents from adding any comments. I review the code and add comments manually. If I can't understand something despite having the context then I throw away the code instead of having an LLM generate comments to explain what it did. This way the code stays readable/debuggable by humans.by hawk_
8/23/2026 at 11:53:41 PM
How do you stop LLMs from making comments? In my experience, LLMs treat requirements for code output as suggestionsby robby_w_g
8/24/2026 at 1:32:18 AM
If you don’t trust the code to write a decent comment, why trust it write good code?Of course, ensuring compilation or other checks can verify some code, which it can’t do for comments. But comments still serve the same purpose as human comments.
by ks2048
8/24/2026 at 3:42:46 AM
If I understand correctly, it’s not that the LLM can’t write a good comment, it’s that you want to be able to interpret and understand the generated code without comments - and in that process end up writing comments yourself.by Infernal
8/24/2026 at 4:49:32 PM
I don’t get that argument. Most of the time by the end of the session the comments from the agent encode tricky details that I told the agent to write down so it stops making “simplifying” assumptions. Thus comments at the end of a couple days of agent-only coding, when I start to actually read and edit the prose, contain the details which aren’t possible to know from reading the local code. It may help that my last couple sessions before I start reading the code myself are variations on telling the agent to self-review and improve the comments in specific ways, so the comments left are only those the agent thought remain meaningful at clarifying unexpected interactions between the local code and other code that needs to be referenced to understand it.by manwe150
8/24/2026 at 2:39:08 PM
The actual code output has improved a lot over the past year. I’ve found it matches existing patterns better, and the code is succinct so I can easily tweak it if I don’t like the way the agent wrote it.The problem with comments is that LLMs tend to copy their verbose chat output format and insert session/prompt specific details. It makes me think that LLMs aren’t constrained in their comment output the same way they are with their code output
by robby_w_g
8/24/2026 at 12:24:02 AM
Ask the agent to write a script to run after each changes, against the newly added code.Use that script as a super linter.
That’s the only way I found to strictly enforce some rules, like the no comments rule, without enforcing them against my own changes or old code.
by miki_oomiri
8/24/2026 at 5:00:40 AM
You could run the script mechanically against the diff (assuming you use version control). No need to rely on the agent.by eru
8/24/2026 at 6:31:31 AM
Add "Don't add any code comments anywhere" to your system prompt.If the model doesn't follow this, you want to start using a better model ASAP, because SOTA models for the last year or so, been able to following this without an issue.
by embedding-shape
8/24/2026 at 7:42:08 AM
I've come recently across arxiv 2604.20911which claims "do" rules persist much better then "don't" rules.
by yehoshuapw
8/24/2026 at 7:55:28 AM
Alright, what you'd put instead of "Don't add any code comments anywhere"?I agree with the general guidance, but it's a general one and not applicable for everything. Some things cannot be expressed in a "do" way rather than "don't".
by embedding-shape
8/24/2026 at 8:05:08 AM
I don't know. I fully agree, and never did really try out this in depth yet.I suspect rules with negations are not the same as don't rules, but unknown if really true, if so:
"when writing code do not add comments, code should not need it" may work
by yehoshuapw
8/24/2026 at 8:11:12 AM
Your proposal is still a "Prohibition-type constraint" that the paper you linked earlier say "isn't good".Some of these constraints we want simply aren't possible without adding "do not" somewhere in the line, even if you prefix/suffix it with other stuff, as you noticed yourself :)
by embedding-shape
8/24/2026 at 11:50:33 AM
I don't think changing "don't" to "do not" is what the paper authors had in mindI use things like "Your code should be self-documenting, so as to require as few comments as possible. Add comments to explain "why" or give important context not apparent from the code itself, but keep them to necessary comments only"
But that's a much laxer rule. I don't think you can truly express "no comments, ever" without a "don't" rule.
by wongarsu
8/24/2026 at 8:44:03 AM
Do add only code free from any comments.by sandos
8/24/2026 at 4:30:24 PM
"Do write comment-less code" ?by gozucito
8/24/2026 at 4:30:31 PM
In my experience, Claude adds loads of comments, but Codex (GPT-5.5) never adds any.by nicky0
8/24/2026 at 7:10:37 AM
> This way the code stays readable/debuggable by humans.Please take the following as expressed with genuine curiosity: Do you not use an editor with syntax highlighting and collapsible comments?
At least on JetBrains you can configure the editor to collapse all comments on open and to have the comments displayed in a low-contrast color. This way, LLMs add a bunch of comments, but it doesn't affect your actual experience in trying to read the code. If you encounter code that seems inexplicable, then and only then would you expand the comment to see if that helps you understand.
by solatic
8/24/2026 at 12:22:34 PM
Not the OP, my two cents:Comments should be written only when there is (hidden) complexity or external context strictly required. Otherwise it is just easier to read the code. Comments then signal one of two things: a) the following code is really complex and I need to tread carefully, or b) this code is complicated, and could benefit from a refactor.
In regards to agentic coding, all these comments are extra contents, driving down quality while increasing cost. Agents also tend to be inconsistent about updating comments, I've had cases repeatedly where a comment did not match the code, at which point it is just a documentation liability.
by arw0n
8/24/2026 at 7:20:21 AM
LLM comments for code are almost unfailingly completely redundant or impenetrably verbose bordering on word salad.by metek
8/24/2026 at 8:22:40 AM
Also, the language model might not fully understand the code then add a comment, then the next iteration will treat assumptions in the comment as the truth.by jodleif
8/24/2026 at 8:05:11 AM
Sometimes I try to add comments in a new session and the agent just don't have enough context for it to give a comprehensive sentence with full context on the why, then the agent will just describe what it does.Human comment is in another level to answer the questions mainly like "why do it like this" for the later collaborators or the forget-ed self, so the important blocks live when it is needed and can be eliminated when it does not.
by shunia_huang
8/24/2026 at 10:26:48 AM
Hiding the code from your view is not the solution.The next developer doing a review will see it. The next agent iteration will see it.
If the comment is wrong (even slightly) or redundant, that will help noone.
by dolmen
8/24/2026 at 8:06:26 AM
I think “This way the code stays readable/debuggable by humans” is a proof by example (not that the generated comments are necessarily bad).If the human can read/understand it well enough to comment it, then it is readable by humans.
by digitalPhonix
8/24/2026 at 8:41:24 AM
> If the human can read/understand it well enough to comment it, then it is readable by humans.No, because the one who is writing the comment has context later reader dont. The writer knows what the requirements are, what he was trying to achieve and what he struggled to comprehend. Writer also presumably spent more time trying to understand it then the person coming later should.
by watwut
8/24/2026 at 11:01:25 AM
It is not perfect, but the delta between 'cannot understand what agent wrote' and 'it makes sense to me right now' is already an improvement. That it may not be sufficient, doesn't mean it isn't a necessary condition.Besides, it has always been like this. I sometimes can't even understand some of the things I wrote myself a couple of months ago, because I forgot the context. Good comments and documentation will help you re-acquire the context you need, not completely eliminate it.
by Lutger
8/24/2026 at 11:33:13 PM
I'm not sure what you're arguing? I'm responding to:>> This way, LLMs add a bunch of comments, but it doesn't affect your actual experience in trying to read the code
by saying that at least reading the code and generating comments is forcing some understanding. Is there a disagreement in that?
You're saying that it's not (necessarily) enough understanding, which may be true but beside the point.
by digitalPhonix
8/24/2026 at 8:14:52 AM
Misleading and hard to read comments are worst then none at all for readability. If he did what you suggest, he would end up with tons of bad javadoc.by watwut
8/23/2026 at 11:49:23 PM
That seems like a really smart workflowI wish my coworkers would adopt this.
I’m sick of reading a fucking Charles dickens novel for every fucking tiny function
by lkjdsklf
8/24/2026 at 5:31:43 AM
Ugh, this. Had a workmate recently churn out 4,000 lines of code using Claude and I'm sure half of it was just comments.by jamesfinlayson
8/24/2026 at 1:12:36 AM
[flagged]by Mtinie
8/24/2026 at 5:26:17 AM
Mad props to you for that. Smart.by imagetic
8/23/2026 at 10:12:22 PM
Right. I've really struggling to get AI to stop explaining the what. It seems to add it to the commits, PRs, code, wherever it feels like. I've put in multiple places to not write the "what", but the "why", and in multiple ways, but it still does it in one or other place.by figmert
8/23/2026 at 10:36:42 PM
The best way I've found to solve this is using LLM as CI - use a small cheap model to inspect the diff and look for those kinds of comments. Prompt left to the observer but using `claude -p` / `codex exec` gets you a lot cleaner output usually, and makes robots fight robots instead of you constantly having to reprompt and it ignoring you.by jaggederest
8/24/2026 at 12:28:20 AM
I've reached that point as well. Is there a preferred model and prompt you use for that?by 5thaccount
8/24/2026 at 6:29:45 AM
[flagged]by jaggederest
8/23/2026 at 7:53:50 PM
I would never tell an agent to write "what does the code do" comments. Their default comments are already way too fluffy.by getnormality
8/23/2026 at 10:33:17 PM
But then you don't know about where the load bearing seams are!by saghm
8/24/2026 at 3:59:19 AM
Honestly? That’s the kicker.by JSR_FDED
8/24/2026 at 1:26:35 AM
Hmm, I guess everyone here is using Claude? I find that Sol is much more restrained, to the point where I have a prompt to tell it to add short comments for things that are not obvious. Really, I find the verbosity problem to be worse in tests. I regularly prompt my review agent to remove tests used only for scaffolding to write the code in the first place. The agent is in a way following strict TDD, which reminds me why I don’t like TDD, even though some of the generated tests can be useful.by telotortium
8/24/2026 at 4:38:46 AM
Sol adds comments when I use it, but it's not nearly as verbose as Opus 5/Fable.For the latter I'll often include an example of a comment it wrote, along with my own rephrasing, and tell it that "future readers will understand code context; good naming is the best documentation". This works alright if I include in the actual prompt, but annoyingly it often doesn't in CLAUDE.md or memory.
by sampullman
8/23/2026 at 11:45:02 PM
I tell the agent to NEVER write comments in the system prompt and it ignore it like 90% of the time. RLHF is a helluva drug.by throwatdem12311
8/24/2026 at 2:23:43 AM
We trained agents on millions of pages of documentation telling them to write good comments and good code and then we tell them never to write any comments.It’s almost the “we built a robot who loves to play Sonatas and gave it no hands” type of thing.
by bombcar
8/24/2026 at 2:19:13 PM
Being overly trained on comments in documentation could be one of the reasons why Claude models write frustrating comments (which often manifest as written justifications of how the code satisfies the prompt). A comment in a tutorial is going to be geared to explaining how the code relates back to the tutorial task or restating what the code does, rather than documenting the "why" of surprising code.by benregenspan
8/24/2026 at 6:33:57 AM
What models are you using? I've had "Never add any new code comments" in my system prompts for like a year at this point, seems every model above 14B picks this up just fine. Are you using llama 7b or similar for testing this?by embedding-shape
8/23/2026 at 9:17:10 PM
I added to the memory, system prompts, and the prompt itself and every soa model still litters code with the most inane useless crap. I will then get code to review from a coworker using fable/opus. It has more lines of comments then code.Maybe I am some god tier code reader (i am not) but i dont think i have ever found a comment in code to be useful in my day job. That isnt true, i once came across
// submit to the dark lord
Above the function that sent a payment to PayPal for processing. It made me laugh so I let it be.
by rustystump
8/23/2026 at 10:17:45 PM
Most useful code comment I have encountered read:“”” After you give up on trying to refactor this code, increment the following line accordingly. HOURS_WASTED_HERE=26 “””
by danielheath
8/23/2026 at 10:05:24 PM
My biggest pet peeve with agents is when people beg their (non-deterministic) agents to do something that a lint rule could've accomplishedby culi
8/23/2026 at 10:15:35 PM
Seems like 80% of agent use boils down to: grep | sed -iWhich is kind of cool if you’re unaware enough to know to do it yourself.
Oh, and find. Agents use find a lot.
by irishcoffee
8/23/2026 at 11:01:05 PM
So it turns out that a lot of these unix utilities have such bad UX that having a tool that knows how to really leverage them feels like a superpower.If you've ever used an LLM to deal with ffmpeg you'll know exactly what I mean.
by eterm
8/24/2026 at 1:01:07 AM
It is incredibly difficult to make an UX that can beat simply typing what you need in your own words.You think of what you need, and you type it. No need to even ask “what options should I use?”
by drfloyd51
8/24/2026 at 1:14:14 AM
I would rather bet that people don’t know that their problem has been solved for ages. Either they don’t know about the tools or can’t make the leap to think of using something like awk or sed to quickly script out their use cases. Or even quickly draft up a quick function/plugin in something like vim, emacs, sublime,…In “The Pragmatic Programmer”, the power of unix tools and editor fluency is well argued. There are plenty of other books like “Unix Power Tools”, “Small, Sharp Software Tools”,…
by skydhash
8/24/2026 at 10:17:14 PM
My problem is always the time necessary to get good at the tool is slightly more than just brute forcing it one more time.by bombcar
8/25/2026 at 1:37:36 AM
I'm not always forced for time. And the time is slightly less when you know how to use man (with apropos and whatis, a few unix conventions (null vs newline when piping text) and the quirks/feature of your shell.by skydhash
8/23/2026 at 11:50:34 PM
Pi even installs ripgrep and fd if it can't find them in the path.by selcuka
8/24/2026 at 1:33:39 AM
It turns out that thinking about and executing these commands at a superhuman speed is, to ape Claude, the real unlock.by telotortium
8/24/2026 at 3:56:04 AM
Yeah, I've actually found in my own testing and usage of LLMs that this is where I get a lot of benefit. I already have fd, ripgrep, etc. installed and know how to use them, but it's not hard to tell the LLM to do it and it often finds things just as well. Or even better.It's especially handy on modern style code where things get broken up across a multitude of files based on convention.
by mpyne
8/23/2026 at 11:00:03 PM
Mine says what I tell engineers:> Write in-code comments that describe _why_ code or a class does what it does, but not _what_ it does. The "what" should be self-evident.
by tyre
8/23/2026 at 10:27:14 PM
Incidentally, I'm from the opposite school and consider every “if” followed by a braced block a smell. If a conditional body needs a block, it's doing enough to deserve a name, so I promote it to a single named call, à la "Extract till you drop".by arialdomartini
8/24/2026 at 12:16:02 AM
Another phrase for this is "functional decomposition", which usually is a good thing.Better yet is to identify conditional execution paths as early as possible in order to obviate conditionals in the call tree. For example, identifying a "create a new something" verses an "update an existing something" based on the workflow initially invoked greatly simplifies service and/or persistent store logic.
by AdieuToLogic
8/24/2026 at 6:12:43 AM
So you’ll make a two line function to replace a braced block? Seems kind of unhinged.by what
8/24/2026 at 1:07:26 PM
The "Uncle Bob" school of thought follows this pattern. Look at his projects, I personally find them unreadable.by farlight
8/24/2026 at 9:45:21 AM
It may happen. I guess you agree that most of the times conditional blocks exist they are more than 2 lines.by arialdomartini
8/24/2026 at 2:20:53 PM
A comment is just a summary of the code in an abstraction that's easier to follow. Let's say you have a simple function which would produce an almost as large comment, yes obviously useless. If the function is large enough, yeah summarizing it as a comment is a good idea.Now you might say, don't write huge functions. Sure I agree, but most codebase or teams are not super disciplined enough. So comments are a compromise.
by woud420
8/24/2026 at 2:23:52 PM
Comments lie. What's worse, AI trusts the comments and apparent logic (inferred from identifiers and whatnot) more than the actual logic. You can quickly get into a mess of stale comments. What's worse, the LLM can sometimes just spit out garbage that poisons the context of the next agent. I disallow comments from my LLM for that last reason.by isqueiros
8/24/2026 at 5:45:07 PM
Code can "lie" too.```auto a = 65535 + 1``` will give you a different answer depending on the architecture. You can then decide.. oh don't use auto or don't use c++ or whatever and have standards... like the standard you set for yourself "disallow comments from my LLM".
by woud420
8/24/2026 at 2:35:40 PM
>> A comment is just a summary of the code in an abstraction that's easier to follow.I disagree. The code already tells you what it does. A summary has low value.
Comments should be for explaining the why: the reason the function uses a particular algorithm even if it's a bit slower, or why the return format is an unconventional shape or contains redundant bits. This is so that someone coming in later (either a human or agent) doesn't get confused or think that the function needs refactoring.
Summary comments have ended up as the bane of my existence everywhere I've worked, for one simple reason: they go stale and there's no way to prevent it from happening.
by enraged_camel
8/24/2026 at 5:48:22 PM
That's your experience and it's valid. For me documentation AND comments have been useful on occasion.The core thing that I agree with is that comments (or docs) can get stale and not follow what is actually being executed. The way I work with it is by being structured, consistent and follow standards. Unfortunately for me, not all developers follow the same guidelines.
by woud420
8/23/2026 at 10:26:29 PM
> Propose ASCII drawings to explain complete systems.LLMs are very bad at ASCII drawings.
https://medium.com/data-science/why-llms-suck-at-ascii-art-a...
by 0xfeba
8/24/2026 at 10:35:02 AM
This article is dated January 2025.Labs have now long understood that ASCII drawing is a core skill needed for coding agents. However, I would not trust them understanding what an existing drawing means, unless it has generated itself.
by dolmen
8/24/2026 at 2:23:56 AM
[dead]by throwuxiytayq
8/24/2026 at 2:27:42 PM
At my work we have basically banned "what" comments for blocks of code. JSDoc comments can still document what a function does at a high level but it should not go into implementation details unless they are important to anyone using the function. And any comments inside the function should always be for explaining why, not what. The "what" of a piece of code should be self explanatory by just reading the code. If it's not, then you likely should rewrite it to be more clear (sometimes hard-to-read code is necessary and then a "what" comment would be appropriate, but this is rare)."What" comments almost always end up falling out of date or even sometimes being slightly incorrect from day one. Incorrect comments lead to confusion and bugs. If a comment says some code does X but the code actually does Y, then you don't know whether the comment is just out of date or if Y is actually a bug. But if a comment explains the intention of the code and the code contradicts that intention, then you know it's likely a bug.
by EliasWatson
8/24/2026 at 6:26:54 AM
The cost of custom linters has like any other code dropped through the floor. I'm sprinkling all kinds of linters over my latest projects. It seems some people are still sleeping on this, expecting great code from the agents.They're fast and deterministic and I run them in git pre-commit.
by duttish
8/24/2026 at 6:30:07 AM
> expecting great code from the agentsYeah, I'm not sure what people are thinking. I keep reading stuff from folks like "I wish models had more common sense" and "I wish they wrote better code", not realizing this is 100% in your own hands, always been. There is no such thing as "clean code" that every programmer agrees on, you have your own subjective opinion and "good" taste about the code, instruct the models to follow it! And automate it while you're on it.
by embedding-shape
8/24/2026 at 4:20:38 PM
> They're fast and deterministic and I run them in git pre-commit.Isnt that too late? I would want the agent to stumble into this as early as possible in the agentic loop, eg at the same time as compiler.
by DenisM
8/24/2026 at 6:48:21 PM
It's been working quite well so far and I don't know of any way of hooking custom linters into cargo so they run after compilation.But that's a pretty good idea, wonder if there is a way...
by duttish
8/24/2026 at 12:07:40 PM
> Then this one really is a pattern that creates a lot of churn:> - Add a small, to the point, comment...
As if you even need to tell Claude to add comments. Over the past few weeks I've noticed Claude over-commenting everything. Massive PRs where you realise that fully half or more of the lines that have changed are comments.
It's no good at all: it just pollutes the context, causes token churn, ablates quality, and makes getting to a high quality outcome considerably slower and more expensive.
I get that sometimes knowing why a thing is the way it is can be useful and valuable, but this is what commit comments are for in my mind.
I've had to tell Claude to stop commenting code because the behaviour has become so problematic.
> The what _is_ the code.
Exactly.
If I don't know what the code does because it's arcane and not commented I can simply ask the LLM to explain it to me. I don't need an essay in comment form.
by bartread
8/24/2026 at 12:03:11 AM
Linters and static analysis -> setup as hooks in your harness. Don’t rely on CLAUDE.md because it’ll ignore it a lot.> ASCII drawings in code
Please don’t this is super obnoxious. Make proper diagrams and kee them in knowledge base. Link out to them if you need to and let the agent fetch them via MCP or API or whatever if it wants them.
by throwatdem12311
8/24/2026 at 3:22:12 AM
> A bunch of these should be enforce with lintingAgreed. One of the first rules I toss into Biome is `noNestedTernary` - LLMs seem to adore completely unreadable nested expressions.
by vunderba
8/24/2026 at 10:53:28 AM
This! I also saw lot of potential work that could be done by linting tools. Remember to always prefer mechanical guards than agent instructions, as they cannot ignore them.by libertas_quae_s
8/24/2026 at 1:36:03 PM
# save the request headers for later because we don't yet know which one we'll needby andreareina
8/24/2026 at 12:48:30 PM
This.We've been using agents heavily for all code for a long time now in my company - everyone has comprehensive & opinionated AGENTS.md customisations & they're widely shared & discussed. Almost everything in this post seems incredibly naive day-one LLM user mistakes - especially everything related to coding style at line level granularity.
We've had non-LLM tooling for these kinds of standards for many years now & the great thing about agents is they're already versed in said tooling. If you haven't got a decent lint setup, ask your agent to set one up. It'll give you much better guarantees than this slop which is just going to drift from model to model & is completely unverifiable.
by lucideer
8/24/2026 at 1:06:31 AM
> The what _is_ the code.Even the why sometimes shouldn’t be a comment, unless it’s very immediate to the code itself. What’s often more necessary is a high level overview of the design of the solution, because that’s what drives the design of the code and link disparate section. Especially the glossary , which you let you understand the name of the symbols (variables, struct. functions,…) used in the code.
It’s like learning the culture associated to a foreign language instead of trying to translate each single word with a dictionary.
by skydhash
8/23/2026 at 10:19:28 PM
One thing I don’t get with a lot of these agents.md and other skills are… why not throw as much mechanical checks and other stuff at the repo to constrain as you want instead of asking a non-deterministic agent (squishy or non-squishy) to maintain it.With the mechanical routes, we get checks, failures, and so much more. A bit wild to me.
Make an agent operate within defined constraints and yell at it when it doesn’t.
by _boffin_
8/24/2026 at 1:57:26 AM
Do both. Instructions help avoid the first pass from making the same mistakes.> Make an agent operate within defined constraints and yell at it when it doesn’t.
And tell it what the constraints are.
by IanCal
8/24/2026 at 5:50:57 AM
[flagged]by _boffin_