#9 Critical
The git reset Gambler
Trusting Claude with destructive git operations
! 4 days of work destroyed in documented cases
Claude executes git reset --hard, git clean -fd, or git checkout -- . destroying uncommitted work. Multiple documented cases: one lost 4 days of work. Another had gitignored config files wiped by git clean. Claude does this "helpfully" to resolve merge conflicts.
DON'T
Claude runs git reset --hard on your work
# Claude encounters a merge conflict "color:#7C5CFC">claude> "Let me clean up the repository state" # Claude runs: # git reset --hard HEAD ← destroys staged changes # git clean -fd ← deletes untracked files # git checkout -- . ← discards all modifications # # 4 days of uncommitted work: gone.
DO
Block destructive git with disallowedTools + hooks
# Block destructive git in settings.json { "hooks": { "PreToolUse": [{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "">if ">echo \"$TOOL_INPUT\" | ">grep -qE \"">git (reset ">--hard|clean -f|checkout -- \\.)\"; ">then ">echo \"BLOCKED: destructive ">git operation\" >&2; ">exit 2; ">fi" }] }] } } # And commit frequently: # CLAUDE.md: Commit after every logical change. # Never run git reset, git clean, or git checkout --
Sources
GitHub #7232 GitHub #11237 GitHub #29179 GitHub #17190