Skip to content
Back to skills

Secret Scanner

BSecurity

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

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 14, 2026
developmentjavascriptpythongojavabashsqlawsgitapisecurity

Works with

  • api

Security analysis

B75/100
  • criticalReads or references SSH private keys

Pro shows the line behind each finding and how to fix it

Scanned November 14, 2026

npx -y skills add samsam007b/claude-code-standards-kit --skill secret-scanner --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Secret Scanner?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Secret Scanner
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/samsam007b-secret-scanner/badge)](https://www.skillsdirectory.com/skills/samsam007b-secret-scanner)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: secret-scanner
description: Scan staged files to detect credentials, API keys, tokens and secrets before any git commit.
tags: [security, git, secrets, credentials]
model: sonnet
---

# 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`:

```bash
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

```javascript
// ❌ BAD - Hardcoded secret
const apiKey = "[REDACTED]";

// ✅ GOOD - Environment variable
const apiKey = process.env.STRIPE_SECRET_KEY;
```

```python
# ❌ BAD
password = "SuperSecret123"

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

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.