pytorch - ✅(Solved) Fix Add block-no-verify PreToolUse hook to .claude/settings.json [1 pull requests, 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
pytorch/pytorch#177880Fetched 2026-04-08 01:03:08
View on GitHub
Comments
1
Participants
2
Timeline
24
Reactions
0
Author
Participants
Timeline (top)
subscribed ×12labeled ×4mentioned ×2added_to_project_v2 ×1

Fix Action

Fixed

PR fix notes

PR #177881: Add block-no-verify PreToolUse hook to .claude/settings.json

Description (problem / solution / changelog)

Summary

Creates .claude/settings.json with [email protected] as a PreToolUse Bash hook to prevent Claude Code agents from bypassing git hooks via the hook-skip flag.

Details

When an agent runs git commit or git push with the hook-bypass flag, it silently disables pre-commit, commit-msg, and pre-push hooks. block-no-verify 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. The existing .claude/skills is unchanged.

Closes #177880


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

Changed files

  • .claude/settings.json (added, +10/-0)

Code Example

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

Feature: Add block-no-verify PreToolUse hook to .claude/settings.json

PyTorch has .claude/skills committed — but no .claude/settings.json. There's no enforcement against agents bypassing git hooks via the hook-skip flag.

When Claude Code agents run git commit or git push with the hook-bypass flag, it silently skips pre-commit hooks, commit-msg validation, and pre-push test suites.

Proposed fix

Create .claude/settings.json with [email protected] (github.com/tupe12334/block-no-verify) as a PreToolUse Bash hook:

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

The package reads tool_input.command from the Claude Code hook stdin, detects the hook-bypass flag across all git subcommands, and exits 2 to block. No custom scripts needed.


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

cc @seemethere @malfet @pytorch/pytorch-dev-infra

extent analysis

Fix Plan

To prevent agents from bypassing git hooks, we will create a .claude/settings.json file with a PreToolUse hook using the block-no-verify package.

Step-by-Step Solution:

  • Create a new file named .claude/settings.json in the root of your repository.
  • Add the following JSON configuration to the file:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [{ "type": "command", "command": "npx [email protected]" }]
      }
    ]
  }
}
  • Commit the changes to your repository.

Verification

To verify that the fix worked, try running a git command with the hook-bypass flag, such as git commit -m "test" --no-verify. The block-no-verify hook should block the command and exit with a non-zero status code.

Extra Tips

  • Make sure to keep the block-no-verify package up to date to ensure you have the latest features and security patches.
  • If you encounter any issues with the hook, check the block-no-verify documentation or open an issue on the GitHub repository for support.

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

pytorch - ✅(Solved) Fix Add block-no-verify PreToolUse hook to .claude/settings.json [1 pull requests, 1 comments, 2 participants]