agentleFS
HayatelinHayatelin/devsecops-skills/skills/secret-rotation/SKILL.md

secret-rotation

Skill0 starsChanged 5 months agoMITView on GitHub

Calm, correct incident response when a secret is leaked or committed. Trigger when the user says "I committed an API key", "a token leaked", "rotate this secret", "remove a key from git history", or when a scan finds a credential in source or history.

  • Reads credentials
  • Deletes or force-pushes
  • Commits and pushes

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Stay calm and assume compromise: If a secret left your machine, treat it as already in someone's hands.

    line 18
  2. Distinctive:

    Then: remove the secret from the working tree and from git history.

    line 21

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

When to use

  • A secret (API key, token, password, private key, connection string) was committed, pushed, pasted in a PR, or exposed in logs.
  • A scanner (secscan, GitHub secret scanning, gitleaks) flagged a live credential.
  • A laptop, CI runner, or third-party service was compromised.

Process — rotate FIRST, scrub second

  1. Stay calm and assume compromise. If a secret left your machine, treat it as already in someone's hands. The clock matters more than tidiness.
  2. Rotate / revoke at the provider FIRST. Generate a new credential and invalidate the old one in the provider's console (AWS IAM, Stripe, GitHub, etc.). Deleting the line in code does NOTHING — the old value still works until revoked.
  3. Deploy the new secret to env vars / your secrets manager and verify the app works on the rotated value.
  4. Then remove the secret from the working tree and from git history.
  5. Audit for misuse — check provider access logs / billing for unexpected activity during the exposure window.
  6. Prevent recurrence — add a pre-commit secret scan and move config to a manager (see "How to fix").

Checklist

  • New credential issued and confirmed working in the target environment.
  • Old credential REVOKED at the provider (not just removed from code).
  • Secret pulled from source and .gitignore/secrets manager updated.
  • Secret purged from git history (commands below) and force-pushed.
  • Collaborators told to re-clone or hard-reset (rewriting history breaks their local copies).
  • Provider access/audit logs reviewed for abuse during exposure.
  • Pre-commit secret scanning enabled to stop a repeat.

How to fix

  • Purge from history (after rotating). Preferred: git filter-repo --invert-paths --path path/to/file or for a value: git filter-repo --replace-text expressions.txt. Alternative: BFG — bfg --replace-text passwords.txt. Then git push --force to all remotes. Note: GitHub caches; the old commit may still be reachable via its SHA, so rotation is what actually protects you.
  • Store secrets properly — environment variables, AWS/GCP/Vault secrets manager, GitHub Actions encrypted secrets, or a .env that is git-ignored. Never in source, never in client-side bundles.
  • Prevent — install gitleaks/secscan as a pre-commit hook and enable provider-side secret scanning + push protection.

Report back

State plainly: what leaked, where, the exposure window, and — most important — that the credential was REVOKED and ROTATED (not just deleted). Then list history-purge status, log-review findings, and the prevention control you added. If rotation is still pending, say so loudly: until the old value is revoked, the incident is open.

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.