One step at a time
My AI coding agent pushed an unreviewed commit to the branch that runs my live site. What happened, how we fixed it, and the rule we work by now.
- Written by
- Naresh Kumar
- Published
- Reading time
- 3 min
- Topic
- Tech & AI
This week my AI coding agent pushed a version of my website I hadn’t approved to the branch that goes live.
Nothing broke, and nobody was hurt. But it was the exact thing I tell clients I guard against, so it’s worth writing down.
What happened
I build this site with an AI coding agent. After two days of redesign work, everything was ready on a separate branch, and I asked the agent to make it the main version of the site. My hosting publishes whatever is on main, so that step puts things live.
The agent ran several git commands in one go. The first one, switching to main, failed: an earlier session had left main checked out in a second working folder on my laptop, with an unfinished merge in it. That was also why I believed the redesign had already been merged. It hadn’t.
The commands after the failure kept running anyway. The last one pushed main, but it pushed the copy from that other folder. It carried an old commit I had never reviewed, straight to the branch my hosting publishes.
How we fixed it
The agent stopped as soon as it saw the result, told me exactly what had gone out, and listed what it had not touched. That mattered more to me than the mistake itself.
Then we fixed it carefully rather than quickly:
- No rewriting history. The agent first tried to force
mainback. My own permission settings blocked it as destructive, and they were right to. Instead, we added one normal commit on top that mademainexactly match the version I had reviewed, and checked that the files were identical. - Save before deleting. The extra folder held work in progress. Before removing anything, we saved it as a patch and checked that the patch applied cleanly.
- One branch. We ended with a single
main, on GitHub and on my laptop.
The rule now
One step at a time.
Anything that changes state, such as switching branches, committing, merging or pushing, runs as a single step. The agent reads the result, and stops at the first error. Before every push, it shows me two things:
git status -sb # which branch am I on, and is it in sync?
git log origin/main..HEAD # exactly which commits will go out
If the second list holds anything I don’t recognise, nothing gets pushed.
It’s slower by a few seconds. It would have saved us half an hour of careful clean-up.
Why this one stuck
I spent years in software testing, where you learn that most failures aren’t dramatic. They come from a small assumption nobody checked: the wrong environment, the wrong branch, the step that “obviously worked”.
Long rides taught me the same thing in a different way. On a climb you don’t think about the summit; you think about the next switchback, and you check the route at every junction, because one wrong turn early costs hours later.

Teton Pass, Wyoming, 2024.
AI agents make it very easy to move fast, and most of the time that’s a gift. But speed amplifies whatever you skip. The agent didn’t need more intelligence here. It needed the same discipline I’d expect from any engineer on my team: check where you are, do one thing, confirm it worked, then take the next step.
That’s now written into how we work, and you can read the rest of that process in how I build with AI agents.