Live data from Hacker News

Write code like a human will maintain it

unstack.io

311–320 of 325 posts

Re: Write code like a human will maintain it

#311

Earlier quoted context omitted.

Run it in a Docker container and give readonly access to the .git folder. This way the agent can read git logs (this is very useful) but cannot commit directly (I don't see any value in this).

If I’m going to be responsible for the code that Claude writes on my behalf, I’m also going to take full responsibility for the moment that it is added to the project history, so I’m going to at least review every line before I allow that to happen. The automatic coauthor line is also just a pet peeve. It’s a tool, not a person. I don’t say that a commit was coauthored by vim - why should Claude get special treatment…

I want it to commit on my behalf, and I don't pay full attention before commits. But I do review every line at the PR level, just as I would if some other human were to submit a PR, and if I find something off, then I ask it to fix it before I will approve the PR.

re: automatic coauthoring -- you can turn that off, but I prefer to turn that on. Commit ownership is something that I want to make clear was not just a human, but a human + AI. Agentic coding does get special treatment from me, because the volition to make changes doesn't come from me. I want that to be clear in the history. The only time I do my own commits (without the coauthor line) is when I make some change myself, without a coding agent.

Re: Write code like a human will maintain it

#312

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 list is like 200 items now. Know what? Agents don’t care that they just got a wall of generic feedback, they happily look into all the bullet points. Yes, yes, there has been a library of information on HN by now about how to use agents effectively. (And I'm grateful for that, because I can keep current and in the loop without feeling enslaved to the new style of development.) None of that is a reason not to do…

> there has been a library of information on HN by now about how to use agents effectively

yes, but where?

Re: Write code like a human will maintain it

#313
post #209

Earlier quoted context omitted.

Most people hyping their AI use mention the short-term gains without taking into account how it affects overall long-term success. We are creatures of convenience.

Considering most teams have only switched to heavy AI use in the past few months, the verdict is still out on this. That said, I've had lots of success using AI to learn, refactor and clean up codebases. I notice another trend were a lot of AI naysayers haven't really spent a ton of time getting intimately familiar with AI.

>I notice another trend were a lot of AI naysayers haven't really spent a ton of time getting intimately familiar with AI.

I don't think that's really true, it's more your feels than anything. I've noticed this thing where everyone that's using AI think nobody else is using AI, or at least not the cool way they are doing it. It's typically nonsense.

I've been using AI for quite a while, personally and professionally, and I can already see the clusterfuck it's causing. I still don't let it work on my important personal projects, but for simple tools and websites, sure. At work we're told to use AI exclusively to code, and it's already causing problems - the AI just endlessly applies bandaid after bandaid and it's turned the code to spaghetti. Nobody even reads the code, the people above just tell us to approve it and ship it. I'm looking for a new job because I already know this isn't going to produce the long-term success they are expecting. All it is doing is making it more expensive to write software, without the knowledge of how the code works, and if you can't already understand how that looks in the future, well... I don't know what to tell you.

Re: Write code like a human will maintain it

#314
post #52

Earlier quoted context omitted.

How did you know you're not stuck at a local optimum where the AI could iterate even faster if you enforced higher quality on what it produced? To make up some hypothetical numbers in order to illustrate with math: if you ship bugfixes 10x faster but then have 11x more bugs you need to fix, that's not a net improvement. Even if it's only 5x more bugs, maybe you could reduce that to 2x if you changed how you worked to…

It’s a new form of development. The thing that the author didn’t state is that to work the code base at all, you must also use these tools and workflows. Manual edits literally aren’t possible. You can’t grok the code growth and the new patterns fast enough to be productive. This does work. I’ve seen it in real products. Nobody has a real mental model of the code flows. But with enough money in Claude credits it does…

[flagged]

Re: Write code like a human will maintain it

#315
post #73

I continually run codebases through different models to have them look for bad code smells like repeated code. That's been pretty effective. You do have to maintain over time or else you end up with a sloppy mess which I can only imagine compounds.

Do you think it matters that it's a different model? Or is it more about the review process and a context reset?

I don't have a scientific answer to this but I'm just assuming a different model, and more specifically, the frontier latest models like Fable/5.6 would catch things the author model might skip over.

Re: Write code like a human will maintain it

#316

I continually run codebases through different models to have them look for bad code smells like repeated code. That's been pretty effective. You do have to maintain over time or else you end up with a sloppy mess which I can only imagine compounds.

What do you think of traditional AST-based static analyzers (like SonarQube, Rubocop, etc.) that catch cyclomatic complexity and code duplication deterministically? You can even put them on the build pipeline, even. No tokens spent at all!

I haven't used them but I'm sure they're good and I'm sure they're even using LLMs themselves now as a non-deterministic pass. For my use cases I'm just trying to keep vendors/costs to a minimum.

Re: Write code like a human will maintain it

#317

Earlier quoted context omitted.

I find myself doing this but then I worry that the slop will just compound and 3, 6, 12 months from now as my services scale I'll have a harder time operating them. Maybe I'm wrong.

The bigger problem is the number of things you don't understand will grow substantially from under your feet, and then you'll slip on it.

that's 100% happening to me right now not just with a specific codebase but with the fun/engineering parts of coding in general.... it makes me sad, slightly concerned, but optimistic that I can build a trillion dollar company with no employees. I'm kidding. Who knows. I'm enjoying building so I guess there's that.

Re: Write code like a human will maintain it

#318

Earlier quoted context omitted.

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…

Run it in a Docker container and give readonly access to the .git folder. This way the agent can read git logs (this is very useful) but cannot commit directly (I don't see any value in this).

I wrote this to do that: https://github.com/deepbluedynamics.com/nemesis8, although I also added `gh` to it so it could do that if it needed to. It can be easily disabled during the container build. Supports at least 8 agent CLIs.

Re: Write code like a human will maintain it

#319
post #209

Earlier quoted context omitted.

Considering most teams have only switched to heavy AI use in the past few months, the verdict is still out on this. That said, I've had lots of success using AI to learn, refactor and clean up codebases. I notice another trend were a lot of AI naysayers haven't really spent a ton of time getting intimately familiar with AI.

>I notice another trend were a lot of AI naysayers haven't really spent a ton of time getting intimately familiar with AI. I don't think that's really true, it's more your feels than anything. I've noticed this thing where everyone that's using AI think nobody else is using AI, or at least not the cool way they are doing it. It's typically nonsense. I've been using AI for quite a while, personally and professionally,…

I'm sorry to hear that's how it's going at your work.

Re: Write code like a human will maintain it

#320

Earlier quoted context omitted.

> My list is like 200 items now. Know what? Agents don’t care that they just got a wall of generic feedback, they happily look into all the bullet points. Yes, yes, there has been a library of information on HN by now about how to use agents effectively. (And I'm grateful for that, because I can keep current and in the loop without feeling enslaved to the new style of development.) None of that is a reason not to do…

> there has been a library of information on HN by now about how to use agents effectively yes, but where ?

In the discussion, mostly. It's been months; so if you find the general topic interesting (as I do) and check HN regularly (as I do) you'll have seen quite a bit that can at least be tried out, or thought about.

Maybe you can get an agent to identify and summarize such threads.

Post reply on HN