Commands
Audit environment variable usage in source against your .env files.
Finds every statically identifiable environment variable reference and compares it with your env files.
broom envbroom env --jsonbroom env --verbosebroom env --fix # add empty placeholders to .env.example (asks first)broom env --fix --yes # same, without prompting broom env 4 variables referenced in 8 source files, 3 env files found. Missing (referenced, not defined in any env file) API_URL app/page.tsx:9 not in example SECRET_TOKEN app/dashboard/page.tsx:3 not in example Duplicate definitions API_KEY .env lines 3, 4 Client exposure app/dashboard/page.tsx SECRET_TOKEN used in a 'use client' component without the NEXT_PUBLIC_ prefix; it will be undefined in the browser Unused (defined, never referenced) API_KEY .env, .env.example STALE_FLAG .env 8 issues found.In source files (.js .jsx .ts .tsx .mjs .cjs .mts .cts):
process.env.KEY, process.env["KEY"], template-literal keys and optional chainingconst { A, B: b, C = 'x' } = process.env'KEY' in process.env, process.env.hasOwnProperty('KEY')import.meta.env.VITE_KEY, import.meta.env["VITE_KEY"](process.env as any).KEYComments and strings never match. Accesses that cannot be resolved statically (process.env[name], { ...rest } = process.env, passing process.env around) are listed as dynamic and make "unused" findings potential.
.env and .env.* files anywhere in the project are read. .gitignore is intentionally not applied here so local files are found. .example, .sample, .template and .dist files document variables; *.local files are local overrides. Values are never printed.
| Finding | Meaning |
|---|---|
| Missing | Referenced but not defined in any env file (examples excluded when real env files exist). |
| Undocumented | Referenced but absent from .env.example. |
| Duplicate definitions | The same key twice in one file. |
| Unused | Defined but never referenced. Potentially unused when dynamic access, non-JS config files (Docker, Prisma, CI, package.json) or tooling might read it. |
| Client exposure | Next.js 'use client' files reading non-NEXT_PUBLIC_ variables; Vite import.meta.env without the VITE_ prefix (skipped if envPrefix is configured). |
Runtime-provided variables (NODE_ENV, CI, PATH, npm_*, Vite's MODE/DEV/PROD/SSR/BASE_URL, and others) are never reported as missing.
| Flag | Description |
|---|---|
--fix | Append NAME= placeholders for missing variables to the root .env.example, creating it if needed. Asks first. |
-y, --yes | Skip confirmation prompts. |
--fix only appends empty NAME= lines. It never invents values.
Found a problem in these docs? Open an issue on GitHub.