agentleFS
AL-JANEFAL-JANEF/janef-forge/skills/security/secrets-guard/SKILL.md

secrets-guard

Skill1 starsChanged 54 days agoMITView on GitHub

Keep secrets out of code, git history, logs, and client bundles: detect hardcoded API keys, credentials, tokens, and connection strings; move them to the environment or a secret manager; catch client-exposed prefixes; set up gitignore and pre-commit scanning; run the rotate-first response when a secret has leaked. Use for any credential, .env, or "where do I put my key?" question.

  • Reads credentials

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 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.

  • 2

    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:

    Use it whenever code touches credentials: adding an API key, wiring up a database connection, configuring an external service (payment, …

    line 25
  2. Distinctive:

    If a real secret is found in code or history: flag it as compromised and requiring rotation, not just removal.

    line 43
  3. Distinctive:

    Never log secrets — check that error handlers and request loggers don't print auth headers, tokens, or connection strings.

    line 77
  4. Distinctive:

    When auditing, report clearly and rank by exposure:

    line 85
  5. Very specific:

    Do not print the full secret value in the report — reference it by type and location (Stripe secret key in config.js:12), show at most a …

    line 103

≈ “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 Guard

A leaked secret is one of the fastest paths to a breach — a single committed API key can hand an attacker the whole system. This skill keeps secrets out of the places they leak from, and cleans them up when they've already landed there.

The rule underneath everything: a secret belongs in the runtime environment, never in the source. If it's in a file that gets committed, shipped to the browser, or printed to a log, treat it as compromised.

When to reach for this skill

Use it whenever code touches credentials: adding an API key, wiring up a database connection, configuring an external service (payment, messaging, storage), setting up .env files, or committing configuration. Also whenever the user asks where to store a key or whether something is safe to commit. The presence of a credential is the trigger.

What to do

1. Detect secrets already present

Scan for hardcoded credentials in the code and config: high-entropy strings, apiKey = "...", connection strings with embedded passwords, private key blocks, tokens in source. Common shapes: cloud keys, database URLs like postgres://user:pass@host, JWT signing secrets, third-party service keys (payment, messaging). Also check what's already committed to git history, not just the working tree — a secret removed from the current code but still in history is still leaked.

If a real secret is found in code or history: flag it as compromised and requiring rotation, not just removal. Once a secret has been committed to a shared repo, deleting it doesn't un-leak it — it must be rotated (regenerated) at the provider. See references/leak-response.md.

2. Move secrets to the environment

Secrets load from environment variables (or a secret manager), never from source:

// wrong — in source
const key = "replace-me";

// right — from environment
const key = process.env.STRIPE_SECRET_KEY;

Provide a committed .env.example with the names and dummy values, and keep the real .env untracked. For production, prefer a managed secret store (the platform's secret manager) over shipping .env files around.

3. Watch the client boundary

The most dangerous secret leak in modern frameworks: putting a secret in code that ships to the browser. In Next.js and similar, anything prefixed for client exposure (e.g. NEXT_PUBLIC_*) is embedded in the bundle and readable by anyone. A secret must never carry a public/client prefix. Only truly public values (publishable keys designed for the client) belong there. Verify which side of the client/server boundary each key lives on.

4. Prevent recurrence

Set up guards so secrets can't slip in again:

  • .gitignore includes .env, .env.* (but allow .env.example).
  • A pre-commit secret scanner (gitleaks, or a hook) blocks commits containing secret-shaped strings.
  • Never log secrets — check that error handlers and request loggers don't print auth headers, tokens, or connection strings.

See references/setup.md for concrete gitignore, .env.example, and pre-commit scanner configuration.

Output format

When auditing, report clearly and rank by exposure:

## Secrets Audit: <target>

### Exposed / compromised   (rotate immediately)
- <secret type> at <location> — committed / in history / in client bundle → rotate + remove

### Misplaced   (move to environment)
- <secret> hardcoded at <location> → move to env var <NAME>

### Prevention gaps
- <e.g. .env not gitignored, no pre-commit scan>

### Verified good
- <secrets correctly externalized>

Do not print the full secret value in the report — reference it by type and location (Stripe secret key in config.js:12), show at most a masked fragment. Printing it in full just copies the leak into a new place.

Proof before done

Demonstrate the fix: the secret no longer appears in the built client bundle (grep the build output), the app still runs reading from env, and the pre-commit scanner actually blocks a test secret. For a rotated key, confirm the old one is revoked at the provider.

References

  • references/setup.md — Copyable .gitignore, .env.example, and pre-commit secret-scanner config. Read it when setting up prevention.
  • references/leak-response.md — Step-by-step response when a real secret has already been committed (rotate, purge, prevent). Read it when a live leak is found.

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.