Live data from Hacker News

Write code like a human will maintain it

unstack.io

181–190 of 325 posts

Re: Write code like a human will maintain it

#181
post #55

Earlier quoted context omitted.

He just means the development pace has picked up with AI. I've been doing this for 15 years, I love coding manually. However, with AI-assistance I can do projects in 3 days what would take 6 months. It's not vibe coding, everything is controlled, reviewed, understood, refined by me in the end. But still the dev time is magnitudes faster. I would not hire anyone that is adverse to AI. I'm actually happier. With age an…

> I can do projects in 3 days what would take 6 months. The hyperbole on this keeps growing every time I see it. Soon we’ll be having people claiming they can do in 12 seconds what used to take them 17 years. What is never presented is proof. People (and programmers are no exception) are notoriously bad at estimating. We already did studies where people thought they were being faster with LLMs when they were in fact…

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.

Re: Write code like a human will maintain it

#182
post #134

Earlier quoted context omitted.

I usually just say “make sure this code is professional and ready to deliver as a senior engineer” and it usually infers all that stuff you said plus more things as well. I try to give it the goal and let it decide what to do. One thing I usually keep having to point out directly is to remove all “progress tracking” code comments and make sure all comments are appropriate for long term maintenance in the code base. C…

For things the agent forgets to obey often, at least in Claude Code, there are also "output styles" that are more deeply embedded - into a system prompt - and agent is also periodically reminded of them during the session: https://code.claude.com/docs/en/output-styles I haven't used them so far but maybe these would work better than basic instructions for such cases.

didn't know of that. I'll switch it to learning mode at work, wondering how long it's going to last.

Re: Write code like a human will maintain it

#183

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`

I've codified mine into a reusable workflow https://github.com/nothingnesses/agent-scaffold . To be honest, this isn't fool-proof though, since the agents can simply choose to ignore them, so I also like to pair this with deterministic linting and compile time checking.

For a Rust project, I created macros that output compiler errors when documentation and tests are not in a shape I want them to be, like missing function invocations or assertions, which forces the agent to address them, where otherwise they would've just worked around them by adding stupid trivial assertions like `assert_eq!(true, true)`.

That still isn't fool-proof either, but it helps minimise those instances. I'm bullish on the idea of integrating formal methods and model-checking with AI. I think that combo feels like a promising avenue for constraining the stochastic side of AI-generated code with something closer to deterministic verification. Provided you can write correct specs of course!

Re: Write code like a human will maintain it

#184
post #64

I have good results with this prompt after every larger change: Now do a final code check. Is everything tidy and do the components adhere to the principle of separations-of-concerns. Is everything in an understandable and maintainable state? Do we make any assumptions that may not be true anymore? Is any code left over from previous edits or experiments that does not belong into the codebase? Is the documentation st…

I like to also compliment the model on its very fashionable shoes as well, they love the flattery.

Re: Write code like a human will maintain it

#185
I think the biggest conceit here is the expectation that humans will continue to do this task in the medium to long term. This was good advice in the past but when inference is ubiquitous and most code ends up being Claudewritten anyways, there is little point. If you are writing C for NASA/ESA then yes of course. For the 99% of the rest of us, probably not so much in the coming years.

Re: Write code like a human will maintain it

#186
> The next time you ask the LLM for another endpoint with the same access rules, the model won't start from first principles. It'll start from the other four copies already sitting in your repo.

To be honest I'm not sure how true this is. I think it's more that there does seem to be quite a baked-in bias to repeat basic structures and not reuse (much less come up with) abstractions. So where that is the existing pattern it looks like it's keeping with that, when in reality it would often do that either way.

There have been many cases where I've started a piece of work by laying down very rigid abstractions and a few examples of using them, and I explicitly prompt to not only exclusively use the specific abstraction API but also copy the way I've used it. And the (frontier) LLM does neither, it just steams ahead re-implementing things from scratch from bottom up basic structures, partially and often totally ignoring the abstractions.

I don't know exactly why this should be the case but my naive suspicion is that there's just an awful lot of this type of stuff in the masses of training code and the weights just somehow 'know better' how to get results this way, rather than using your more novel abstractions/patterns.

Re: Write code like a human will maintain it

#187
post #181
post #55

Earlier quoted context omitted.

> I can do projects in 3 days what would take 6 months. The hyperbole on this keeps growing every time I see it. Soon we’ll be having people claiming they can do in 12 seconds what used to take them 17 years. What is never presented is proof. People (and programmers are no exception) are notoriously bad at estimating. We already did studies where people thought they were being faster with LLMs when they were in fact…

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.

I'm talking about the scale. This was a large app with 60+ screens, 400+ component ui kit, and very rich features.

And had to work on ios/android/web.

I'd consider myself a pretty fast programmer, and I grind 12 hours at a time, everyday until it's done.

But between all humans it's a rounding error compared to the output of an agent swarm.

For personal projects, I pick and choose how much to use AI. But for work, agents go brrrr.

Re: Write code like a human will maintain it

#188
post #160

Earlier quoted context omitted.

This is what has been frustrating me most lately. Even though I have a rule in my global CLAUDE.md that says: > Only write comments to explain the why when it is not obvious from the code (rationale, gotchas, constraints). Do not comment on the what — well-named code already says it. Do not comment on how a framework works. It still keeps adding these bad comments. When I then ask it to review the comments based on m…

My hypothesis is that Claude is inclined to write so many comments as a way of doing additional thinking

Yeah, it's short form memory or something. Like writing a todo list.
Post reply on HN