Skip to content

feat: add block-no-verify hook to prevent git hook bypass#203

Closed
tupe12334 wants to merge 1 commit intomicrosoft:mainfrom
tupe12334:feat/block-no-verify-hook
Closed

feat: add block-no-verify hook to prevent git hook bypass#203
tupe12334 wants to merge 1 commit intomicrosoft:mainfrom
tupe12334:feat/block-no-verify-hook

Conversation

@tupe12334
Copy link

Summary

  • Adds block-no-verify@1.1.2 as a PreToolUse hook in .claude/settings.json to block git commands that attempt to bypass hooks
  • Documents the git hook safety policy in Agents.md under a new "Git Hook Safety" section

Problem

The current .claude/settings.json has PreToolUse hooks for Task — but nothing prevents an agent from using the bypass flags on git commit or git push, which silently skips all pre-commit/pre-push hooks (tests, linting, secret scanning, etc).

Solution

block-no-verify is a purpose-built hook that reads Claude Code's PreToolUse stdin payload and exits non-zero if it detects:

  • The --no-verify flag on any git subcommand
  • The -n shorthand on git commit
  • A core.hooksPath override pointing to /dev/null

Zero configuration — just add it as a Bash PreToolUse hook.

Changes

.claude/settings.json  — add block-no-verify Bash PreToolUse hook
Agents.md              — add Git Hook Safety section

Test plan

  • Run git commit normally — should pass through
  • Run git commit with bypass flags — should be blocked with a clear message
  • Verify Agents.md renders cleanly in GitHub

Closes #202

Adds block-no-verify@1.1.2 as a PreToolUse hook in .claude/settings.json
to detect and block attempts to bypass git hooks. Also documents the
git hook safety policy in Agents.md.

Closes #202
@tupe12334 tupe12334 closed this by deleting the head repository Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add block-no-verify hook to prevent agents from bypassing git hooks

1 participant