Add gpg-pinentry-guard plugin to prevent broken GPG signing prompts#30521
Open
Clovel wants to merge 1 commit intoanthropics:mainfrom
Open
Add gpg-pinentry-guard plugin to prevent broken GPG signing prompts#30521Clovel wants to merge 1 commit intoanthropics:mainfrom
Clovel wants to merge 1 commit intoanthropics:mainfrom
Conversation
PreToolUse hook plugin that intercepts git commands which would trigger GPG signing with a terminal-based pinentry (pinentry-curses, pinentry-tty). Claude Code's Ink renderer holds exclusive control of the terminal's keyboard input. When pinentry opens /dev/tty to read the passphrase, keystrokes are captured by the Ink renderer instead, causing "gpg: signing failed: No passphrase given". The hook detects this by checking: - Whether the command triggers GPG signing (commit, tag, merge) - Whether signing is enabled via git config or explicit flags - Whether the pinentry is terminal-based vs GUI - Whether the passphrase is already cached in gpg-agent When a broken prompt would occur, the hook blocks the command (exit 2) with actionable guidance: cache passphrase, use --no-gpg-sign, switch to GUI pinentry, or increase cache timeout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
620d925 to
41afa99
Compare
This was referenced Mar 4, 2026
Author
|
Any news from any maintainers ? |
5 tasks
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 a
gpg-pinentry-guardplugin — a PreToolUse hook that prevents broken GPG pinentry prompts during git commits.Fixes #30539.
The Problem
When
commit.gpgsign=trueis enabled and the passphrase is not cached,git committriggerspinentry-curseswhich cannot read keyboard input because Claude Code's Ink renderer holds exclusive control of the terminal. The commit fails withgpg: signing failed: No passphrase given.What This Plugin Does
A Bash PreToolUse hook that detects when a git command would trigger a broken terminal pinentry and blocks it early with actionable guidance.
Detection pipeline:
commit,tag,merge)commit.gpgsign,tag.gpgsign,merge.gpgsign, or-S/-sflags)--no-gpg-signalready present? → allowgpg-agent? → allow (no pinentry needed)Files Changed
Test Results
git status,git pushgit commit --no-gpg-signgit commit -m "test"(gpgsign=true, uncached)git tag -s v1.0git add && git commit(compound)GPG_TTY=... git commit(env prefix)git -C /path commit(flag prefix)/usr/bin/git commit(full path)git --no-pager commit(extra flags)(git commit)(subshell)-e(printf safety)16/16 passing.
🤖 Generated with Claude Code