Write code like a human will maintain it

ScottWRobinson 328 points 283 comments July 10, 2026
unstack.io · View on Hacker News

Discussion Highlights (19 comments)

alexpotato

There is an old quote: "Add comments to your code under the assumption that the next person to maintain it is a homicidal maniac who knows where you live"

cebert

It's interesting that the author didn't mention considering updating their agentic code review prompt to keep an eye out for repetitive/duplicate code.

cyanydeez

AI isnt taking my job. my company is supporting local AI for development. who ever comes after me will have the same hardware and models or better. unless a MBA is put in charge, my boss and predecessors can maintain and build out as needed. bottom up AI use seems a godsend compared to the corporate AI rat race. i setup some slop reporting systems and ensured my boss knows theyre great starting points but serious use requires real time investment.

schnebbau

That sounds like a good idea, but shipping 10x as many features and bugfixes sounds better. I started using AI with the best intentions. Checking everything before committing. Improving output by hand if it didn't quite follow the existing code style guidelines or variables were not named as well as they should be. Or if it did something sloppy or hacky. Now, AI GOES BURRRRRRRRRRRR! If the tests pass it's good to ship. AI can deal with the problems it may create. No problems so far.

dsagent

Very much this. LLMs are not producing code humans can maintain unless you take your time with them and still care about the quality of the output. Maybe someone has the perfect claude.md that solves this problem but I have not seen it.

deadbabe

I absolutely will not write corporate code like humans are maintaining it anymore, because I don’t have any confidence actual humans will be maintaining it. For personal projects, I can trust that I myself will be maintaining things so I still write things like it matters, but I do not extend the trust to others.

bdcravens

Humans have been writing unmaintainable code well before LLMs came along.

carimura

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.

andrewjneumann

Have a bit of a contrarian view on this tl;dr don’t write code for human consumption if you use AI; BUT you have to accept AI coding lock in and change how you work. Funny enough, discussed this yesterday Stop Optimizing Code for Humans https://youtube.com/live/eLn4-XA-KdQ?feature=share

jdw64

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Code for readability. — John F. Woods (1991)

ing33k

And hope it works? I’m pretty sure many people who use AI to write emails or blog posts add "make it sound like a human wrote it" to their prompts. We all know what the result usually looks like. If AI is writing my code, I'd rather have it focus purely on correctness and efficiency than on making the code easy to read. heck! I might even ask it to imitate Arthur Whitney’s style. /s

cadamsdotcom

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: ...” and proceeds to a bullet list of things. Any time I notice something in code review and have to get the agent to fix it.. I throw it on the list! 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. I added “ensure the new things aren’t duplicating code that already exists elsewhere” and it gave me such a surprise - it really truly started planning cleanups! We are just scratching the surface. We have to give tools to our tools so they can use them to be better tools for us.

trjordan

AI is so miserable for this. It's so focused on doing what you ask, it forgets that there's stuff worth doing that you didn't ask for, like defining reasonable abstractions. Getting away from stuff like this is exactly why I want to use AI. When I say "implement this for idle but active users," I _want_it to define isUserActiveIdle() and stuff these 4 conditionals in it. Having to check the generated code for stuff like this undoes, like .... all the benefit of using AI. AI makes all these little decisions for us. I can about some of these decisions. I just want to notice when it's doing this without having to make my eyes bleed reading 10k lines of generated code a day.

francisofascii

Before LLMs we didn't have time for code quality. LLMs make our jobs faster, so now we have time to dedicate to code quality, right?

DCKing

I run various forms of workflows to run dedicated QA, code review (of various flavors) simplification and text simplification agents. Especially the simplification goes a long way to remove dumb padding, duplication and efficiency. Dedicated docs/comment simplification is also becoming more and more necessary on recent models. For things like feature development in my workflow, the majority of time the agents run and tokens spent is critiquing the code from various perspectives and it's not close. Of course, this doesn't solve the overall issue that agents don't write code like you and still requires a lot of human attention in planning and code review out to clean up leftover issues, and e.g. challenge bad assumptions about architecture and real-world context. A human is still very much needed to cull the slop (or, more gratuitously: align the agent). But IME it does help avoid a lot of pitfalls and makes the code high quality a lot more quickly.

wxw

The key idea here is that your codebase is context that will be used for future changes. And context determines the model’s output, so it’s still worth having a well-designed codebase. Easier said than done to be honest, especially if there are many people (and their agents) pushing code. It’s hard to keep up these days.

phaser

The first line of my AGENTS.md is: You are an engineer who writes code for *human brains, not machines*. Taken from: https://github.com/zakirullin/cognitive-load/blob/main/READM...

exabrial

What I'm seeing is the organizations that had written code standards: * define the software layers, their function, and the max depth allowed * establish a corp code formatter for each language, along with a process to PR it * establish a business vocabulary and what the terms mean * establish a data dictionary, make it part of the database schema/table/col comments Are far more successful with LLMs. You _should_ have been doing this years ago, but with LLMs its a super power.

esafak

Just run weekly cron job to assess code quality and highlight candidates for refactoring. In addition to doing the same in each PR, of course, but things can get through.

Semantic search powered by Rivestack pgvector
14,015 stories · 131,331 chunks indexed