CommandOpen

Security (secrets-scan)

Scan the codebase for leaked secrets, API keys, tokens, and credentials.

Scan the codebase for leaked secrets, API keys, tokens, and credentials.

Steps

  1. Define patterns to search for:
  • AWS keys: AKIA[0-9A-Z]{16}, aws_secret_access_key.
  • API keys: sk-[a-zA-Z0-9]{32,}, api[_-]?key\s*[:=].
  • Tokens: ghp_, gho_, github_pat_, xoxb-, xoxp-.
  • Private keys: -----BEGIN (RSA|EC|OPENSSH) PRIVATE KEY-----.
  • Database URLs: (postgres|mysql|mongodb)://[^:]+:[^@]+@.
  • Generic secrets: password\s[:=]\s["'][^"']+["'], secret\s*[:=].
  1. Scan all tracked files: git ls-files (skip binary files).
  2. Also scan .env files that may not be tracked.
  3. Exclude known false positives (test fixtures, documentation examples, .env.example).
  4. For each finding, determine severity:
  • CRITICAL: Real credentials with high entropy that appear functional.
  • WARNING: Patterns that look like secrets but may be placeholders.
  • INFO: References to secret names without values.
  1. Check if .gitignore properly excludes sensitive files (.env, .pem, .key).
  2. Suggest remediation for each finding.

Format

Secrets Scan Results
====================

CRITICAL (immediate action required):
  - <file>:<line> - <type>: <masked-value>

WARNING (review needed):
  - <file>:<line> - <type>: <description>

.gitignore check:
  - [ ] .env files excluded
  - [ ] Key files excluded

Remediation:
  1. Rotate <credential type>
  2. Add <pattern> to .gitignore

Rules

  • Never print full secret values; mask all but the first 4 characters.
  • Scan both tracked and untracked files.
  • Check git history for secrets in past commits using git log -p --all -S.
  • Suggest .gitignore additions for any unprotected secret file patterns.
  • Recommend using environment variables or secret managers for all findings.

Source: https://github.com/rohitg00/awesome-claude-code-toolkit/blob/main/commands/security/secrets-scan.md

Author: rohitg00, Claude Code toolkit (rohitg00). License: Apache-2.0.

Shown here with formatting for the web. Keep the author and license notice when you reuse it.

Related entries

There are more like this in the members library

The Codex library holds 7,009 entries. Members can search all of them by meaning and read every one in full.