agentleFS
Phaedra-SolutionsPhaedra-Solutions/cursor-rules/skills/secrets-scan/SKILL.md

secrets-scan

Skill4 starsChanged 10 days agoMITView on GitHub

Scan staged changes, the working tree or git history for leaked secrets with gitleaks, and guide the user through revoking and rotating anything found, then optionally removing it from history. Use before a commit, when asked to check for secrets or leaked keys, after a secret was pasted or committed, or as part of a security audit.

  • Reads credentials

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. 0 are common, 7 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Before a commit (the git-commit skill calls this on staged files).

    line 15
  2. Distinctive:

    When the user asks to check for secrets, keys or credentials.

    line 16
  3. Distinctive:

    After a secret was pasted into code, a log, an issue or chat, or committed by mistake.

    line 17
  4. Very specific:

    Check that gitleaks is installed: gitleaks version.

    line 22
  5. Very specific:

    Never print, echo or paste a secret value, even partly.

    line 24
  6. Very specific:

    Don't write a report file into the repo.

    line 25
  7. Distinctive:

    every commit hash after the first affected commit changes.

    line 50
  8. Very specific:

    If history was rewritten: gitleaks git .

    line 69
  9. Distinctive:

    Never print a secret's value, in full or in part, in chat, files, commit messages or logs.

    line 73
  10. Distinctive:

    Never send a secret to an external service to "check" it.

    line 74
  11. Distinctive:

    Never rewrite history or force-push without explicit consent.

    line 75
  12. Very specific:

    Never add .gitleaksignore entries or gitleaks:allow comments without the user's approval.

    line 76
  13. Distinctive:

    Never disable push protection or a secret-scanning hook to get a commit through.

    line 77

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “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

Secrets scan

When to use

  • Before a commit (the git-commit skill calls this on staged files).
  • When the user asks to check for secrets, keys or credentials.
  • After a secret was pasted into code, a log, an issue or chat, or committed by mistake.
  • As part of security-audit, which only scans the working tree; this skill also covers history.

Before you start

  • Check that gitleaks is installed: gitleaks version. If it isn't, ask before installing it, and install only from the official source (package manager or the GitHub releases page).
  • Agree the scope with the user: staged changes (default), the working tree, a commit range, or the full history. A full-history scan can be slow on large repos.
  • Never print, echo or paste a secret value, even partly. Always pass --redact so gitleaks hides values in its output.
  • Don't write a report file into the repo. If the user wants one, write it outside the working tree with --redact and delete it when done.

Steps

  1. Run the scan for the agreed scope (from the repo root):

    ScopeCommand
    Staged changesgitleaks git --staged --redact --no-banner -v
    Unstaged changesgitleaks git --pre-commit --redact --no-banner -v
    Working tree (all files, tracked or not)gitleaks dir . --redact --no-banner -v
    A commit rangegitleaks git --log-opts="origin/main..HEAD" --redact --no-banner -v
    Full historygitleaks git . --redact --no-banner -v

    Exit code 1 means leaks were found; 0 means none. Respect an existing .gitleaks.toml and .gitleaksignore.

  2. Triage each finding. For each one, note the rule ID, file, line, commit (for history scans) and author. Decide:
    • Real secret: go to step 3.
    • Test fixture or example value: confirm it grants no access, then suggest a gitleaks:allow comment on that line, or a fingerprint in .gitleaksignore. Ask the user first; never add an ignore on your own.
    • False positive: same as above, with the reason.
  3. Contain a real secret. Explain to the user, in this order:
    1. Revoke or rotate it first, at the provider (cloud console, GitHub token settings, npm token revoke, the API vendor's dashboard). A secret that reached a remote, a CI log, a package or chat is compromised even after it's deleted. Removing it from history doesn't make it safe.
    2. Check for misuse: review the provider's access logs for the period since the leak.
    3. Replace it with a reference to an env var or secret manager (process.env.STRIPE_SECRET_KEY, a CI secret, a vault). Add the file to .gitignore if it's a local config file.
    4. Remove it from the code in a normal commit.
  4. Only if the user asks, rewrite history. Explain the cost first:

    • every commit hash after the first affected commit changes;
    • a force-push is required, and every collaborator must re-clone or rebase; forks, open PRs, caches and existing clones keep the old data;
    • on GitHub, cached views and PR refs may need GitHub Support to purge.

    With the user's consent, work in a fresh clone and use git-filter-repo (≥ 2.47 for --sensitive-data-removal):

    git filter-repo --sensitive-data-removal --invert-paths --path config/secrets.yml
    # or replace the literal values listed one per line in a file kept outside the repo:
    git filter-repo --sensitive-data-removal --replace-text ../expressions.txt

    The user runs the force-push; never run it yourself.

  5. Prevent recurrence. Suggest gitleaks as a pre-commit hook or CI step, and GitHub secret scanning with push protection where available. Ask before adding hooks or workflows (see core/agent-safety).

Verify

  • Re-run the same scan; it must report no leaks (or only approved, documented ignores).
  • The user has confirmed the secret is revoked at the provider. Rewriting history isn't a substitute.
  • If history was rewritten: gitleaks git . --redact --no-banner on a fresh clone of the remote finds nothing.

Safety

  • Never print a secret's value, in full or in part, in chat, files, commit messages or logs.
  • Never send a secret to an external service to "check" it.
  • Never rewrite history or force-push without explicit consent; never force-push yourself.
  • Never add .gitleaksignore entries or gitleaks:allow comments without the user's approval.
  • Never disable push protection or a secret-scanning hook to get a commit through.

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.