secrets-detection
Find and prevent leaked secrets, API keys, and credentials in code. Use this skill when reviewing code for exposed secrets, setting up pre-commit hooks, or auditing repositories. Activate when: leaked secret, API key exposed, credentials in code, hardcoded password, secret scanning, git secrets, pre-commit hook.
What this skill does
# Secrets Detection
**Find and prevent leaked API keys, passwords, and credentials in your codebase.**
## When to Use
- Reviewing code for hardcoded secrets
- Setting up CI/CD security checks
- Auditing git history for leaks
- Configuring pre-commit hooks
- Responding to secret exposure incidents
## Common Secret Patterns
| Secret Type | Pattern Example |
|------------|-----------------|
| AWS Access Key | `AKIA[0-9A-Z]{16}` |
| AWS Secret Key | 40-character base64 |
| GitHub Token | `ghp_[a-zA-Z0-9]{36}` |
| Stripe API Key | `sk_live_[a-zA-Z0-9]{24}` |
| Private Key | `-----BEGIN RSA PRIVATE KEY-----` |
| JWT Secret | High entropy string |
## Detection Tools
### 1. Gitleaks (Recommended)
```bash
# Install
brew install gitleaks
# Scan current directory
gitleaks detect -v
# Scan git history
gitleaks detect --source . -v
# CI/CD integration
gitleaks detect --source . --exit-code 1
```
```yaml
# .gitleaks.toml - Custom rules
[allowlist]
paths = [
'''vendor/''',
'''node_modules/''',
'''\.test\.'''
]
[[rules]]
description = "Custom API Key"
id = "custom-api-key"
regex = '''myapp_[a-zA-Z0-9]{32}'''
tags = ["key", "custom"]
```
### 2. git-secrets (AWS)
```bash
# Install
brew install git-secrets
# Add AWS patterns
git secrets --register-aws
# Scan repository
git secrets --scan
# Install hooks
git secrets --install
```
### 3. TruffleHog
```bash
# Scan repository
trufflehog git file://. --only-verified
# Scan GitHub org
trufflehog github --org=myorg --only-verified
# CI/CD
trufflehog git file://. --fail --only-verified
```
## Pre-Commit Hooks
### Husky + lint-staged
```bash
npm install -D husky lint-staged
npx husky init
```
```json
// package.json
{
"lint-staged": {
"*.{js,ts,jsx,tsx}": [
"gitleaks detect --no-git -v"
]
}
}
```
```bash
# .husky/pre-commit
#!/bin/sh
npx lint-staged
gitleaks protect --staged -v
```
### Pre-commit Framework
```yaml
# .pre-commit-config.yaml
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.0
hooks:
- id: gitleaks
- repo: https://github.com/awslabs/git-secrets
rev: master
hooks:
- id: git-secrets
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
```
```bash
# Install
pip install pre-commit
pre-commit install
```
## CI/CD Integration
### GitHub Actions
```yaml
name: Secret Scanning
on: [push, pull_request]
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Gitleaks
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
trufflehog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: TruffleHog
uses: trufflesecurity/trufflehog@main
with:
extra_args: --only-verified
```
### GitLab CI
```yaml
secret_detection:
stage: test
image: zricethezav/gitleaks:latest
script:
- gitleaks detect --source . --exit-code 1 -v
allow_failure: false
```
## Safe Secrets Management
### Environment Variables
```javascript
// Load from environment
const config = {
apiKey: process.env.API_KEY,
dbPassword: process.env.DB_PASSWORD,
jwtSecret: process.env.JWT_SECRET
};
// Validate required secrets
const requiredSecrets = ['API_KEY', 'DB_PASSWORD', 'JWT_SECRET'];
for (const secret of requiredSecrets) {
if (!process.env[secret]) {
throw new Error(`Missing required secret: ${secret}`);
}
}
```
### .env Files (Development Only)
```bash
# .env.example (commit this)
API_KEY=your_api_key_here
DB_PASSWORD=your_db_password_here
# .env (NEVER commit)
API_KEY=sk_live_actual_key_12345
DB_PASSWORD=actual_password
```
```gitignore
# .gitignore
.env
.env.local
.env.*.local
*.pem
*.key
```
### Secrets Manager Integration
```javascript
// AWS Secrets Manager
const { SecretsManager } = require('@aws-sdk/client-secrets-manager');
async function getSecret(secretName) {
const client = new SecretsManager({ region: 'us-east-1' });
const response = await client.getSecretValue({ SecretId: secretName });
return JSON.parse(response.SecretString);
}
// HashiCorp Vault
const vault = require('node-vault')({
endpoint: process.env.VAULT_ADDR,
token: process.env.VAULT_TOKEN
});
async function getVaultSecret(path) {
const { data } = await vault.read(path);
return data.data;
}
```
## Incident Response: Secret Leaked
```bash
# 1. Immediately revoke the secret
# - AWS: IAM console -> Delete access key
# - GitHub: Settings -> Developer settings -> Delete token
# - Stripe: Dashboard -> API keys -> Roll key
# 2. Remove from git history
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch path/to/secret/file" \
--prune-empty --tag-name-filter cat -- --all
# Or use BFG Repo-Cleaner (faster)
bfg --delete-files secret-file.txt
bfg --replace-text secrets.txt
# 3. Force push (coordinate with team!)
git push origin --force --all
git push origin --force --tags
# 4. Audit for unauthorized access
# Check service logs for the compromised credential
# 5. Generate new secret and update references
```
## Code Review Checklist
- [ ] No hardcoded API keys or passwords
- [ ] No private keys in repository
- [ ] No credentials in configuration files
- [ ] Environment variables used for secrets
- [ ] .env files in .gitignore
- [ ] Pre-commit hooks configured
- [ ] CI/CD secret scanning enabled
- [ ] Secrets manager used in production
- [ ] Example config files don't contain real secrets
## Best Practices
1. **Never Commit Secrets**: Use pre-commit hooks
2. **Use Secrets Managers**: Vault, AWS Secrets Manager
3. **Rotate Regularly**: Automate secret rotation
4. **Audit Access**: Log who accesses secrets
5. **Least Privilege**: Minimal permissions for each secret
6. **Scan Git History**: Secrets may be in old commits
7. **Act Fast on Leaks**: Revoke immediately, then clean up
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.