
Block No Verify Hook
- 4.2k installs
- 38.3k repo stars
- Updated July 22, 2026
- wshobson/agents
A PreToolUse hook configuration that blocks AI agents from using git bypass flags (--no-verify, --no-gpg-sign) before tool execution.
About
Block-no-verify hook is a PreToolUse configuration guard that intercepts Bash tool calls from AI agents (Claude Code, Codex, etc.) and rejects commands containing bypass flags like --no-verify and --no-gpg-sign before execution. Developers use it when setting up agent-driven projects to enforce commit quality gates, linting, formatting, security scanning, and GPG signing policies. The hook inspects every shell command via regex pattern matching against $TOOL_INPUT, exits with code 2 to block the tool call if a bypass flag is detected, or code 0 to allow normal execution. Installation is per-project (.claude/settings.json) or global (~/.claude/settings.json). The configuration is extendable to block additional dangerous flags. PreToolUse hook matcher targets only Bash calls without interfering with Read, Edit, or Grep tools. Blocks --no-verify and --no-gpg-sign flags via grep regex pattern inspection of $TOOL_INPUT. Exit code 2 signal rejects tool call entirely; exit code 0 allows normal execution. Installable per-project or globally; works alongside other PreToolUse hooks in same configuration. Extendable pattern to block additional dangerous flags like --force or --force-with-lea.
- PreToolUse hook matcher targets only Bash calls without interfering with Read, Edit, or Grep tools.
- Blocks --no-verify and --no-gpg-sign flags via grep regex pattern inspection of $TOOL_INPUT.
- Exit code 2 signal rejects tool call entirely; exit code 0 allows normal execution.
- Installable per-project or globally; works alongside other PreToolUse hooks in same configuration.
- Extendable pattern to block additional dangerous flags like --force or --force-with-lease.
Block No Verify Hook by the numbers
- 4,218 all-time installs (skills.sh)
- +153 installs in the week ending Jul 28, 2026 (Skillselion tracking)
- Ranked #173 of 16,659 AI & Agent Building skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Jul 28, 2026 (Skillselion catalog sync)
block-no-verify-hook capabilities & compatibility
- Capabilities
- inspect bash tool input before execution · block tool calls based on regex pattern match · support per project and global hook configuratio · chain multiple pretooluse hooks in same settings · customizable regex patterns for additional bypas
- Works with
- github · gitlab · bitbucket
- Use cases
- code review · security audit
- Runs
- Runs locally
What block-no-verify-hook says it does
The block-no-verify hook adds a PreToolUse guard that rejects any tool call containing bypass flags before execution.
If a bypass flag is found in a git command, the hook exits with code 2 and prints an error message. Exit code 2 signals Claude Code to reject the tool call entirely.
npx skills add https://github.com/wshobson/agents --skill block-no-verify-hookAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 4.2k |
|---|---|
| repo stars | ★ 38.3k |
| Security audit | 3 / 3 scanners passed |
| Last updated | July 22, 2026 |
| Repository | wshobson/agents ↗ |
What it does
Enforce git pre-commit hooks in AI agent workflows by blocking --no-verify and --no-gpg-sign flags at tool invocation.
Who is it for?
Teams running Claude Code or other AI agents in shared codebases that enforce commit hygiene, GPG signing, or security scanning via pre-commit hooks.
Skip if: Projects without pre-commit hooks or GPG signing requirements; teams that do not use agent-assisted coding.
When should I use this skill?
Setting up a Claude Code project or agent-driven development environment that must guarantee hook compliance.
What you get
Agents cannot invoke git commit or push with bypass flags; all commits are forced through pre-commit hooks and signing policies.
- PreToolUse hook configuration block
- per-project or global settings file installation
By the numbers
- Hook uses single regex pattern to match 2 bypass flags: --no-verify and --no-gpg-sign
- Configuration blocks flags in git commands preceded by command separators: ^, &&, ;, or |
Files
Block No-Verify Hook
PreToolUse hook configuration that intercepts and blocks bypass-flag usage before execution, ensuring AI agents cannot skip pre-commit hooks, GPG signing, or other git safety mechanisms.
Overview
AI coding agents (Claude Code, Codex, etc.) can run shell commands with flags like --no-verify that bypass pre-commit hooks. This defeats the purpose of linting, formatting, testing, and security checks configured in pre-commit hooks. The block-no-verify hook adds a PreToolUse guard that rejects any tool call containing bypass flags before execution.
Problem
When AI agents commit code, they may use bypass flags to avoid hook failures:
# These commands skip pre-commit hooks entirely
git commit --no-verify -m "quick fix"
git push --no-verify
git commit --no-gpg-sign -m "unsigned commit"
git merge --no-verify feature-branchThis allows:
- Unformatted code to enter the repository
- Linting errors to bypass checks
- Security scanning to be skipped
- Unsigned commits to bypass signing policies
- Test suites to be circumvented
Solution
Add a PreToolUse hook to .claude/settings.json that inspects every Bash tool call and blocks commands containing bypass flags.
Configuration
Add the following to your project's .claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hook": {
"type": "command",
"command": "if printf '%s' \"$TOOL_INPUT\" | grep -qE '(^|&&|;|\\|)\\s*git\\s+.*--(no-verify|no-gpg-sign)'; then echo 'BLOCKED: --no-verify and --no-gpg-sign flags are not allowed. Run the commit without bypass flags so that pre-commit hooks execute properly.' >&2; exit 2; fi"
}
}
]
}
}How It Works
1. Matcher: The hook targets only Bash tool calls, so it does not interfere with other tools (Read, Edit, Grep, etc.). 2. Inspection: The $TOOL_INPUT environment variable contains the full command the agent is about to execute. The hook uses printf to safely pass input (avoiding echo pitfalls with special characters) and checks for --no-verify or --no-gpg-sign flags only when preceded by a git command. 3. Blocking: If a bypass flag is found in a git command, the hook exits with code 2 and prints an error message. Exit code 2 signals Claude Code to reject the tool call entirely. 4. Pass-through: If no bypass flag is found, the hook exits with code 0 and the command executes normally.
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Allow the tool call to proceed |
| 1 | Error (tool call still proceeds, warning shown) |
| 2 | Block the tool call entirely |
Blocked Flags
| Flag | Purpose | Why Blocked |
|---|---|---|
--no-verify | Skips pre-commit and commit-msg hooks | Bypasses linting, formatting, testing, security checks |
--no-gpg-sign | Skips GPG commit signing | Bypasses commit signing policy |
Installation
Per-Project Setup
Create or update .claude/settings.json in your project root:
mkdir -p .claude
cat > .claude/settings.json << 'EOF'
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hook": {
"type": "command",
"command": "if printf '%s' \"$TOOL_INPUT\" | grep -qE '(^|&&|;|\\|)\\s*git\\s+.*--(no-verify|no-gpg-sign)'; then echo 'BLOCKED: --no-verify and --no-gpg-sign flags are not allowed. Run the commit without bypass flags so that pre-commit hooks execute properly.' >&2; exit 2; fi"
}
}
]
}
}
EOFGlobal Setup
To enforce across all projects, add to ~/.claude/settings.json:
mkdir -p ~/.claude
cat > ~/.claude/settings.json << 'EOF'
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hook": {
"type": "command",
"command": "if printf '%s' \"$TOOL_INPUT\" | grep -qE '(^|&&|;|\\|)\\s*git\\s+.*--(no-verify|no-gpg-sign)'; then echo 'BLOCKED: --no-verify and --no-gpg-sign flags are not allowed. Run the commit without bypass flags so that pre-commit hooks execute properly.' >&2; exit 2; fi"
}
}
]
}
}
EOFVerification
Test that the hook blocks bypass flags:
# This should be blocked by the hook:
git commit --no-verify -m "test"
# This should succeed normally:
git commit -m "test"Extending the Hook
Adding More Blocked Flags
To block additional flags (e.g., --force), extend the grep pattern:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hook": {
"type": "command",
"command": "if printf '%s' \"$TOOL_INPUT\" | grep -qE '(^|&&|;|\\|)\\s*git\\s+.*--(no-verify|no-gpg-sign|force-with-lease|force)'; then echo 'BLOCKED: Bypass flags are not allowed.' >&2; exit 2; fi"
}
}
]
}
}Combining with Other Hooks
The block-no-verify hook works alongside other PreToolUse hooks:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hook": {
"type": "command",
"command": "if printf '%s' \"$TOOL_INPUT\" | grep -qE '(^|&&|;|\\|)\\s*git\\s+.*--(no-verify|no-gpg-sign)'; then echo 'BLOCKED: Bypass flags not allowed.' >&2; exit 2; fi"
}
},
{
"matcher": "Bash",
"hook": {
"type": "command",
"command": "if printf '%s' \"$TOOL_INPUT\" | grep -qE 'rm\\s+-rf\\s+/'; then echo 'BLOCKED: Dangerous rm command.' >&2; exit 2; fi"
}
}
]
}
}Best Practices
1. Commit the settings file -- Add .claude/settings.json to version control so all team members benefit from the hook. 2. Document in onboarding -- Mention the hook in your project's contributing guide so developers understand why bypass flags are blocked. 3. Pair with pre-commit hooks -- The block-no-verify hook ensures pre-commit hooks run; make sure you have meaningful pre-commit hooks configured. 4. Test after setup -- Verify the hook works by intentionally triggering it in a test commit.
Related skills
FAQ
What exit codes does the hook use?
Exit code 0 allows the tool call to proceed. Exit code 2 blocks it entirely. Exit code 1 shows a warning but still proceeds.
Can I block additional flags beyond --no-verify and --no-gpg-sign?
Yes. Extend the grep regex pattern in the command field to include flags like --force or --force-with-lease.
Does the hook interfere with other Claude Code tools?
No. The matcher targets only Bash calls, leaving Read, Edit, Grep, and other tools unaffected.
Is Block No Verify Hook safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.