Detect hardcoded credentials, API keys, tokens, and other secrets in source code and configuration files.
Use this skill when:
Use available tools in order of preference:
trufflehog filesystem --directory=<path> --json
trufflehog git file://<repo_path> --json # includes git history
gitleaks detect --source=<path> --report-format=json --report-path=results.json
detect-secrets scan <path> --all-files
If no scanner is installed, proceed with manual analysis.
Search for these high-confidence patterns:
| Pattern | Service | Regex Hint |
|———|———|———–|
| AKIA[0-9A-Z]{16} | AWS Access Key ID | Exact format |
| sk-[a-zA-Z0-9]{48} | OpenAI API Key | Prefix match |
| sk-ant-[a-zA-Z0-9-]{80,} | Anthropic API Key | Prefix match |
| ghp_[a-zA-Z0-9]{36} | GitHub Personal Access Token | Prefix match |
| gho_, ghu_, ghs_, ghr_ | GitHub OAuth/App tokens | Prefix match |
| xoxb-, xoxp-, xoxs- | Slack tokens | Prefix match |
| SG\.[a-zA-Z0-9_-]{22}\.[a-zA-Z0-9_-]{43} | SendGrid API Key | Format match |
| sk_live_, pk_live_, rk_live_ | Stripe keys | Prefix match |
| Pattern | What to Look For |
|———|—————–|
| Connection strings | ://user:password@host patterns |
| Password assignments | password = "...", PASSWORD: ..., passwd, secret |
| Private keys | -----BEGIN (RSA\|EC\|OPENSSH) PRIVATE KEY----- |
| Certificates | PEM-encoded certificates with private key material |
| JWT secrets | JWT_SECRET, TOKEN_SECRET assignments |
| Database credentials | DB_PASSWORD, MONGO_URI, DATABASE_URL with embedded credentials |
Scan these files with extra scrutiny:
.env, .env.* files**/config/**, **/settings/**docker-compose*.yml (environment sections)*.tfvars, terraform.tfstatekubeconfig, *.kubeconfigcredentials, credentials.json, service-account*.json.npmrc, .pypirc, pip.conf (registry tokens)**/ci/**, .github/workflows/** (inline secrets)For each detected secret:
CHANGE_ME, xxx, your-api-key-here, <token>).gitignore — is the file supposed to be excluded?Verify that the project has:
.gitignore entries for sensitive files (.env, *.key, *.pem, tfstate, etc.).gitleaks.toml or equivalent allowlist config for known false positives## Secrets Scan: [Repository/Directory]
### Scan Summary
- **Scanner used**: [tool or manual]
- **Scope**: Current files | Git history | Both
- **Files scanned**: [count]
- **Secrets found**: [count by category]
### Findings
[Standard finding template for each secret, with type and blast radius]
### Preventive Controls
| Control | Status |
|---------|--------|
| .gitignore covers sensitive files | Present/Missing |
| Pre-commit secret scanning | Present/Missing |
| CI secret scanning | Present/Missing |
### Immediate Actions Required
[If active production secrets are found, list rotation steps]
AKIA****EXAMPLE