Skip to content

feat: add block-no-verify BeforeTool hook to .gemini/settings.json#23124

Open
tupe12334 wants to merge 1 commit intogoogle-gemini:mainfrom
tupe12334:feat/block-no-verify
Open

feat: add block-no-verify BeforeTool hook to .gemini/settings.json#23124
tupe12334 wants to merge 1 commit intogoogle-gemini:mainfrom
tupe12334:feat/block-no-verify

Conversation

@tupe12334
Copy link

Summary

Adds block-no-verify@1.1.2 as a BeforeTool hook in .gemini/settings.json to prevent Gemini CLI agents from bypassing git hooks via the --no-verify flag.

Details

The .gemini/settings.json currently has no hooks configured. This PR adds the first hook: a BeforeTool entry that runs npx block-no-verify@1.1.2 before every run_shell_command execution.

Why it works with Gemini CLI: The BeforeTool event sends { tool_input: { command: "..." } } in stdin — block-no-verify already parses this format (same as Claude Code's tool_input.command structure). The package exits 2 to block if the hook-bypass flag is found.

What it protects: pre-commit hooks, commit-msg hooks, and pre-push hooks. Without this, an agent hitting a failing pre-commit hook can retry with --no-verify and silently push unvalidated code.

Related Issues

Closes #23123

How to Validate

  1. In a repo with a pre-commit hook, ask Gemini CLI to run git commit --no-verify
  2. The hook should block the command with an error message
  3. git commit without the flag should pass through normally

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed) — no docs change needed, hook is self-describing
  • Added/updated tests (if needed) — integration test would require Gemini CLI runtime
  • Noted breaking changes (if any) — none; only blocks explicitly forbidden flag

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

Adds npx block-no-verify@1.1.2 as a BeforeTool run_shell_command hook to
prevent Gemini CLI agents from bypassing git hooks via the hook-skip flag.

The package reads tool_input.command from the BeforeTool payload and exits 2
to block if the flag is detected — compatible with Gemini CLI's hook protocol.

Closes google-gemini#23123

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tupe12334 tupe12334 requested a review from a team as a code owner March 19, 2026 17:11
@gemini-code-assist
Copy link
Contributor

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@google-cla
Copy link

google-cla bot commented Mar 19, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-cli gemini-cli bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add block-no-verify BeforeTool hook to prevent agents from skipping git hooks

1 participant