Skip to content

block-no-verify over-matches: blocks commits when the flag appears in the commit message body #2107

Description

@baselito

Summary

The block-no-verify PreToolUse hook (wired via the plugin's hooks/hooks.json, currently npx block-no-verify@1.1.2) over-matches: it blocks git commit whenever the literal string --no-verify (or no-verify) appears anywhere in the command string, including inside the commit message body — not just when it is actually passed as a flag.

Impact

Legitimate commits are blocked when their message merely mentions the flag. Real-world examples that get blocked even though no --no-verify flag is passed:

  • A commit documenting the hook itself, or a docs change that explains "don't use --no-verify".
  • Any commit whose body references bypassing git hooks by name.

In a recent session this fired twice on legitimate commits whose message bodies referenced the flag, forcing the message to be reworded before the commit would go through. (Ironically, even a commit message containing the hook's own name, block-no-verify, is blocked because it contains the substring no-verify.)

Reproduction

# No --no-verify flag is passed, yet this is blocked:
git commit -m "docs: explain why we never pass --no-verify"

Result: BLOCKED: --no-verify flag is not allowed with git commit. Git hooks must not be bypassed.

Suggested fix

Tighten the matcher to detect --no-verify (and -n for commit, if covered) only in flag/argument position, not as a substring of the whole command — e.g.:

  • Match the token only when it appears as a standalone argument (word-boundary / argv element), and
  • Exclude content that is part of the commit message (after -m/-F, or inside a heredoc body).

This preserves the safety guarantee (you still can't actually bypass hooks) while removing the false positives on message bodies.

Environment

  • block-no-verify@1.1.2 invoked as a Claude Code PreToolUse Bash hook via the ECC plugin's hooks/hooks.json.
  • Observed on macOS, Claude Code, ECC plugin 1.9.0.

Thanks for ECC — the safety-guard hooks are great; this is just a matcher-scope refinement.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions