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
- sentimony/skillstheir own version, first seen Nov 1, 2026
- Mcpgate-de/maisecretstheir own version, first seen Oct 23, 2026
- 26zl/universal-agent-skillstheir own version, first seen Oct 6, 2026
- dfrysinger/skillstheir own version, first seen Aug 2, 2026
- GoldenWing-360/claude-security-skillstheir own version, first seen May 12, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- GoldenWing-360/claude-security-skills★ 16same name
- Mcpgate-de/maisecrets★ 8same name
- sentimony/skills★ 7same name
- dfrysinger/skills★ 3same name
- 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
- Very specific: line 24
Before writing the first line of config, check that .gitignore actually contains .env.
- Very specific: line 44
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.
- Very specific: line 55
Put the real value in .env.
- Very specific: line 56
Add the variable name — with a placeholder value — to .env.example.
- Distinctive: line 58
If the value was real, say that it needs rotating: it has been through a model's context window, which is disclosure.
- Distinctive: line 72
Then: remove it from the working tree and commit that.
- Distinctive: line 76
Check for forks and caches you cannot rewrite: forks, mirrors, CI logs, issue and PR comments, the provider's own audit log.
- Distinctive: line 79
Never present history rewriting as the fix.
“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.
Files
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
| Kind | Home | Committed? |
| Local development | .env (gitignored) | no |
| The shape of config | .env.example, placeholders only | yes |
| CI | the runner's secret store (GitHub Actions secrets, etc.) | no |
| Production | the platform's env vars or a secret manager | no |
A key file (.pem, .p12) | gitignored path, or the secret manager | no |
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 bootimport os
key = os.environ["STRIPE_SECRET_KEY"] # KeyError at boot beats None at 3amFail 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.
- Replace the literal with an environment read.
- Put the real value in
.env; confirm.envis gitignored. - Add the variable name — with a placeholder value — to
.env.example. - Tell the user the variable they need to set, by name.
- 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:
- 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.
- Then remove it from the working tree and commit that.
- 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. - 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 committedScope 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"]
}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.

