Live data from Hacker News

My agent.md to improve LLM-assisted code quality

fabiensanglard.net

111–120 of 200 posts

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

#111

Earlier quoted context omitted.

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

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.

You could run the script mechanically against the diff (assuming you use version control). No need to rely on the agent.

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

#112

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…

[deleted]

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

#113
post #38

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…

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.

Mad props to you for that. Smart.

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

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

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

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.

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

#117
post #93

Earlier quoted context omitted.

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…

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.

[flagged]

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

#118
"When writing something intended for human consumption, (comment, commit message, reply to prompt) use as few words as possible. Pick every word meticulously to reduce the volume to a strict minimum. Be down to the point. Less is more."

The irony in this first paragraph using many words and many ways to convey the same message about succintness. But this file is not for human consumtion so different rules should (still?) apply.

I find myself doing this in prompts, I guess it is a way of adding more weight to parts of the context we consider need emphasis, and shows a lack of trust in the llm's abilities to get the message if it is mentioned once.

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

#119

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…

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.

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

#120

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.

Post reply on HN