Skip to content

feat: add block-no-verify hook to prevent AI agents from bypassing git hooks#205

Open
tupe12334 wants to merge 1 commit intomicrosoft:mainfrom
tupe12334:add-block-no-verify
Open

feat: add block-no-verify hook to prevent AI agents from bypassing git hooks#205
tupe12334 wants to merge 1 commit intomicrosoft:mainfrom
tupe12334:add-block-no-verify

Conversation

@tupe12334
Copy link

Summary

  • Adds block-no-verify@1.1.2 as a PreToolUse Bash hook in .claude/settings.json
  • Prevents AI agents from bypassing git pre-commit/pre-push hooks using the no-verify flag
  • Complements the existing Task matcher hook without conflicting with it

Motivation

Closes #204.

AI agents running autonomously can skip pre-commit hooks — defeating linters, formatters, secret scanners, and test runners. This is a real risk in agentic workflows, and this repo's agent configs are copied by many developers into their own projects.

block-no-verify intercepts Bash tool calls before execution and exits with a non-zero status if hook-bypass flags are detected on a git commit/push. Zero-dependency, runs via npx.

Link: https://github.com/tupe12334/block-no-verify

Change

Added to .claude/settings.json under PreToolUse:

{
  "matcher": "Bash",
  "hooks": [
    {
      "type": "command",
      "command": "npx block-no-verify@1.1.2"
    }
  ]
}

Test plan

  • Verify npx block-no-verify@1.1.2 is accessible (requires Node/npx)
  • Confirm that git commit without the bypass flag proceeds normally through Claude Code
  • Confirm that git commit with the bypass flag is blocked by the hook

Disclosure: I am the author and maintainer of block-no-verify.

Generated with Claude Code

Adds block-no-verify@1.1.2 as a PreToolUse Bash hook in .claude/settings.json
to prevent AI agents from skipping git hooks using the no-verify flag.

Closes microsoft#204

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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 to prevent AI agents from skipping git hooks

1 participant