agentleFS
saizulsaizul/security-audit-skills/skills/secrets-scan/SKILL.md

secrets-scan

Skill0 starsChanged 10 days agoMITView on GitHub

Scan your own repository or files for hardcoded secrets - AWS, GitHub, GitLab, Slack, Stripe, Google, npm, SendGrid and LLM API keys, private key blocks, JWTs, passwords in URLs and high-entropy values assigned to password/token/api_key names - plus sensitive files such as .env, id_rsa, *.pem and terraform.tfstate. Output is always redacted (prefix, length, fingerprint), supports a baseline and inline allow markers, and ends with a rotation plan for anything real. Use when the user asks to check a repo for leaked secrets or credentials before pushing or open-sourcing, mentions "API key in git", "did I commit my .env", GitHub push protection or secret scanning alerts, or wants a pre-commit / CI secret check.

  • Reads credentials

9 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 6

    Distinctive

    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:

    Never print, quote, paste or summarise a full secret value - not even "to confirm".

    line 18
  2. Very specific:

    Do not cat, grep or open a flagged file in a way that echoes the secret into the chat.

    line 20
  3. Distinctive:

    If you must inspect context, read only neighbouring lines, or ask the user to look.

    line 21
  4. Distinctive:

    Do not test whether a key works by calling the provider API.

    line 22
  5. Distinctive:

    After a contractor leaves or a laptop is lost: what credentials live in our code?

    line 30
  6. Distinctive:

    Scan git history too: when the repo has a history (deleted files still leak).

    line 51
  7. Distinctive:

    Always end with: what is real, what was already pushed, the rotation plan, and the prevention step.

    line 100

“Common” is measured: kept by at least 6 in 10 of the 6 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

Find credentials in the working tree, never display them, and get real ones rotated. Paths below are relative to this skill's folder (in Claude Code: ${CLAUDE_SKILL_DIR}).

Safety rules for this skill

  • Never print, quote, paste or summarise a full secret value - not even "to confirm". Refer to findings by file, line, rule and the redacted prefix the script prints.
  • Do not cat, grep or open a flagged file in a way that echoes the secret into the chat. If you must inspect context, read only neighbouring lines, or ask the user to look.
  • Do not test whether a key works by calling the provider API. Treat every match as live until the owner says otherwise.

When to use

  • "Scan this repo for secrets / API keys / passwords before I push or make it public"
  • "Did I commit my .env?", "GitHub says it found a secret", "push protection blocked my push"
  • Setting up a pre-commit hook or CI job that blocks secrets
  • After a contractor leaves or a laptop is lost: what credentials live in our code?

When not to use

  • A secret is already confirmed leaked publicly: start with incident-response-playbook (rotate first, investigate second) and use this skill afterwards to find other copies.
  • Scanning repositories or systems the user does not own or is not authorised to audit.
  • Dependency vulnerabilities (dependency-audit) or secrets inside Docker images (dockerfile-security covers ENV/ARG and copied key files).

Workflow

  1. Scope it. Confirm the directory and whether the repo is (or will become) public. Note test fixtures that intentionally contain fake keys so they can be excluded.
  2. Scan the working tree (read-only).
    python3 scripts/secrets_scan.py .
    python3 scripts/secrets_scan.py . --exclude 'tests/fixtures/*' --json > secrets.json
    Skips .git, node_modules, vendor, virtualenvs, build output, lockfiles, binaries and files over 1 MB. Exit 1 = findings at or above --fail-on (default low), 2 = bad input.
  3. Scan git history too when the repo has a history (deleted files still leak). Prefer an installed scanner; do not install tools without asking:
    gitleaks git -v --redact .          # gitleaks 8.19+; older versions: gitleaks detect --redact
    git log --all --oneline -- '*.env' '*.pem' 'id_*'    # quick check for removed key files
    trufflehog can verify keys against providers, which sends them over the network - only with the user's explicit consent.
  4. Triage each finding using the table below. A finding is a false positive only if the value is a placeholder, a published example, or a test fixture that never worked anywhere. Mark accepted false positives with a secrets-scan:allow comment on the line, or record them in a baseline:
    python3 scripts/secrets_scan.py . --write-baseline .secrets-baseline.json
    python3 scripts/secrets_scan.py . --baseline .secrets-baseline.json
    The baseline stores fingerprints only (truncated SHA-256 of rule + value), never values.
  5. Real secret found: rotate, then clean up. Removing it from the code is not enough once it has been committed or pushed. Follow references/rotation.md: revoke/rotate at the provider, deploy the new value from an environment variable or secret manager, check the provider's audit log, then decide whether history rewriting is worth it. Propose every rotation and history rewrite as exact steps and wait for the user to confirm.
  6. Prevent recurrence. Offer the pre-commit and CI setup in references/prevention.md and make sure .gitignore covers .env* (but not .env.example), key files and Terraform state.
RuleTypical meaningAction
private-key, aws-*, github-*, stripe-live-key, provider tokensreal credential formatrotate unless clearly fake
generic-secrethigh-entropy literal assigned to a secret-like nameask the owner; move to env/secret store
url-credentialsscheme://user:password@hostrotate DB/service password; use env vars
jwttoken in code or logsusually a test token; check expiry and where it came from
stripe-test-key (low)test-mode keystill move to env; rotate if repo is public
sensitive-file.env, keys, tfstate presentgit rm --cached, add to .gitignore, rotate contents

Output

secrets scan: 214 files, 3 high, 1 medium, 0 low, 0 info (values redacted)
HIGH   src/config.py:12  aws-access-key-id  AKIA******** (len 20)  fp=3f9c0a...
HIGH   deploy/id_rsa  sensitive-file  SSH private key
MEDIUM docker-compose.yml:31  url-credentials  Tr0u******** (len 14)

Real credentials: 2 (AWS key in src/config.py, SSH key in deploy/). Both were committed in
a1b2c3d (2026-10-02) and pushed to origin -> treat as exposed.
Plan (needs your confirmation): 1) deactivate the AWS key and create a new one ...
False positives: 1 (fixture in tests/, added to baseline).

Always end with: what is real, what was already pushed, the rotation plan, and the prevention step.

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.