Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Claude Code commit guards never fire: $TOOL_INPUT is unset

オープン 初心者向け
#128 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github, go
領域
cli, security

調査の方向性

.claude/settings.json と、issue でリンクされている Claude Code hooks のリファレンスを読みます。issue には、失敗する guard と提案されている stdin の解析変更についての再現例が含まれています。git -C . commit や、ステージされていない secret を含む git commit -am など、記載されているバイパスの表記で guard がどう動作するかを確認します。説明されているステージ済みのケースを guard がブロックし、issue のバイパスケースが CI チェックで網羅されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Go
スター
75
フォーク
2
平均マージ
16日 4時間
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nylas/cli のほかの issue

nylas/cli の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。