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 Torvalds quote I used to read out loud: revert undoes the data changes, but it doesn’t undo history. Back then that was a precision point. Know which tool you’re reaching for. Now that AI agents run git commands, it’s a permissions question.
In this episode I show revert and reset side by side on a real branch, including what git reset --hard does to uncommitted work and how reflog gets it back. Then I turn the conclusion into code: a Claude Code PreToolUse hook that blocks history-rewriting and work-destroying git commands before they run, and tells the agent what to do instead.
The demo is honest about how agents actually behave. With a CLAUDE.md instruction in place, the agent usually picks revert on its own. So I remove the instruction, start a fresh session, give it the same prompt, and let the hook catch what the suggestion no longer prevents. One time in twenty is a fine failure rate for a suggestion and a terrible one for a guardrail.
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