Skip to content
Back to skills

Env Doctor

ASecurity

Check a project's environment variables against its code — variables the code reads that .env.example doesn't document, stale keys nothing reads, keys unset in .env/.env.local (undefined at runtime), secrets exposed to the browser through VITE_/NEXT_PUBLIC_/REACT_APP_-style prefixes, real-looking keys inside .env.example, and .env files committed to git or missing from .gitignore. Never prints values. Use for "works on my machine" bugs, onboarding a repo, before open-sourcing or deploying, or...

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 21, 2026
ai-agentspythonrustgorubyphpshellreactnodedockergit

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 21, 2026

npx -y skills add binay-py/claude-skills --skill env-doctor --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Env Doctor?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Env Doctor
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/binay-py-env-doctor/badge)](https://www.skillsdirectory.com/skills/binay-py-env-doctor)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: env-doctor
description: Check a project's environment variables against its code — variables the code reads that .env.example doesn't document, stale keys nothing reads, keys unset in .env/.env.local (undefined at runtime), secrets exposed to the browser through VITE_/NEXT_PUBLIC_/REACT_APP_-style prefixes, real-looking keys inside .env.example, and .env files committed to git or missing from .gitignore. Never prints values. Use for "works on my machine" bugs, onboarding a repo, before open-sourcing or deploying, or when a variable is undefined.
---

# env-doctor

`scripts/env-doctor.mjs` is zero-dependency Node 22+ and read-only unless `--fix-example`.

```
node env-doctor.mjs [project-dir]
node env-doctor.mjs . --fix-example     # append missing keys (empty) to .env.example, backup kept
```

It finds variable reads in JS/TS (`process.env.X`, `process.env["X"]`, destructuring, `import.meta.env.X`, `Deno.env.get`, `Bun.env`), Python (`os.environ[...]`, `.get`, `os.getenv`), Ruby, Go, PHP, Rust, and `${X}` in shell scripts, Dockerfiles and docker-compose. In Cloudflare Workers projects (a `wrangler.toml/json/jsonc` or `.dev.vars`) it also reads `env.X` and treats `.dev.vars` as the local env file, ignoring names the wrangler config declares as bindings or `[vars]`. It skips `node_modules`, build output and virtualenvs, and ignores standard runtime variables (NODE_ENV, PORT, HOME, CI…).

| Severity | Finding |
|---|---|
| high | a secret-named variable with a **browser-exposed prefix** (`VITE_SUPABASE_SERVICE_ROLE_KEY`, `NEXT_PUBLIC_STRIPE_SECRET`): it ships in the JS bundle. Publishable/anon/site keys are allowed |
| high | a real-looking key or credentialed URL in `.env.example` (localhost/`user:pass` placeholders are fine) |
| high | `.env` / `.env.local` committed to git, or present in git history |
| medium | variables used in code but missing from `.env.example`, or no example file at all |
| medium | variables used in code but not set in any local env file; an env file not in `.gitignore` |
| low | example keys no code reads (or that only a framework config reads); keys set but empty |

## Acting on it
- Browser-exposed secret: move the call server-side (API route, edge function), drop the public prefix, and **rotate the key**, because it's already in every shipped bundle.
- Committed `.env`: `git rm --cached .env`, add it to `.gitignore`, rotate everything in it. History keeps the old values.
- After `--fix-example`, give each new key a placeholder and a one-line comment saying where to get it.

## Limits
Static scan: dynamic names (`process.env[name]`) and variables read only by tools or framework config files (e.g. `DATABASE_URL` read by Prisma's schema) aren't seen, which is why "stale" is only low severity. Hosted env (Vercel/Cloudflare dashboards) isn't checked.

Files in this skill

  • SKILL.md2.8 KB
  • scripts/env-doctor.mjs11 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.