agentleFS
bilals2008bilals2008/bilal-skills/skills/git-leak-prevention/SKILL.md

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

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
  1. Distinctive:

    Run this command to find files that should NOT be on GitHub:

    line 16
  2. Distinctive:

    Look for these patterns in tracked files:

    line 34
  3. Distinctive:

    Search for hardcoded secrets in tracked files:

    line 54
  4. Distinctive:

    Look for patterns like:

    line 60
  5. Very specific:

    If sensitive files are found, automatically update .gitignore:

    line 69
  6. Distinctive:

    Add missing entries. Standard .gitignore for web projects:

    line 76
  7. Distinctive:

    If sensitive files are already tracked:

    line 129
  8. Distinctive:

    WARNING: If secrets were pushed to GitHub, they are compromised.

    line 141
  9. Distinctive:

    Never use the same secrets again

    line 143

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 --porcelain

Step 2 — Check common sensitive patterns

Look for these patterns in tracked files:

PatternRiskAction
.env / .env.*API keys, DB passwordsRemove from git + add to .gitignore
node_modules/Dependencies (huge, not needed)Remove + .gitignore
dist/ / build/Compiled outputRemove + .gitignore
releases/Binary releasesRemove + .gitignore
*.key / *.pemPrivate keysRemove + .gitignore
*.p12 / *.pfxCertificatesRemove + .gitignore
.DS_StoremacOS metadata.gitignore
Thumbs.dbWindows metadata.gitignore
*.logLog files.gitignore
.cache/Cache folders.gitignore
coverage/Test coverage.gitignore
.turbo/ / .next/Build caches.gitignore
*.sqlDatabase 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 code

Look for patterns like:

  • API_KEY=sk-...
  • SECRET=...
  • PASSWORD=...
  • PRIVATE_KEY-----BEGIN
  • token: "eyJ..."

Step 4 — Auto-fix .gitignore

If sensitive files are found, automatically update .gitignore:

# Check current .gitignore
cat .gitignore

Add 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
*.swo

Step 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 .gitignore

WARNING: If secrets were pushed to GitHub, they are compromised. The user should:

  1. Rotate all exposed keys/secrets immediately
  2. 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:

  1. What was found at risk
  2. What was fixed automatically
  3. What the user needs to do manually (rotate keys)

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.