agentsclimarketplace

Git prepush secret remote check

Skill bokuwalily/claude-code-skills/skills/git-prepush-secret-remote-check

git pushやパブリック公開の直前に実行する。リモートURLが自分のリポジトリを指しているか確認し、ステージ・差分内のAPIキー/トークン/PII漏洩をスキャンする。複数セッションで「サードパーティforkへのwrong-remote」と「PII流出」が実際に発生したことへの対策。From its SKILL.md

Install
npx -y skills add bokuwalily/claude-code-skills --skill git-prepush-secret-remote-check

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

3.2 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it

Procedure

1. リモートURLを確認する

git remote -v

出力例:

origin  [email protected]:YOUR_USERNAME/YOUR_REPO.git (fetch)
origin  [email protected]:YOUR_USERNAME/YOUR_REPO.git (push)

自分のアカウント名が含まれていることを確認。サードパーティのfork元URLになっていれば即修正:

git remote set-url origin [email protected]:YOUR_USERNAME/YOUR_REPO.git

2. ステージ済みファイルに秘密情報がないかスキャン

git diff --cached | grep -iE \
  "(api_?key|secret|token|password|passwd|auth|credential|access_?key|private_?key)\s*[=:]\s*\S+"

何も出力されなければOK。ヒットしたら即 git reset HEAD <file> でアンステージし、.env 化してから .gitignore に追加。

3. コミット済み履歴を含むスキャン(念のため)

git log --oneline -10
git show HEAD | grep -iE "(api_?key|secret|token|password)\s*[=:]\s*\S+"

4. .env 系ファイルが追跡されていないか確認

git ls-files | grep -E "^\.env"

出力があればトラッキングから除外:

git rm --cached .env
echo ".env" >> .gitignore
git add .gitignore

5. 個人情報(PII)の簡易チェック

git diff --cached | grep -iE \
  "(\b[0-9]{3}-[0-9]{4}-[0-9]{4}\b|@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})"

電話番号・メールアドレスパターンにヒットしたらコード内のハードコーディングを確認。


Pitfalls

  • fork元リモートのままpush:テンプレートをforkしたまま origin を変えずにpushすると、サードパーティリポジトリに自分のコードが公開される。手順1を必ず行う。
  • .env ファイルの誤コミット:create-next-app や vite はデフォルトで .env.local を .gitignore に入れるが、自前設定のプロジェクトでは漏れる。手順4で確認。
  • grep のパターンは完璧ではない:難読化・Base64化された秘密情報は検出できない。gitleaks や truffleHog などの専用ツールが使える環境ならそちらを優先。
  • force-pushで履歴書き換えても残る:一度でも公開リポジトリにpushしたシークレットはGitHub側にキャッシュされる可能性がある。露出したら即ローテーション。

Verification

# リモートが自分のリポジトリを指していること
git remote -v | grep "YOUR_USERNAME"

# シークレットスキャンで何もヒットしないこと
git diff --cached | grep -iE "(api_?key|secret|token|password)\s*[=:]\s*\S+" | wc -l
# → 0 であればOK

# .env系が追跡されていないこと
git ls-files | grep -E "^\.env" | wc -l
# → 0 であればOK

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 625,150. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.