feat: add block-no-verify hook to prevent AI agents from bypassing git hooks#205
Open
tupe12334 wants to merge 1 commit intomicrosoft:mainfrom
Open
feat: add block-no-verify hook to prevent AI agents from bypassing git hooks#205tupe12334 wants to merge 1 commit intomicrosoft:mainfrom
tupe12334 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
block-no-verify@1.1.2as aPreToolUseBashhook in.claude/settings.jsonTaskmatcher hook without conflicting with itMotivation
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-verifyinterceptsBashtool calls before execution and exits with a non-zero status if hook-bypass flags are detected on a git commit/push. Zero-dependency, runs vianpx.Link: https://github.com/tupe12334/block-no-verify
Change
Added to
.claude/settings.jsonunderPreToolUse:{ "matcher": "Bash", "hooks": [ { "type": "command", "command": "npx block-no-verify@1.1.2" } ] }Test plan
npx block-no-verify@1.1.2is accessible (requires Node/npx)git commitwithout the bypass flag proceeds normally through Claude Codegit commitwith the bypass flag is blocked by the hookDisclosure: I am the author and maintainer of
block-no-verify.Generated with Claude Code