Revert is Not Undo

Revert undoes the data. Reset undoes history. With AI agents committing, that difference becomes a permissions boundary: agents get revert, humans keep reset. We use a Claude Code hook to enforce it.

Agents get revert. Humans keep reset. Here’s why, and a hook that enforces it.

In the 2016 Git course I taught at NASA, there’s a Linus Tor­valds quote I used to read out loud: revert undoes the data changes, but it doesn’t undo his­to­ry. Back then that was a pre­ci­sion point. Know which tool you’re reach­ing for. Now that AI agents run git com­mands, it’s a per­mis­sions question.

In this episode I show revert and reset side by side on a real branch, includ­ing what git reset --hard does to uncom­mit­ted work and how reflog gets it back. Then I turn the con­clu­sion into code: a Claude Code Pre­Too­lUse hook that blocks his­to­ry-rewrit­ing and work-destroy­ing git com­mands before they run, and tells the agent what to do instead.

The demo is hon­est about how agents actu­al­ly behave. With a CLAUDE.md instruc­tion in place, the agent usu­al­ly picks revert on its own. So I remove the instruc­tion, start a fresh ses­sion, give it the same prompt, and let the hook catch what the sug­ges­tion no longer pre­vents. One time in twen­ty is a fine fail­ure rate for a sug­ges­tion and a ter­ri­ble one for a guardrail.

Transcript

Premium

Follow along with the full transcript

Search every word, click any line to jump to that moment, and read along as you watch — a CraftQuest Premium feature.

Sign up for Premium
Topic
Instructor
Level
Intermediate
Date Published
September 21, 2026