Live data from Hacker News

My agent.md to improve LLM-assisted code quality

fabiensanglard.net

141–150 of 200 posts

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

#141
post #132

Earlier quoted context omitted.

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

LLM comments for code are almost unfailingly completely redundant or impenetrably verbose bordering on word salad.

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.

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

#143
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…

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.

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

#145

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

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 :)

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

#146
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…

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.

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

#147
post #132

Earlier quoted context omitted.

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

LLM comments for code are almost unfailingly completely redundant or impenetrably verbose bordering on word salad.

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.

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

#148
post #88

> - Keep function names short. Less than 30 characters. Recently I asked GPT to port a browser game to Rust. It voluntered this gem: draw_image_with_html_image_element_and_sw_and_sh_and_dx_and_dy_and_dw_and_dh(...) I thought it was smoking some good stuff, but it turned out, that is actually the name of the function! https://docs.rs/web-sys/latest/web_sys/struct.CanvasRenderin...

This is an unfortunate side effect of bridging an API from a language that supports function overloading, into a language that does not

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

#149
post #88

> - Keep function names short. Less than 30 characters. Recently I asked GPT to port a browser game to Rust. It voluntered this gem: draw_image_with_html_image_element_and_sw_and_sh_and_dx_and_dy_and_dw_and_dh(...) I thought it was smoking some good stuff, but it turned out, that is actually the name of the function! https://docs.rs/web-sys/latest/web_sys/struct.CanvasRenderin...

They laughed at objective-c back then, now the shoe's on the other foot

So much this. DoThisWithThatAndThatAndThis is a objective c convention and I love it so much that I use it everywhere.

Although a bit of taste is required to keep code legible and pleasant.

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

#150

Earlier quoted context omitted.

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

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.

Post reply on HN