What’s Detected
API Keys and Tokens
Credentials that could grant unauthorized access:- AWS Access Keys and Secret Keys
- API tokens (GitHub, Slack, Stripe, etc.)
- OAuth tokens and refresh tokens
- Service account credentials
Certificates and Private Keys
Cryptographic material that should never appear in conversation:- Private SSH keys
.pemand.p12certificate files- TLS/SSL private keys
- Signing keys
Configuration Files
Sensitive configuration that often contains credentials:.envfiles with embedded secrets- Database connection strings with passwords
- Cloud provider configuration files
- Docker secrets
System Files
Operating system files that could expose sensitive information:/etc/passwdand/etc/shadow- SSH configuration directories
- System keychain access
- Credential stores
How It Works
Secret detection runs as Claude Code hooks on both requests (what’s sent to the LLM) and responses (what the agent outputs). This two-way scanning catches:- Secrets in tool output — If Claude Code reads a file containing API keys, the secret pattern is detected and flagged
- Secrets in responses — If the agent attempts to include credentials in its output, they are caught
Example
Tuning
If your workflow triggers false positives:- Disable individual rules — If a specific detection isn’t relevant to your environment
- Create custom rules — Add patterns specific to your organization’s credential formats