agentleFS
RiyanKothariRiyanKothari/riyans-claude-skills/skills/secrets-hygiene/SKILL.md

secrets-hygiene

Skill1 starsChanged 39 days agoMITView on GitHub

Keeping credentials out of files, stores and repositories — redacting at write time, scanning before committing, and handling a leak that already happened. Use before committing or publishing anything, before storing prompt or conversation text, when initialising a repo, and whenever a tool persists user input to disk.

6 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

3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 2

    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. Very specific:

    After redacting the text field, secrets were still on disk — in _terms, a tokenized search index built from the text *before* redaction and …

    line 41
  2. Distinctive:

    Check what is actually staged.

    line 56
  3. Distinctive:

    If it ever reached a public remote, treat it as fully public regardless of how briefly it was up.

    line 66

“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 Hygiene

Redact at write time, not before commit

Anything built from prompts or conversation text will eventually contain a live credential, because people paste keys into chat. Scrubbing at commit time is too late — by then it has been synced, backed up or shared.

A memory store here was seeded from real transcripts and picked up seven records containing Razorpay keys, an Anthropic key, a Gemini key, Meta tokens and a Postgres URL. The fix was redaction inside add(), so a secret never reaches disk at all.

const SECRET_PATTERNS = [
  /\bsk-ant-[A-Za-z0-9_-]{16,}/g,
  /\brzp_(?:test|live)_[A-Za-z0-9]{10,}/g,
  /\bAIza[A-Za-z0-9_-]{20,}/g,
  /\bgh[pousr]_[A-Za-z0-9]{20,}/g,
  /\bEAA[A-Za-z0-9_-]{20,}/g,
  /\b(?:postgres(?:ql)?|mysql|mongodb(?:\+srv)?):\/\/[^\s:@]+:[^\s@]+@\S+/gi,
  /\b(?:api[_-]?key|secret|token|password)\s*[:=]\s*["']?[A-Za-z0-9_\-./+]{12,}["']?/gi,
  /\bBearer\s+[A-Za-z0-9._-]{20,}/g,
];

Redact rather than reject — the record keeps its value, the secret does not survive.

Get the character classes right. The first version used [A-Za-z0-9] and missed every Meta token, because those contain _ and -. A pattern that half-matches gives false confidence.

Derived data leaks too

After redacting the text field, secrets were still on disk — in _terms, a tokenized search index built from the text before redaction and then serialized alongside it.

Any cache, index, embedding or log derived from sensitive input inherits the sensitivity. The fix was to stop persisting derived state at all: it is rebuildable, it bloated the file, and it leaked. The store shrank 54KB to 35KB as a side effect.

Before a repo goes public

  1. git init in the project, not a parent. Check git rev-parse --show-toplevel — a project inside a home-directory repo will publish far more than intended.
  2. Grep the staged set for credential shapes before the first commit.
  3. Gitignore user data by default: memory stores, logs, local settings, *.bak.
  4. Check what is actually staged. 329 files here turned out to include 246 files of another tool's generated content.

If a secret was already committed

Deleting the file is not enough — git history keeps it. Assume it is compromised:

  1. Rotate the key first. Cleaning history without rotating protects nothing.
  2. Then purge with git filter-repo or BFG, and force-push with the team warned.
  3. If it ever reached a public remote, treat it as fully public regardless of how briefly it was up.

Never put secrets in these

URLs and query strings, log lines, error messages, commit messages, or anything sent to a third-party service — including diagram renderers and pastebins.

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.