Live data from Hacker News

My agent.md to improve LLM-assisted code quality

fabiensanglard.net

151–160 of 200 posts

Re: My agent.md to improve LLM-assisted code quality

#151

Earlier quoted context omitted.

I've come recently across arxiv 2604.20911 which claims "do" rules persist much better then "don't" rules.

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".

Do add only code free from any comments.

Re: My agent.md to improve LLM-assisted code quality

#152
My problem with latest models is that you can’t tell them anything or they’ll treat it as gospel and over do it

For example this says > Reduce code indentation. Avoid Arrow Anti-Pattern. Leverage early return and continue.

You can bet sol is going bend over backward to reduce indentation now and write non idiomatic code

Re: My agent.md to improve LLM-assisted code quality

#153
post #119

Earlier quoted context omitted.

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".

So you’ll make a two line function to replace a braced block? Seems kind of unhinged.

It may happen. I guess you agree that most of the times conditional blocks exist they are more than 2 lines.

Re: My agent.md to improve LLM-assisted code quality

#154

The most powerful change I have run into is: "Positive phrasing" as a default, prefer to tell the model what they should do, and why. Not a prohibition on a behavior. When you say "don't do x" you are just pre-seeding the model with "x" and the prohibition mitigates that some, but not as much as never having put "x" in the context in the first place. "Do Y, for these reasons" can be shaped to achieve what you mean by…

[dead]

Re: My agent.md to improve LLM-assisted code quality

#155
post #38

Earlier quoted context omitted.

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.

> 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 experi…

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.

Re: My agent.md to improve LLM-assisted code quality

#156
post #39

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 drawin…

> 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...

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.

Re: My agent.md to improve LLM-assisted code quality

#157

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 drawin…

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.

Re: My agent.md to improve LLM-assisted code quality

#158
post #150

Earlier quoted context omitted.

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.

> 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.

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.

Re: My agent.md to improve LLM-assisted code quality

#159

Earlier quoted context omitted.

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".

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

I don't think changing "don't" to "do not" is what the paper authors had in mind

I 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.

Re: My agent.md to improve LLM-assisted code quality

#160
the author referenced this paper which I thought was really interesting https://arxiv.org/abs/2307.03172 - "Lost in the Middle" - are there any other papers a bit like this that summarise lessons to do with applying llms

I'm not necessarily looking for the latest and greatest - more papers that those in the community have coalesced around providing nice ways of summarising problems or as a good example of a specific area.

Post reply on HN