Live data from Hacker News

My agent.md to improve LLM-assisted code quality

fabiensanglard.net

121–130 of 200 posts

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

#121

Just this one line in AGENTS.md has given better results to reduce if not eliminate verbosity and grandeur. **Always use ASD-STE100 Simplified Technical English Disclaimer: I saw this listed in some other HN post that I can' locate right away.

If we alter the way LLMs talk, will it noticeably affect the quality of code it produces?

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

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

I like long function names as long as they're still explanatory and not distracting.

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

#123

Earlier quoted context omitted.

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.

I've reached that point as well. Is there a preferred model and prompt you use for that?

[flagged]

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

#124

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…

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.

> expecting great code from the agents

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

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

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

How do you stop LLMs from making comments? In my experience, LLMs treat requirements for code output as suggestions

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.

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

#126

Earlier quoted context omitted.

I would never tell an agent to write "what does the code do" comments. Their default comments are already way too fluffy.

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.

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?

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

#128
That's a lot of context for not much content. I ussually start with something like:

- Prefer documentation as code

- Comment why, not what

- Document public APIs

- Readability is paramount

That usually gets me 80% there; rest is covered by the linter.

I'm mostly just missing it explaining previous state too much, especially when making edits to plans, but I have not found good wording for that yet.

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

#130
Would there be any disadvantage to simply having all of the code style stuff in a CONTRIBUTING.md file and the "how to talk to me" stuff in an AGENTS.md file, since code style stuff also applies to human contributions? Similarly, isn't the "how to talk to me" stuff personal and therefore not something that belongs in a repo?
Post reply on HN