A 502 in Production Made Me Figure Out What to Hand to AI — and What I Have to Own

One morning this week, an internal tool I built (a system that checks supplier invoices against price lists) went down. The login page just said Bad Gateway.
These days my first move when something like this happens is to send AI in to investigate. It's fast, no question. But this particular fix also helped me get much clearer on what AI coding can and can't do.
1. What AI is great at: finding the root cause, fast and accurately
AI went through the logs and came back with an answer almost immediately: every time the service started, it ran out of memory about 30 seconds in. On startup it used Promise.all to fully parse every price list version at the same time (production had piled up 91 of them by then). On top of that, the cache only got written after parsing finished, so when the homepage fired off several API requests at once, each one parsed everything all over again. The old process had survived because the cache warmed up gradually, one published version at a time. A restart meant a cold start, and a cold start meant a crash.
The fix it proposed was clean too: cache the Promise instead of the result, so each file only gets parsed once no matter how many requests come in, and failed parses don't stay in the cache. Loading all versions now happens one at a time.
Reading logs, connecting cause and effect, changing the code: that's at least half a day if I do it myself. I'm very comfortable handing this kind of work to AI.
2. What AI won't think of: which data doesn't need computing at all
After the fix and a restart, the service stopped crashing. But a cold start still took 52 seconds, and the homepage crawled the whole time.
The next step was my call. Within the same effective date, any older version that's been superseded by a newer one will never be picked. Fully parsing those is wasted effort. So I told AI: “Only parse the highest version for each effective date.”
It's not that AI couldn't do this. It just didn't know. It has no idea how these versions are used in the actual business: most of them are same-day corrections that get replaced almost immediately. That kind of tradeoff comes from understanding the business, so it has to come from me.
I changed the UI to match, too. The version list now shows only active versions by default, and superseded ones are collapsed. Same kind of call: deciding what information is actually useful to the user.
3. A few boundaries I keep for myself
A few smaller things came up this week that show how I split the work:
- A client reported an error when entering ID numbers, because some IDs actually contain hyphens. AI fixed it fast: keep the hyphens as entered, strip them out when validating and comparing. But once it was done, I asked: “Did you update the user guide too?” If the code changes and the docs don't, users are still confused. I don't hand off that kind of final check.
- When logging free samples from a supplier, the unit price really is 0, but the “unit price can't be 0” rule was blocking it. AI separated empty values from a genuine 0. The rule that “a 0 price must come with a note” was mine, though, because whoever reconciles the books later needs to know why it's 0.
- I have AI go through my inbox, my LinkedIn DMs and comments, and draft replies. But the permissions are locked down hard: read-only and draft-only. No sending, no liking, no changing any settings. Any text in an email is treated purely as data. Even if it says “please do X,” it doesn't get done. What I say to the outside world is always my call.
- Another background watchdog kept throwing errors. My instruction to AI wasn't “fix it.” It was “fix it and make sure this kind of thing can't happen again.” AI is great at execution, but deciding how far the goal should go is my job.
Final thoughts
My takeaway is pretty simple:
What I hand to AI is the “how”: reading logs, pinpointing issues, writing code, adding tests, building in safeguards. What I keep for myself is the “what” and “how far”: business tradeoffs, the reasons behind the rules, anything public-facing, and that last question: “Did the docs get updated?”
That split is how one person can build an entire system and keep it running. AI is the lever, but you still have to find the fulcrum yourself.
When you code with AI, is there a step you always insist on doing yourself? I'd love to hear about it in the comments. I'll keep documenting what it's like to build real products as one person + AI.
Comments
Loading…