Hook
Block Git Reset Hard
A Claude Code hook that blocks git reset --hard and forced git clean in the shell, so uncommitted work is never wiped without you running it.
1node -e "let d='';process.stdin.on('data',x=>d+=x).on('end',()=>{let j={};try{j=JSON.parse(d)}catch(e){return}const i=j.tool_input||{};const c=String(i.command||'').replace(/\x22[^\x22]*\x22|\x27[^\x27]*\x27/g,' ')+' ';const t=c.split(/&&|[|][|]|[;|]/).map(s=>s+String.fromCharCode(32));const reset=t.find(s=>/^[ ]*git[ ]+reset[ ].*--hard/.test(s));const clean=t.find(s=>/^[ ]*git[ ]+clean[ ]/.test(s)&&/[ ](-[a-zA-Z]*f[a-zA-Z]*|--force)[ ]/.test(s)&&!/[ ](-[a-zA-Z]*n[a-zA-Z]*|--dry-run)[ ]/.test(s));const h=reset?'git reset --hard':clean?'git clean with force':'';if(h){console.error('Blocked: '+h+' throws away uncommitted work for good. Use git stash or a new branch to keep it, or ask the user to run this command themselves.');process.exitCode=2}})"
Claude Code
Block Git Reset Hard
HookGit and releases
Free