OptionOfT
9 hours ago
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.
hombre_fatal
5 minutes ago
The code is the what, but it doesn't capture the intent. I like intent/justification in comments. Also useful for file-level comments and per-test comments.
hawk_
7 hours ago
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.
robby_w_g
5 hours ago
How do you stop LLMs from making comments? In my experience, LLMs treat requirements for code output as suggestions
miki_oomiri
5 hours ago
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.
eru
9 minutes ago
You could run the script mechanically against the diff (assuming you use version control). No need to rely on the agent.
ks2048
4 hours ago
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.
Infernal
an hour ago
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.
lkjdsklf
5 hours ago
That seems like a really smart workflow
I wish my coworkers would adopt this.
I’m sick of reading a fucking Charles dickens novel for every fucking tiny function
figmert
7 hours ago
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.
jaggederest
7 hours ago
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.
5thaccount
5 hours ago
I've reached that point as well. Is there a preferred model and prompt you use for that?
getnormality
9 hours ago
I would never tell an agent to write "what does the code do" comments. Their default comments are already way too fluffy.
telotortium
4 hours ago
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.
sampullman
31 minutes ago
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.
saghm
7 hours ago
But then you don't know about where the load bearing seams are!
JSR_FDED
an hour ago
Honestly? That’s the kicker.
throwatdem12311
5 hours ago
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.
bombcar
3 hours ago
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.
rustystump
8 hours ago
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.
danielheath
7 hours ago
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 “””
culi
7 hours ago
My biggest pet peeve with agents is when people beg their (non-deterministic) agents to do something that a lint rule could've accomplished
irishcoffee
7 hours ago
Seems like 80% of agent use boils down to: grep | sed -i
Which is kind of cool if you’re unaware enough to know to do it yourself.
Oh, and find. Agents use find a lot.
eterm
6 hours ago
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.
drfloyd51
4 hours ago
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?”
skydhash
4 hours ago
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”,…
selcuka
5 hours ago
Pi even installs ripgrep and fd if it can't find them in the path.
telotortium
4 hours ago
It turns out that thinking about and executing these commands at a superhuman speed is, to ape Claude, the real unlock.
mpyne
an hour ago
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.
tyre
6 hours ago
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.
vunderba
2 hours ago
> A bunch of these should be enforce with linting
Agreed. One of the first rules I toss into Biome is `noNestedTernary` - LLMs seem to adore completely unreadable nested expressions.
arialdomartini
7 hours ago
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".
AdieuToLogic
5 hours ago
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.
0xfeba
7 hours ago
> 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...
throwatdem12311
5 hours ago
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.
_boffin_
7 hours ago
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.
IanCal
3 hours ago
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.
skydhash
4 hours ago
> 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.