Stop Claude Code from skipping git hooks with --no-verify A developer published a Claude Code PreToolUse hook that blocks `git commit --no-verify` and `git commit -n`, closing a gap left by existing guards against `git push --force` and `git reset --hard`. The Python script parses the Bash tool input, detects the bypass flags while ignoring quoted commit messages, and exits with code 2 to refuse the command so repository hooks still run. The hook is wired into `.claude/settings.json` under PreToolUse, optionally scoped to the Bash matcher. A PreToolUse hook can already block git push --force and git reset --hard . That still leaves a hole: git commit --no-verify or -n skips the hook that would have caught a secret, a red test, or a broken lint. A small PreToolUse hook can refuse that flag so the repo hooks still run. The hook should name the blocked command and exit 2 . Save this as .claude/hooks/block no verify.py and make it executable: python /usr/bin/env python3 import json import re import sys try: event = json.load sys.stdin except json.JSONDecodeError: sys.exit 0 tool = event.get "tool name" or event.get "tool" or "" inp = event.get "tool input" or event.get "input" or {} if tool = "Bash": sys.exit 0 command = str inp.get "command" or "" if not re.search r"\bgit\b", command or not re.search r"\b commit|commit-tree \b", command : sys.exit 0 if re.search r" ^| \s --no-verify \s|=|$ ", command : print "PreToolUse: blocked git commit --no-verify. Let the repo hooks run." sys.exit 2 for token in re.findall r" ?: ^\s\"' +|\" ^\" \"|' ^' ' ", command : if token.startswith "'" or token.startswith '"' or token.startswith "--" : continue if token.startswith "-" and "n" in token 1: : print "PreToolUse: blocked git commit -n. Let the repo hooks run." sys.exit 2 Wire it in .claude/settings.json under PreToolUse with command set to python3 .claude/hooks/block no verify.py . If your settings support a matcher, limit it to Bash . "Don't skip hooks" in CLAUDE.md only works when the model remembers it mid-turn. After a hook fails, the next move is often git commit --no-verify to "just land the change." The PreToolUse hook runs before the shell, so that escape hatch is closed. If a hook is actually broken, fix the hook or run the commit yourself in a terminal — do not let the agent skip it. reset --hard PreToolUse guard so destructive git and hook-skipping are both blocked. -n is treated as --no-verify on git commit . Quoted commit messages are ignored, so git commit -m "do not verify" will not trip the hook. I keep copy-ready Claude Code configs CLAUDE.md templates, slash commands, hooks, permission rules in Vildanden Agent Config . There's a free sample: https://justly-mia-429.rehost.page/ https://justly-mia-429.rehost.page/