git-leak-prevention
Skill0 starsChanged 4 months agoMITView on GitHub
Scan repositories for sensitive files (.env, secrets, API keys, build artifacts, node_modules, dist, releases) before pushing to GitHub. Automatically fix .gitignore to prevent leaks. Use when the user asks to check for secrets, scan for leaks, fix gitignore, or perform any security-related task.
- Reads credentials
In this repository3 other files it gives its agents.
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 8 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
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 16
Run this command to find files that should NOT be on GitHub:
- Distinctive: line 34
Look for these patterns in tracked files:
- Distinctive: line 54
Search for hardcoded secrets in tracked files:
- Distinctive: line 60
Look for patterns like:
- Very specific: line 69
If sensitive files are found, automatically update .gitignore:
- Distinctive: line 76
Add missing entries. Standard .gitignore for web projects:
- Distinctive: line 129
If sensitive files are already tracked:
- Distinctive: line 141
WARNING: If secrets were pushed to GitHub, they are compromised.
- Distinctive: line 143
Never use the same secrets again
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Git Leak Prevention
Purpose
Prevent sensitive files, secrets, and build artifacts from being pushed to GitHub. Scan, detect, and auto-fix .gitignore.
Instructions
Step 1 — Scan for sensitive files
Run this command to find files that should NOT be on GitHub:
git ls-files | findstr /i ".env .env.local .env.production .env.staging node_modules dist build releases *.key *.pem *.p12 secrets"On PowerShell:
git ls-files | Select-String -Pattern "\.env|node_modules|dist|build|releases|\.key$|\.pem$|\.p12$|secrets|\.log$|\.cache$"Also check for untracked sensitive files:
git status --porcelainStep 2 — Check common sensitive patterns
Look for these patterns in tracked files:
| Pattern | Risk | Action |
.env / .env.* | API keys, DB passwords | Remove from git + add to .gitignore |
node_modules/ | Dependencies (huge, not needed) | Remove + .gitignore |
dist/ / build/ | Compiled output | Remove + .gitignore |
releases/ | Binary releases | Remove + .gitignore |
*.key / *.pem | Private keys | Remove + .gitignore |
*.p12 / *.pfx | Certificates | Remove + .gitignore |
.DS_Store | macOS metadata | .gitignore |
Thumbs.db | Windows metadata | .gitignore |
*.log | Log files | .gitignore |
.cache/ | Cache folders | .gitignore |
coverage/ | Test coverage | .gitignore |
.turbo/ / .next/ | Build caches | .gitignore |
*.sql | Database dumps (sometimes secrets) | Check content |
Step 3 — Check for secrets in code
Search for hardcoded secrets in tracked files:
rg -i "(api[_-]?key|secret|password|token|private[_-]?key)\s*[:=]\s*['\x22]" --type-add 'code:*.{ts,tsx,js,jsx,json,yaml,yml,env,config}' -t codeLook for patterns like:
API_KEY=sk-...SECRET=...PASSWORD=...PRIVATE_KEY-----BEGINtoken: "eyJ..."
Step 4 — Auto-fix .gitignore
If sensitive files are found, automatically update .gitignore:
# Check current .gitignore
cat .gitignoreAdd missing entries. Standard .gitignore for web projects:
# Environment files
.env
.env.local
.env.production
.env.staging
.env.development
# Dependencies
node_modules/
# Build output
dist/
build/
release/
releases/
# Secrets
*.key
*.pem
*.p12
*.pfx
# IDE
.vscode/settings.json
.idea/
# OS
.DS_Store
Thumbs.db
# Logs
*.log
npm-debug.log*
# Cache
.cache/
.turbo/
.next/
.nuxt/
# Coverage
coverage/
# Misc
*.swp
*.swoStep 5 — Remove sensitive files from git tracking (if already tracked)
If sensitive files are already tracked:
# Remove from tracking but keep locally
git rm --cached .env
git rm --cached -r node_modules/
git rm --cached -r dist/
git rm --cached -r build/
# Then add to .gitignoreWARNING: If secrets were pushed to GitHub, they are compromised. The user should:
- Rotate all exposed keys/secrets immediately
- Never use the same secrets again
Step 6 — Show report to user
Present findings clearly:
🔍 Security Scan Report
Files at risk:
❌ .env — tracked (contains secrets)
❌ node_modules/ — tracked (should be ignored)
⚠️ dist/ — tracked (build output)
Actions taken:
✅ Added .env to .gitignore
✅ Added node_modules/ to .gitignore
✅ Added dist/ to .gitignore
✅ Removed .env from git tracking (kept locally)
⚠️ If .env had real secrets, ROTATE them now.
GitHub history still has the old version.Step 7 — Commit the fix
git add .gitignore
git commit -m "chore(security): update gitignore to prevent secret leaks"What NOT to do
- ❌ Never show actual secret values in the report (mask them:
sk-****...****) - ❌ Never commit .env or secrets even for "temporary" reasons
- ❌ Never ignore the warning if secrets were already pushed
- ❌ Never skip checking
git ls-files— untracked files are fine, tracked ones are the risk
Expected Output
A clean security report showing:
- What was found at risk
- What was fixed automatically
- What the user needs to do manually (rotate keys)
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.

