@bobfromarcher/envdoc
v1.0.1
Published
Find every environment variable your code reads, then document it - generate .env.example, a Markdown table, and fail CI on undocumented vars. Zero dependencies.
Maintainers
Readme
envdoc
Finds every environment variable your code reads and tells you which ones are documented. It can generate a .env.example, print a Markdown table, or fail CI when code references a variable that is missing from your .env.example. No dependencies, no AI.
A new process.env.SOMETHING that never makes it into .env.example is a common cause of "works on my machine". envdoc reads your source the way your runtime does and reports the drift.
Install
npm install -g @bobfromarcher/envdoc
# or run once:
npx @bobfromarcher/envdocLanguages
envdoc recognises environment access in JavaScript and TypeScript (process.env.X, process.env['X'], import.meta.env.X), Python (os.environ['X'], os.environ.get('X'), os.getenv('X')), Go (os.Getenv("X"), os.LookupEnv), and Ruby (ENV['X']).
Usage
envdoc [path] [options]| Option | Description |
| --- | --- |
| --write | Write or update .env.example (existing values are kept) |
| --check | Exit 1 if code uses vars missing from .env.example |
| --markdown, --md | Print a Markdown table of all referenced variables |
| --json | Print raw JSON |
| --env <file> | The dotenv file to diff against (default .env.example) |
| -h, --help | Show help |
| -v, --version | Show version |
Examples
envdoc # summary for the current directory
envdoc --write # regenerate .env.example, keeping known values
envdoc src --markdown > ENV.mdGuard it in CI
# .github/workflows/env.yml
- run: npx @bobfromarcher/envdoc --checkThe build fails the moment someone references a variable that is not documented, so your code and your .env.example stay in sync.
Fast path
When ripgrep is on your PATH, envdoc uses it to list files (respecting .gitignore) and scans thousands of files in milliseconds. Without ripgrep it falls back to a built-in Node walk with the same results and still zero npm dependencies.
Development
git clone https://github.com/bobfromarcher/envdoc
cd envdoc
node test/test.jsCI runs the suite on Node 18, 20 and 22 across Linux, macOS and Windows.
License
MIT, bobfromarcher.
