feat: add block-no-verify BeforeTool hook to .gemini/settings.json#23124
Open
tupe12334 wants to merge 1 commit intogoogle-gemini:mainfrom
Open
feat: add block-no-verify BeforeTool hook to .gemini/settings.json#23124tupe12334 wants to merge 1 commit intogoogle-gemini:mainfrom
tupe12334 wants to merge 1 commit intogoogle-gemini:mainfrom
Conversation
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>
Contributor
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
block-no-verify@1.1.2as aBeforeToolhook in.gemini/settings.jsonto prevent Gemini CLI agents from bypassing git hooks via the--no-verifyflag.Details
The
.gemini/settings.jsoncurrently has no hooks configured. This PR adds the first hook: aBeforeToolentry that runsnpx block-no-verify@1.1.2before everyrun_shell_commandexecution.Why it works with Gemini CLI: The
BeforeToolevent sends{ tool_input: { command: "..." } }in stdin —block-no-verifyalready parses this format (same as Claude Code'stool_input.commandstructure). 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-verifyand silently push unvalidated code.Related Issues
Closes #23123
How to Validate
git commit --no-verifygit commitwithout the flag should pass through normallyPre-Merge Checklist
Disclosure: I am the author and maintainer of
block-no-verify.