nextjs - 💡(How to fix) Fix feat: add block-no-verify PreToolUse hook to protect git hooks [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#91672Fetched 2026-04-08 01:02:35
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
closed ×1commented ×1labeled ×1locked ×1

Fix Action

Solution

Create .claude/settings.json with [email protected] as a PreToolUse Bash hook. It reads tool_input.command from the Claude Code hook stdin payload, detects the hook-bypass flag across all git subcommands, and exits 2 to block.

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [{ "type": "command", "command": "npx [email protected]" }]
      }
    ]
  }
}

The existing .claude/skills are unchanged.


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

Code Example

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [{ "type": "command", "command": "npx [email protected]" }]
      }
    ]
  }
}
RAW_BUFFERClick to expand / collapse

Problem

Claude Code agents can silently bypass git hooks by running git commit with the hook-skip flag. This disables pre-commit, commit-msg, and pre-push hooks — the same hooks that enforce linting, type-checking, and commit message conventions.

Solution

Create .claude/settings.json with [email protected] as a PreToolUse Bash hook. It reads tool_input.command from the Claude Code hook stdin payload, detects the hook-bypass flag across all git subcommands, and exits 2 to block.

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [{ "type": "command", "command": "npx [email protected]" }]
      }
    ]
  }
}

The existing .claude/skills are unchanged.


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

extent analysis

Fix Plan

To prevent Claude Code agents from bypassing git hooks, we will:

  • Create a .claude/settings.json file
  • Install the block-no-verify package as a PreToolUse Bash hook

Steps

  1. Create settings file: Create a new file named settings.json in the .claude directory.
  2. Install block-no-verify: Add the following code to settings.json:
{
  "PreToolUse": ["[email protected]"]
}
  1. Verify installation: Run git commit with the --no-verify flag to test if the hook is blocking the command.

Example Code

To test the hook, you can use the following Bash script:

#!/bin/bash

# Simulate git commit with --no-verify flag
git commit -m "Test commit" --no-verify

If the hook is working correctly, this script should exit with a non-zero status code.

Verification

To verify that the fix worked, check the exit status of the git commit command. If the hook is blocking the command, the exit status should be 2. You can use the following command to check the exit status:

echo $?

If the output is 2, the hook is working correctly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix feat: add block-no-verify PreToolUse hook to protect git hooks [1 comments, 2 participants]