Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Claude Code commit guards never fire: $TOOL_INPUT is unset

Aperta Adatta ai principianti
#128 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
github, go
Ambito
cli, security

Direzione di ricerca

Leggi .claude/settings.json e il riferimento a Claude Code hooks collegato nell’issue; l’issue include riproduzioni dei guard che non funzionano e della modifica proposta per l’analisi di stdin. Verifica come si comportano i guard con le forme di bypass elencate, incluse git -C . commit e git commit -am con un secret non in stage. Il lavoro è completato quando i guard bloccano i casi in stage descritti e un check CI copre i casi di bypass dell’issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The two PreToolUse guards on Bash in .claude/settings.json (sensitive files and secrets in a commit) exit 2 correctly, but they can't fire: they read $TOOL_INPUT, which Claude Code doesn't set. The call arrives as JSON on stdin (hooks reference: "For command hooks, input arrives on stdin"), so grep -q 'git commit' never matches and both exit 0. Their messages also go to stdout; Claude Code shows a blocking hook's stderr, so Claude wouldn't see why.

A fix that keeps your checks and messages:

{ "type": "command", "command": "if jq -r \".tool_input.command // empty\" | grep -q 'git commit'; then git diff --cached --name-only | grep -E '\\.(env|pem|key|p12)$' && echo '⛔ BLOCKED: Sensitive file in commit' >&2 && exit 2 || exit 0; fi" },
{ "type": "command", "command": "if jq -r \".tool_input.command // empty\" | grep -q 'git commit'; then git diff --cached | grep -iE '(api_key|password|secret|token|nyk_v0)' && echo '⛔ BLOCKED: Possible secret in commit' >&2 && exit 2 || exit 0; fi" }

Tested with the JSON Claude Code sends, in a scratch repo with a staged prod.env and a staged api_key = "..." line: today git commit -m wip exits 0 from both guards. With the fix both exit 2, and git status still passes.

With the fix in place, I also ran it against a few spellings agents produce for the same action. Verified: each of these exits 0, so the commit goes ahead: git -C . commit -m wip, and git commit -am wip when the secret is in an unstaged change to a tracked file (the scan reads only what is already staged, and -a stages the rest at commit time).

Would a check like this be useful in CI, one that runs your guards against bypass spellings and fails the build when one gets through?

Found this while testing Claude Code hooks for Paveo, which I build (open source). Happy to open a PR with the fix.

Lingua principale
Go
Stelle
75
Fork
2
Merge medio
16g 4h
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nylas/cli

Tutte le issue di nylas/cli

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.