agentleFS
ShendLlapashticaShendLlapashtica/leak-guard/skills/secret-hygiene/SKILL.md

secret-hygiene

Skill1 starsChanged 15 days agoMITView on GitHub

How to handle an API key, token, password or connection string in a repository - where the value goes, what gets committed, and what to do when one has already been committed or pushed. Use when wiring up authentication or a third-party API, when adding config, when a write was denied for containing a credential, or when the user pastes a key into the conversation.

  • Reads credentials

5 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions5 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 5

    1. GoldenWing-360/claude-security-skills★ 16same name
    2. Mcpgate-de/maisecrets★ 8same name
    3. sentimony/skills★ 7same name
    4. dfrysinger/skills★ 3same name
    5. 26zl/universal-agent-skills★ 2same 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.

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 4

    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 writing the first line of config, check that .gitignore actually contains .env.

    line 24
  2. Very specific:

    Never log it, never put it in a URL query string (it lands in access logs, proxy logs and Referer headers), never ship it to the browser.

    line 44
  3. Very specific:

    Put the real value in .env.

    line 55
  4. Very specific:

    Add the variable name — with a placeholder value — to .env.example.

    line 56
  5. Distinctive:

    If the value was real, say that it needs rotating: it has been through a model's context window, which is disclosure.

    line 58
  6. Distinctive:

    Then: remove it from the working tree and commit that.

    line 72
  7. Distinctive:

    Check for forks and caches you cannot rewrite: forks, mirrors, CI logs, issue and PR comments, the provider's own audit log.

    line 76
  8. Distinctive:

    Never present history rewriting as the fix.

    line 79

“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

Secret hygiene

The one rule

A credential never appears as a literal in a file git tracks. Not in source, not in a config file, not in a test, not in a comment, not in a README, not "temporarily". Everything below follows from that.

Where the value goes

KindHomeCommitted?
Local development.env (gitignored)no
The shape of config.env.example, placeholders onlyyes
CIthe runner's secret store (GitHub Actions secrets, etc.)no
Productionthe platform's env vars or a secret managerno
A key file (.pem, .p12)gitignored path, or the secret managerno

Before writing the first line of config, check that .gitignore actually contains .env. A .env that is already tracked keeps being committed no matter what you add to .gitignore later — git rm --cached .env is what untracks it.

Reading it in code

const key = process.env.STRIPE_SECRET_KEY;
if (!key) throw new Error('STRIPE_SECRET_KEY is not set');   // fail loudly at boot
import os
key = os.environ["STRIPE_SECRET_KEY"]      # KeyError at boot beats None at 3am

Fail at startup, not at the call site. A missing credential discovered on the first request is an outage; discovered at boot it is a deploy that did not happen.

Never log it, never put it in a URL query string (it lands in access logs, proxy logs and Referer headers), never ship it to the browser. Anything a browser can read is public — NEXT_PUBLIC_*, VITE_* and friends are compiled into the bundle, so only a publishable key goes there.

When a write is denied for containing a credential

The guard denied it because the file would be committed. Do not retry the write, and do not work around it by writing the value somewhere else.

  1. Replace the literal with an environment read.
  2. Put the real value in .env; confirm .env is gitignored.
  3. Add the variable name — with a placeholder value — to .env.example.
  4. Tell the user the variable they need to set, by name.
  5. If the value was real, say that it needs rotating: it has been through a model's context window, which is disclosure.

A credential belongs in .env and the guard allows that, so there is never a reason to hardcode one to "get it working first".

When one has already been committed

Say this plainly, in this order, because the order is what people get wrong:

  1. Rotate it now. This is the only step that actually fixes anything. Everything else is tidying. If the commit was pushed to a public remote, assume the credential was harvested within minutes — scanners watch the firehose, and GitHub keeps pushed objects reachable even after a force-push.
  2. Then remove it from the working tree and commit that.
  3. Only then, if it matters, rewrite history (git filter-repo, or BFG) and force-push. Warn the user this rewrites every commit hash, breaks open pull requests and requires every collaborator to re-clone or hard-reset.
  4. Check for forks and caches you cannot rewrite: forks, mirrors, CI logs, issue and PR comments, the provider's own audit log.

Never present history rewriting as the fix. "I removed it from the repo" is not remediation; the key still works until it is rotated.

Checking

/leak-scan            # the whole repository
/leak-scan --staged   # just what is about to be committed

Scope false positives in .leakguard.json at the project root rather than switching the guard off:

{
  "allow": ["hardcoded-credential"],
  "skip": ["test/fixtures/"],
  "forbid": ["my-internal-hostname.example"]
}

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.