agentleFS
samsam007bsamsam007b/claude-code-standards-kit/skills/secret-scanner/SKILL.md

secret-scanner

Skill2 starsChanged 8 months agoMITView on GitHub

Scan staged files to detect credentials, API keys, tokens and secrets before any git commit.

  • Reads credentials
  • Commits and pushes

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Does NOT remove secrets from Git history

    line 79
  2. Distinctive:

    Does not scan binary files

    line 80
  3. Distinctive:

    Remove the secret from the code: use environment variables

    line 86

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Secret Scanner - Protection against credential leaks

Description

This skill provides automatic protection against leaking secrets (passwords, API keys, tokens) in Git commits. It automatically analyzes every git commit and git push before execution.

How it works

The PreToolUse hook intercepts Bash commands containing:

  • git commit
  • git push
  • git commit --amend

It then runs the scan-secrets.sh script, which:

  1. Retrieves the staged changes (git diff --cached)
  2. Analyzes the content with 30+ regex patterns
  3. Blocks the operation if secrets are detected

Detected patterns

Passwords

  • password = "..."
  • pwd = "..."
  • passwd = "..."

API Keys

  • AWS: AKIA... (16 chars)
  • Stripe: sk_live_..., sk_test_..., whsec_...
  • Google: AIza... (35 chars)
  • GitHub: ghp_..., gho_...
  • Supabase JWT tokens
  • SendGrid: SG....
  • Slack: xox[baprs]-...

Generic tokens

  • api_key = "..."
  • secret_key = "..."
  • auth_token = "..."
  • access_token = "..."
  • bearer ...

Private keys

  • -----BEGIN PRIVATE KEY-----
  • -----BEGIN RSA PRIVATE KEY-----
  • -----BEGIN PGP PRIVATE KEY BLOCK-----

Connection strings

  • MongoDB: mongodb://user:pass@...
  • PostgreSQL: postgres://user:pass@...
  • MySQL: mysql://user:pass@...
  • Redis: redis://user:pass@...

Files

  • Hook script: .claude/hooks/scan-secrets.sh
  • Configuration: .claude/settings.json (PreToolUse hook)

Customization

To add new patterns, edit the PATTERNS array in scan-secrets.sh:

PATTERNS=(
    # Add your pattern here
    "my_custom_pattern"
    ...
)

Limitations

  • Does NOT remove secrets from Git history
  • Does not scan binary files
  • May produce false positives on some generic patterns

What to do if a secret is detected?

  1. Do not commit: the hook blocks automatically
  2. Remove the secret from the code: use environment variables
  3. If already committed: rotate the exposed secret immediately
  4. Optional: clean the history with git filter-branch or BFG

Examples of good practice

// ❌ BAD - Hardcoded secret
const apiKey = "sk_live_abc123xyz";

// ✅ GOOD - Environment variable
const apiKey = process.env.STRIPE_SECRET_KEY;
# ❌ BAD
password = "SuperSecret123"

# ✅ GOOD
import os
password = os.environ.get("DB_PASSWORD")

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.