Use when discussing code security, secret management, credential leaks, API key handling, LLM provider keys, PII protection, git history cleaning, or file permissions auditing.
Scans code for secrets, PII, and credentials, then redacts or removes them from files and git history.
/plugin marketplace add iamfiscus/claude-code-scrub/plugin install iamfiscus-scrub@iamfiscus/claude-code-scrubThis skill inherits all available tools. When active, it can use any tool Claude has access to.
| Provider | Pattern | Environment Variable |
|---|---|---|
| OpenAI | sk-..., sk-proj-..., sk-svcacct-... | OPENAI_API_KEY |
| Anthropic | sk-ant-... | ANTHROPIC_API_KEY |
| Google AI | AIza[0-9A-Za-z-_]{35} | GOOGLE_API_KEY, GEMINI_API_KEY |
| Cohere | 40-char alphanumeric | COHERE_API_KEY |
| Mistral | 32-char alphanumeric | MISTRAL_API_KEY |
| Groq | gsk_... | GROQ_API_KEY |
| Perplexity | pplx-... | PERPLEXITY_API_KEY |
| Hugging Face | hf_... | HF_TOKEN, HUGGINGFACE_API_KEY |
| Replicate | r8_... | REPLICATE_API_TOKEN |
| Together AI | 64-char hex | TOGETHER_API_KEY |
| xAI (Grok) | varies | XAI_API_KEY |
Never do this:
# BAD - hardcoded key
client = OpenAI(api_key="sk-abc123...")
Do this instead:
# GOOD - environment variable
import os
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
Or use dotenv:
from dotenv import load_dotenv
load_dotenv() # Loads from .env file
client = OpenAI() # Auto-reads OPENAI_API_KEY
| Service | Pattern | Example |
|---|---|---|
| AWS Access Key | AKIA[0-9A-Z]{16} | AKIAIOSFODNN7EXAMPLE |
| AWS Secret Key | 40 char base64 | wJalrXUtnFEMI/K7MDENG... |
| GitHub Token | ghp_[a-zA-Z0-9]{36} | ghp_xxxx... |
| GitHub PAT | github_pat_[0-9a-zA-Z_]{82} | github_pat_... |
| GitLab Token | glpat-[0-9a-zA-Z-]{20} | glpat-xxxx... |
| Stripe Live | sk_live_[a-zA-Z0-9]{24} | sk_live_... |
| Stripe Test | sk_test_[a-zA-Z0-9]{24} | sk_test_... |
| Slack Token | xox[baprs]-... | xoxb-... |
| Slack Webhook | https://hooks.slack.com/... | webhook URL |
| Twilio | SK[0-9a-fA-F]{32} | SK... |
| SendGrid | SG.[a-zA-Z0-9]{22}.[a-zA-Z0-9]{43} | SG.... |
| Discord Bot | [MN][A-Za-z0-9]{23,}... | Bot token |
| Firebase | AAAA[A-Za-z0-9_-]{7}:... | FCM key |
| Supabase | sbp_[a-f0-9]{40} | sbp_... |
| JWT | eyJ... (3 base64 segments) | eyJhbGc... |
| Private Key | -----BEGIN...PRIVATE KEY----- | PEM format |
The scrub plugin includes a PreToolUse hook that blocks Claude from reading files containing credentials.
Read operationsAdd trusted files to ~/.claude/plugins/scrub/.guard-allowlist:
# Allow test fixtures
tests/fixtures/
*.test.js
.env.example
/scrub:guard status # Check if enabled
/scrub:guard on # Enable guard
/scrub:guard off # Disable guard
/scrub:guard allowlist # Manage allowlist
.env, config.js, settings.py.github/workflows/, JenkinsfileDockerfile, docker-compose.ymlBefore sharing logs:
| File Type | Recommended | Why |
|---|---|---|
| Private keys | 600 | Owner only |
| .env files | 600 | Contains secrets |
| Scripts | 755 | Execute for all, write for owner |
| Config files | 644 | Read for all, write for owner |
| Directories | 755 | Standard access |
# Environment
.env
.env.*
.env.local
# Keys and certificates
*.pem
*.key
*.p12
*.pfx
*.keystore
id_rsa
id_ed25519
# Credentials
credentials.json
secrets.json
*secret*
*credential*
# Logs
*.log
logs/
Use when working with Payload CMS projects (payload.config.ts, collections, fields, hooks, access control, Payload API). Use when debugging validation errors, security issues, relationship queries, transactions, or hook behavior.