Live data from Hacker News

Write code like a human will maintain it

unstack.io

291–300 of 325 posts

Re: Write code like a human will maintain it

#291
I wonder how effective it would be to just put the blog's title as a line in your AGENTS.md...

This is kinda the "this could have been an email" of AI complaints.

As an AI acolyte, I strongly believe that AIs should be being trained for this sort of mode by default, but they tend to be optimized (or at least tested) to solve the single shot benchmarks rather than multi-step stuff that you really need in a long term maintainable project.

There is a https://www.scbench.ai/ SlopCodeBench that checks this and a variety of others. These don't seem to often come up when frontier labs are advertising their new models.

Re: Write code like a human will maintain it

#292

Write yourself a /review command. That is an empty markdown file at `.claude/commands/review.md`. In it, put a checklist of things the agent should look for. When you’re ready to have your agent review the code, type `/review`. The checklist will be examined and it’ll plan out some findings to ask you if you want them fixed. Mine starts with “Enter plan mode. Examine the differences on this branch vs. main. Consider:…

My experience is the more things you add to the list, the worse agents perform (I'm not exactly the first person to notice this) I actually have a pretty simple set of instructions right now and Claude still regularly messes them up. Like, my first instructions are: - Never commit to git without permission. - Never sign commit messages You know what it constantly does? Commits without permissions and signs commit mes…

>and then I ask it

Why? It has no idea why it does what it does…

Re: Write code like a human will maintain it

#293
post #213

Write yourself a /review command. That is an empty markdown file at `.claude/commands/review.md`. In it, put a checklist of things the agent should look for. When you’re ready to have your agent review the code, type `/review`. The checklist will be examined and it’ll plan out some findings to ask you if you want them fixed. Mine starts with “Enter plan mode. Examine the differences on this branch vs. main. Consider:…

I've been finding that they can write surprisingly elegant code, you just have to ask them to. It seems to be kind of like the old generative AI art days where you still had to add "+quality -bad" to the prompt. Failing that they default to the most common style they were trained on. Which, at this point, is mostly code they wrote...

Yes, and, write custom linters for things you want to prevent forever. Have a look at https://github.com/cadamsdotcom/CodeLeash/blob/main/scripts/... for an example (enforced before all commits via https://github.com/cadamsdotcom/CodeLeash/blob/main/.pre-com...)

Basically I got sick of telling the agent to put dynamic imports at the top of the file so I made them into an error that blocks commits.

Now I don’t even need that in the review.md because it can’t make it though to /review.

Re: Write code like a human will maintain it

#294

Write yourself a /review command. That is an empty markdown file at `.claude/commands/review.md`. In it, put a checklist of things the agent should look for. When you’re ready to have your agent review the code, type `/review`. The checklist will be examined and it’ll plan out some findings to ask you if you want them fixed. Mine starts with “Enter plan mode. Examine the differences on this branch vs. main. Consider:…

Can you share your list? I am curious what does it contain, for me a lot of times its a back and forth with agent until it "looks good to my eyes and taste", but haven't written any such list yet, because it is context dependant, in some projects I forgive minor issues, or allow magical numbers, but in other projects I force agent to use constants with meaningful names `SECONDS_IN_A_DAY = 24 * 60 * 60`

Somewhat out of date (it’s grown a lot!)

https://github.com/cadamsdotcom/CodeLeash/blob/main/.claude/...

Re: Write code like a human will maintain it

#295

Earlier quoted context omitted.

I’m not a Claude code user, is there really no way to get it to not commit to git other than “asking it nicely in a prompt”? I thought there was some sort of permission system?

There are options, but they're not great. I could ban it from using git, but having access to git logs helps it do work so I don't want to go that far. I could probably ban the subcommand, but as a convenience I do like to be able to ask it to make a commit. (I'm not super attached to this, I frequently commit myself just to avoid these issues). It does tend to write good commit messages, so sometimes I ask it to gen…

Deny:

Bash(“git * commit *”)

And for bonus points you can have the agent write you a Pre Bash hook. Tell it to make the hook look in the command for anything that’s a git commit. The vaguer your instructions here the better. Let it pull some crazy regex out of its hat. You’ll be impressed.

Re: Write code like a human will maintain it

#297
post #281
post #181

Earlier quoted context omitted.

That one does sound like hyperbole, or maybe he just works slowly as a human? People are different. Likewise, I think they're having wildly different results. Look at how differently humans drive vehicles, and realize they're doing the same with compute. Some people probably are working at light speed, and some people are actually slower like in the study.

> Look at how differently humans drive vehicles, and realize they're doing the same with compute. I’m not sure that comparison is evoking the image you intended. Hands down the best driver I know—the one I’m sure won’t get me car sick, won’t ever have me worrying for my safety, the most fuel efficient, the smoothest rider—is by no means the fastest but the most thoughtful and methodical. I don’t care how fast you dev…

Sure, I agree. And I get that result--slow and steady--out of the LLM when I use it.

Re: Write code like a human will maintain it

#298

Earlier quoted context omitted.

My experience is the more things you add to the list, the worse agents perform (I'm not exactly the first person to notice this) I actually have a pretty simple set of instructions right now and Claude still regularly messes them up. Like, my first instructions are: - Never commit to git without permission. - Never sign commit messages You know what it constantly does? Commits without permissions and signs commit mes…

I have dedicated checkpoint and commit skills. Checkpoint has it run my review skill, then run my commit skill. The commit skill just asks it to suggest commit messages for my review. Having these skills in place has resulted in claude preferring to use the commit skill instead of committing on its own, and suggesting commit messages to me before actually doing the commit.

Why are you having it commit or write commit messages unless you have no idea what it’s doing?

Re: Write code like a human will maintain it

#299

Earlier quoted context omitted.

And as time goes on?

You get promoted and let other people deal with the mess. The truth is that no one in management cares about your perfect code, they only care about the projects you deliver, the features you push out and the meeting KPIS.. Your customers don't care about your perfect abstractions either, they just want the button to work when it's clicked. You can always argue about maintenance, but who is going to listen? By the ti…

> The truth is that no one in management cares about your perfect code, they only care about the projects you deliver, the features you push out and the meeting KPIS.. Your customers don't care about your perfect abstractions either, they just want the button to work when it's clicked.

I don't think most developers care about perfect code (if such thing exists). What they care about is maintainability, so that the project is delivered on time, features keep getting pushed and KPIS can be actually met. And that the customers have a working button.

Instead we got projects that keeps being dragged around (until it's put out of its misery), half baked features, and KPIs that are twisted until they're barely looks like what was stated at the beginning of the quarter. And the customer is complaining about another button breaking.

What I do is never ask for permission, because that's an engineering concern, not a product/management one. I just tidy the code I work on, one step at a time.

Re: Write code like a human will maintain it

#300
post #298

Earlier quoted context omitted.

I have dedicated checkpoint and commit skills. Checkpoint has it run my review skill, then run my commit skill. The commit skill just asks it to suggest commit messages for my review. Having these skills in place has resulted in claude preferring to use the commit skill instead of committing on its own, and suggesting commit messages to me before actually doing the commit.

Why are you having it commit or write commit messages unless you have no idea what it’s doing?

Who likes writing commit messages? In the abstract, perfectly spherical developer mindset, I'd spend hours writing the best commit message to go with the most elegant and perfect, beautiful code that I'm comitting, but the real world with meetings and life demands is greasier and grimer than that. Letting the LLM start off with the commit messages for me to edit with additional details has been a boon to productivity. Staring at an empty $EDITOR my brain goes blank, but with a framework of what's going on, I find the details for me to add flow more easily.
Post reply on HN