agentleFS
lglucaslglucas/ai-dev-operating-system/.claude/skills/secrets-discipline/SKILL.md

secrets-discipline

Skill12 starsChanged 47 days agoMITView on GitHub

Enforce safe handling of API keys, tokens, passwords, and credentials — env files, `.gitignore` coverage, `.env.example` upkeep, rotation after exposure. This is the PREVENTIVE workflow; `secrets-scan` is the detection pass that finds what already leaked. Run when adding an integration, before commits, before a first deploy, and when the user pastes something that looks like a credential or says "essa é minha chave da OpenAI", "onde eu coloco esse token?", "posso commitar o .env?".

  • Reads credentials

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

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

    Before any commit if any file in the changeset contains an = followed by a long opaque string.

    line 12
  2. Very specific:

    Never paste real secrets into source code: Always use process.env.X (or framework equivalent).

    line 17
  3. Very specific:

    Always update .env.example: when introducing a new env var.

    line 18
  4. Distinctive:

    One secret, one env var: Don't reuse the same key for unrelated services.

    line 21
  5. Distinctive:

    Rotate after exposure: If a secret was committed at any point (even in a deleted file), rotate it.

    line 22
  6. Very specific:

    Run a quick scan: search for accidental literal API keys — the patterns in .claude/rules/secrets.md (sk-, ghp_, github_pat_, AKIA, …

    line 34
  7. Distinctive:

    If any literal secret is found in a tracked file, stop and ask the user to rotate.

    line 35

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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 Discipline

When to run this skill

  • The user is adding a new integration (Stripe, Supabase, OpenAI, etc.).
  • The user pastes a string that looks like a secret (long random, starts with sk-, sk_, pk_, re_, ghp_, AKIA, etc.).
  • Before any commit if any file in the changeset contains an = followed by a long opaque string.
  • The user says "vou colocar a chave" / "where do I put my key".

Rules

  1. Never paste real secrets into source code. Always use process.env.X (or framework equivalent).
  2. Always update .env.example when introducing a new env var. The example file documents the existence of the variable, not its value.
  3. Never commit .env or any .env.<stage> — .env.local, .env.development, .env.staging, .env.production. Only the templates (.env.example, .sample, .template, .dist) are committed. The rest are gitignored — verify before commit.
  4. Server-only secrets must stay server-only. In Next.js, anything starting with NEXT_PUBLIC_ is shipped to the browser. If it's a secret, do NOT prefix it.
  5. One secret, one env var. Don't reuse the same key for unrelated services.
  6. Rotate after exposure. If a secret was committed at any point (even in a deleted file), rotate it. Git history retains it.

Vibe coder explanation

Secrets are like the keys to your house. The .env file is the keychain you keep at home. The .env.example is the description of what keys you need (front door, garage, mailbox) without showing what they look like. When you share your project on GitHub, you share the description — never the actual keys.

Workflow

  1. Identify all secret-like values in the proposed change.
  2. Confirm each is referenced via process.env.X (or equivalent).
  3. Confirm .env.example documents each new variable with a comment explaining purpose.
  4. Confirm .env and .env.* are in .gitignore, with the templates excepted (git check-ignore .env.development must print the name).
  5. Run a quick scan: search for accidental literal API keys — the patterns in .claude/rules/secrets.md (sk-, ghp_, github_pat_, AKIA, private-key headers) — the hook in .claude/hooks/ blocks the same set at commit time — plus sk_[a-zA-Z0-9]{20,}, pk_[a-zA-Z0-9]{20,}, re_[a-zA-Z0-9]{20,}, AIza[a-zA-Z0-9\-_]{35}.
  6. If any literal secret is found in a tracked file, stop and ask the user to rotate.

Output

✅ secrets-discipline check
- New variables documented in .env.example: STRIPE_WEBHOOK_SECRET
- No literal secrets in source code
- .gitignore covers .env files
- Server-only vars not exposed via NEXT_PUBLIC_

⚠️  If you committed a real key earlier, rotate it now in the provider dashboard.

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.