secret-detection
Skill49 starsChanged 35 days agoMITView on GitHub
Use when you suspect API keys, tokens, or passwords are hardcoded in source code or committed to git history — scans and guides safe removal without breaking existing integrations.
- Reads credentials
1 other project uses a version of this.
Adopted by
Most recently taken up by
- IBM/mcp-context-forgetheir own version, first seen Nov 29, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- IBM/mcp-context-forge★ 4.9ksame name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository117 other files it gives its agents.
- AGENTS.mdAGENTS.md
- COPILOT-INSTRUCTIONS.mdCopilot instructions
- .github/copilot-instructions.mdCopilot instructions
- ai-visibilitySkill
- content-strategySkill
- seoSkill
- actions-debuggingSkill
- agentic-engineeringSkill
- autopilot-patternsSkill
- background-agentSkill
- context-primeSkill
- copilot-memorySkill
- cross-session-memorySkill
- ecosystem-intakeSkill
- fleet-parallelSkill
- github-code-searchSkill
- github-codespaces-efficiencySkill
- github-issue-triageSkill
- github-pr-workflowSkill
- ide-switchingSkill
- knowledge-curatorSkill
- mcp-builderSkill
- mcp-ecosystemSkill
- multi-model-strategySkill
- plan-mode-masterySkill
- scope-guardSkill
- session-managementSkill
- stack-detectorSkill
- sub-agent-sandboxingSkill
- task-intake-routerSkill
- team-plannerSkill
- token-cost-optimizerSkill
- api-and-interface-designSkill
- code-reviewSkill
- context-engineeringSkill
- cpp-debuggingSkill
- deprecation-and-migrationSkill
- design-to-codeSkill
- diagnoseSkill
- fix-build-errorsSkill
- fix-github-issueSkill
- go-runtime-debuggingSkill
- implementSkill
- improve-codebase-architectureSkill
- nestjs-prismaSkill
- nextjs-prismaSkill
- performance-optimizationSkill
- pr-multi-perspective-reviewSkill
- prototypeSkill
- react-vitestSkill
- receiving-code-reviewSkill
- refactor-cleanSkill
- reviewSkill
- skill-creatorSkill
- source-driven-developmentSkill
- spec-driven-developmentSkill
- systematic-debuggingSkill
- tdd-workflowSkill
- terraform-safe-workflowSkill
- zoom-outSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Before open-sourcing a private repository
- Distinctive: line 16
After a developer reports a potential secret leak
- Distinctive: line 86
Check the provider's audit log for use of the old credential between exposure and revocation
- Very specific: line 178
Use explore agent to trace how a secret is used before replacing it with env vars
- Distinctive: line 181
Add secret scanning to your CI pipeline so this check runs automatically
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Secret Detection
When to Use
- Auditing a codebase for accidentally committed credentials
- Before open-sourcing a private repository
- After a developer reports a potential secret leak
- As part of a regular security review cadence
- Setting up pre-commit hooks for secret prevention
Prerequisites
- Access to the repository source code and git history
- Ability to rotate compromised credentials
- Access to a secrets manager or environment variable configuration
Workflow
1. Scan Source Code for Secret Patterns
# AWS Access Keys
grep -rn "AKIA[0-9A-Z]{16}" . --include="*.ts" --include="*.js" --include="*.py" --include="*.json"
# GitHub tokens
grep -rn "ghp_[a-zA-Z0-9]{36}\|github_pat_[a-zA-Z0-9_]{82}" .
# Generic API keys and secrets
grep -rni "api[_-]?key\s*[:=]\s*['\"][a-zA-Z0-9]" src/ --include="*.ts" --include="*.js"
# Private keys
grep -rn "BEGIN.*PRIVATE KEY" .
# Connection strings with credentials
grep -rni "mongodb\+srv://\|postgres://\|mysql://" . | grep -v "localhost\|example\|template"
# JWT secrets and signing keys
grep -rni "jwt[_]?secret\|signing[_]?key" src/ --include="*.ts" | grep -v "process\.env\|config\."2. Check for Secret Files
# Find committed secret files
git --no-pager ls-files | Select-String "\.pem$|\.key$|\.p12$|\.pfx$|id_rsa|\.env$"
# Check .gitignore covers sensitive patterns
Get-Content .gitignore 2>$null | Select-String "\.env|\.pem|\.key|secret"3. Scan Git History
Secrets removed from code may still exist in git history:
# Search recent commits for secret patterns
git --no-pager log --all -p --since="6 months ago" -S "AKIA" --oneline | Select-Object -First 20
# Search for common secret keywords in diffs
git --no-pager log --all -p -S "api_key" --oneline | Select-Object -First 204. Remediate Found Secrets
Step 1: Rotate the credential immediately Any secret found in source code should be considered compromised.
Revoking a key that services still use causes an outage, so rotate in this order when the provider allows two valid credentials at once:
- List every consumer of the credential (services, CI secrets, scheduled jobs, other teams)
- Issue the new credential and store it in the secret manager; do not paste it into chat or tickets
- Switch each consumer to the new credential and confirm a successful authenticated call from each
- Revoke the old credential at the provider, not only in your configuration
- Prove the revocation: a request with the old credential is now refused (for example
401), and requests with the new one still succeed - Check the provider's audit log for use of the old credential between exposure and revocation
An exposed credential is already compromised, so the overlap exists only to move consumers, not to keep the old key as a fallback. Keep the overlap as short as the switch takes; if a consumer fails, fix it forward with the new credential rather than pointing it back at the exposed one. Rolling back to the old credential is acceptable only in a routine rotation where nothing was exposed. If the key is being actively abused, revoke it now. If the provider allows only one valid credential, the service owner and whoever leads the incident decide — from the key's permissions, how widely it was exposed, and the cost of downtime — between immediate revocation, reducing the key's permissions first, or a short planned cutover, and record that decision.
Step 2: Replace with environment variables
// BEFORE — hardcoded secret
const apiKey = 'sk-abc123def456';
// AFTER — environment variable
const apiKey = process.env.API_KEY;
if (!apiKey) throw new Error('API_KEY environment variable is required');Step 3: Add to .env.example (without values)
# .env.example
API_KEY=
DATABASE_URL=
JWT_SECRET=Step 4: Update .gitignore
# Ensure .env is ignored
echo ".env" >> .gitignore
echo ".env.local" >> .gitignore
echo "*.pem" >> .gitignore
echo "*.key" >> .gitignore5. Prevent Future Leaks
# Add a pre-commit check (example with grep)
# Create a simple pre-commit hook#!/bin/sh
# .git/hooks/pre-commit
# --text: without it, files git treats as binary (a NUL byte, a -diff attribute) show only
# "Binary files differ" and a token inside them passes unchecked. UTF-16 text still will not
# match these ASCII patterns, so keep a dedicated scanner (gitleaks, trufflehog) in CI too.
if git diff --cached --text | grep -qaiE "AKIA[0-9A-Z]{16}|ghp_[a-zA-Z0-9]{36}|BEGIN.*PRIVATE KEY"; then
echo "ERROR: Potential secret detected in staged changes. Aborting commit."
exit 1
fiExamples
Comprehensive Scan Script
# Run all pattern checks and summarize
$patterns = @(
"AKIA[0-9A-Z]{16}",
"ghp_[a-zA-Z0-9]{36}",
"BEGIN.*PRIVATE KEY",
"password\s*=\s*['\"][^'\"]+['\"]"
)
foreach ($p in $patterns) {
$matches = grep -rn $p src/ --include="*.ts" --include="*.js" 2>$null
if ($matches) { Write-Host "FOUND: $p"; $matches }
}Migrating Secrets to Environment Variables
# 1. Find all hardcoded values
grep -rn "const.*secret\|const.*key\|const.*password" src/ --include="*.ts" | grep -v "process.env"
# 2. For each finding, edit the file to use process.env
# 3. Add the variable to .env.example
# 4. Add the actual value to your deployment's environment configTips
- Rotate first, clean up second — assume any committed secret is already compromised
- Use
exploreagent to trace how a secret is used before replacing it with env vars - Common false positives: test fixtures, example configs, documentation — but always verify
- For removing secrets from git history, consider
git filter-repo(destructive, requires coordination) - Add secret scanning to your CI pipeline so this check runs automatically
- Store secrets in a dedicated manager (Vault, AWS SSM, GitHub Secrets) — not in
.envfiles on servers
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

