1---2name: secrets-hygiene3description: Use when committing, opening a PR, editing configs, or pasting logs. Scan diffs and config for credentials and secrets; never commit API keys, tokens, private keys, or passwords — redact and rotate if exposure is suspected.4---56# Secrets Hygiene78## When to use910- Preparing a commit, PR, patch, or shareable log/snippet.11- Editing `.env` examples, CI configs, Dockerfiles, Terraform, or Helm values.12- The user pastes credentials or asks to "wire up" a third-party API.1314## When not to use1516- Discussing secret-management architecture at a pure design level with no files touched.17- Working exclusively with already-public, non-sensitive sample data clearly marked as fake.1819## Assumptions2021- Access to `git diff` / `git status` and the working tree.22- Ability to search the repo for high-entropy strings and known secret patterns.23- Secret stores (GitHub Actions secrets, Vault, cloud SM) may exist — prefer them over files.24- Do **not** push, force-push, or amend shared history to "hide" a leaked secret without an explicit incident plan (rotation first).25- Do **not** print full live secrets into chat, logs, or PR bodies.2627## Workflow28291. Before staging, scan the diff and any new config files for secret-shaped values.302. Move real secrets to the environment or a secret manager; keep only placeholders in git.313. Ensure `.gitignore` / example env files cannot accidentally track real values.324. If a secret may already be in history or a remote, stop and plan rotation + scrub with the user.335. Proceed with commit/PR only when the diff is clean of credentials.3435## Steps36371. **Diff scan** — Review `git diff` and untracked files for keys named `*SECRET*`, `*TOKEN*`, `*PASSWORD*`, `*_KEY`, `Authorization`, PEM blocks, and connection strings with credentials.382. **Pattern check** — Flag JWTs, AWS-like keys, private key headers (`BEGIN … PRIVATE KEY`), and long high-entropy literals in source.393. **Separate concerns** — Real values → env / secret manager. Docs and examples → obviously fake placeholders (`sk_test_…`, `REPLACE_ME`).404. **Ignore rules** — Confirm `.env`, key files, and local overrides are ignored; commit `.env.example` without real values only.415. **Output hygiene** — Redact secrets in logs, screenshots, and PR text. Never echo `printenv` wholesale.426. **Leak response** — If exposure is plausible: revoke/rotate first, then discuss history rewrite. Do not assume "delete the file" is enough.4344## Success criteria4546- [ ] No live credentials, private keys, or password-bearing URLs appear in the staged diff.47- [ ] Examples use placeholders; real secrets live outside version control.48- [ ] `.gitignore` (or equivalent) covers local secret files.49- [ ] Suspected leaks triggered a rotation plan before further pushes.50- [ ] Chat/PR output does not contain full secret values.5152## Out of scope5354- Implementing a full company-wide secrets platform.55- Cryptographic key ceremony design beyond basic hygiene.56- Legal/compliance attestation (SOC2 evidence packs).