Env secrets check
@shipcheck/env-secrets-check
Check your repo for leaked secrets before you push or launch: .env files git tracks or will pick up, .env files hiding in git history, server keys behind NEXT_PUBLIC_ or VITE_ prefixes that ship to the browser, provider key shapes (Stripe, AWS, GitHub, OpenAI, Anthropic, Supabase service_role), and passwords hardcoded in code. Reports names and redacted hints, never the values.
- Activity
- New: be the first to try it
- Installs
- 0 installs
- Likes
- 0 likes
- Clones
- 0 clones
- 1---
- 2name: env-secrets-check
- 3description: Scan a project for leaked secrets before pushing, open-sourcing, or launching. Finds .env files that git tracks or will commit, .env files left in git history, server keys exposed to the browser through NEXT_PUBLIC_, VITE_, EXPO_PUBLIC_ or REACT_APP_ prefixes, provider key shapes (Stripe, AWS, GitHub, OpenAI, Anthropic, Slack, Supabase service_role, database URLs with passwords), and hardcoded passwords. Use when the user says "did I leak any keys", "is my .env safe", "check for secrets", "can I make this repo public", before a first deploy, or after a key-leak warning email.
- 4license: MIT
- 5---
- 7# Env and secrets check
- 9Vibe-coded apps leak keys in a few predictable ways: a `.env` that was never ignored, a service key with a `NEXT_PUBLIC_` prefix so it ships to every browser, or a key pasted straight into code. This skill finds those, ranks them, and walks the user through fixing and rotating. It reports names and short redacted hints only, never full values.
- 11## When to use
- 13- Before the first `git push`, before making a repo public, before launch.
- 14- After GitHub, a provider, or a stranger emails about a leaked key.
- 15- "Is my .env safe?", "did I commit my Stripe key?", "should this be NEXT_PUBLIC?"
- 17## Steps
- 191. **Run the scan** from the project root.
- 21 ```bash
- 22 node scripts/secrets-scan.mjs . --json out/secrets-report.json --md out/secrets-report.md
- 23 ```
- 25 With git it scans tracked files plus new files git would add, and checks history for `.env` files. Without git it follows `.gitignore`.
- 272. **Show the summary** (High, Medium, Low counts) and every high finding in plain words: what leaked, where, and who can see it.
- 283. **Sort the high findings into two piles:**
- 29 - **Already exposed:** the file is committed, in history, pushed, or deployed with a public prefix. These keys must be rotated. Moving them is not enough.
- 30 - **About to be exposed:** not committed yet. Fixing the file is enough.
- 32 Ask whether the repo has been pushed and whether it is public if you cannot tell. `git log` is fine for checking history.
- 334. **Fix, with a yes for each change:**
- 34 - Add missing lines to `.gitignore` (`.env*`, `!.env.example`). Show the lines first.
- 35 - For a committed env file, give the user the command `git rm --cached <file>` to run. It keeps their local copy.
- 36 - For public-prefix secrets, rename the variable (drop the prefix), and move every use into server code (API routes, server actions, edge functions). Show the diff.
- 37 - For hardcoded values, replace them with `process.env.NAME` and add `NAME=` to `.env.example`.
- 385. **Rotation checklist.** For each exposed key, write a numbered list in `out/rotate-keys.md`: the provider, where in its dashboard to roll the key, and where to paste the new one (local `.env.local`, then the host's env settings, then redeploy).
- 396. **Re-run step 1** and show that high is 0.
- 41## Output format
- 43```markdown
- 44# Secrets check: <project>
- 45High 2 | Medium 3 | Low 1
- 47## Rotate now (already exposed)
- 481. STRIPE_SECRET_KEY: committed in .env (git tracks it). Roll it in Stripe, Developers, API keys.
- 50## Fix before you push
- 51- .env.local is not in .gitignore. Added .env* (you said yes).
- 53## Check
- 54- NEXT_PUBLIC_MAPBOX_TOKEN ships to the browser. Fine if it is restricted by URL.
- 55```
- 57## What is public on purpose
- 59These are meant for the browser and are not findings: Supabase URL and anon (publishable) key, Stripe publishable key (`pk_`), Firebase web config, analytics IDs, Sentry DSN, Mapbox tokens restricted by URL. The anon key is only safe when RLS is on; suggest the supabase-rls-audit kit if the project uses Supabase.
- 61## Guardrails
- 63- Never open, print, or paste the contents of `.env` files, and never repeat a full secret value. The script output is redacted; keep it that way.
- 64- Never rewrite git history (`filter-repo`, force push) yourself. If the user wants history cleaned, explain the trade-offs and let them run it. Rotation matters more than history.
- 65- Never call a provider API to test whether a key works.
- 66- Never move a secret into a public prefix to "make it work" in the browser. The fix is a server route.
- 67- A clean scan is not a guarantee. Say so, and mention keys in screenshots, logs, and chat messages too.
