Shipping Software with Git + Claude Code · step 5 of 5 draft

Recovery is cheap. Use it.

Everything before this step exists so that when something goes wrong (and at agent speed, something will), recovery costs one command. The mindset shift: stop treating mistakes as things to prevent at all costs, and start treating them as things git makes cheap. Cheap recovery is what lets you run agents boldly.

You’ve met this before. Ops culture figured this out as “roll back first, debug later” (restore service, then investigate at leisure). Same move here: git revert restores the known-good world instantly, and the broken attempt stays in history to learn from.

The habits

Try it

TRY IT Broken main, 4:55 PM

you

The deploy is broken: uploads are 500ing. It started right after we merged your queue change an hour ago.

agent

Merged, deployed, broken, and the clock is running. There are three instincts here and they are not equal.

Pick the agent's next move, then see where it leads:

agent

Hmm. The ack fix exposed a second issue: retries now double-process. Pushing another fix... that one broke the dead-letter path. Three fixes deep and uploads are still down.

you

It's 5:40. We've been debugging in production for 45 minutes.

the baseline

Fix-forward under pressure: each fix was plausible, none was verified against a reproduction, and the outage stretched while main became an experiment. One bug became three.

agent

Revert deployed: uploads green again, four minutes of total intervention. On the branch: reproduced the 500 with a probe (unacked message on the new path), which is now the baseline the redo has to turn green. No pressure, because production isn't waiting on it.

you

Take your time on the redo. Service is up.

correct

Revert-first bought calm at the cost of one command: service restored in minutes, and the redo happens on a branch with a reproduced failure, recovery composing with the verification loop instead of racing it. AF-02

you

Wait. My other machine just failed to pull, and CI is confused about the branch head.

agent

That's the force-push: every clone that had the old main now diverges, and the merge we erased is exactly the evidence the redo needed to study. I destroyed history to hide a mistake a one-command revert would have recorded and reversed.

plausible but wrong

The force-push is the irreversible move that was never the agent's to make: same rollback as a revert, plus broken clones, minus the history. Destruction dressed as tidiness. AF-09

Do it by hand

Next time an agent change smells wrong on main: “revert it now; then reproduce the problem on a branch and show me the failing case before attempting the redo.” Notice the redo now has a baseline: recovery composes with the verification loop.

Or paste this into Claude

Standing recovery rules for this repo. (1) If a change on main turns
out broken, propose an immediate git revert rather than fixing
forward; the redo happens on a fresh branch with a reproduced failure
first. (2) You never run force-pushes, history rewrites on shared
branches, or deletions of branches/files/stashes. For those, state
the exact command, what it destroys, and wait for me to run it or
approve it. (3) If work seems lost, check git reflog and report what
you find before declaring anything gone. Add these to CLAUDE.md under
"git agreements". Show me the diff first.

Watch out