Skip to content

commandDevOps and cloud

Document Env Vars

Finds every environment variable your code reads and writes an example env file plus a table of what each one does.

npx workspacetemplates add document-env-vars --tool claude-code

Writes 1 file to .claude/commands/

.claude/commands/document-env-vars.md14 lines · 1.2 KBFile
---
description: Finds every environment variable your code reads and writes an example env file plus a table of what each one does.
argument-hint: "[folder, default whole project]"
---

Document the environment variables used by: $ARGUMENTS (whole project if empty).

1. Search for reads in every language present: `process.env`, `import.meta.env`, `os.environ`, `os.getenv`, `ENV[`, `System.getenv`, `std::env::var`, and config loaders such as dotenv or pydantic settings. Also search Dockerfiles, compose files, CI workflows and shell scripts.
2. For each variable record: name, file and line of first use, whether code fails without it (required) or falls back to a default, the default value, and the expected type or format.
3. Mark likely secrets by name (KEY, TOKEN, SECRET, PASSWORD, DSN). Leave their example value empty or as a clear dummy value such as `changeme`.
4. Read existing .env files only to learn names. Never print or copy actual values.
5. Write `.env.example` grouped by area with a comment above each line, and a Markdown table with the columns Name, Required, Default, Purpose.

Show the table and the file contents, list variables found in code but missing from the old .env.example, and ask before creating or overwriting anything.

What it does

New teammates lose an afternoon to a missing variable that nobody wrote down. This command searches the code, scripts and deployment files for every place the environment is read and builds the documentation from what it finds.

It marks which variables are required, which have defaults and which look like secrets, and it never copies real values from your own env file.

Example

you › /document-env-vars

agent › Found 17 variables in 9 files. Required: DATABASE_URL, SESSION_SECRET, STRIPE_KEY. 4 are in code but missing from .env.example (REDIS_URL, LOG_LEVEL, SENTRY_DSN, PORT). Write the new .env.example and docs table?

Questions

Does it copy values from my real .env?
No. It reads only the names there. Example files get dummy values.
Will it find variables set in CI?
Yes, it also scans workflow files, compose files and Dockerfiles for names the app expects.
  • Debug Container

    Commanddocker

    Free
  • Deploy Checklist

    CommandDevOps and cloud

    Free
  • Dockerize

    Commanddocker

    Free
  • Review Terraform Plan

    Commandterraform

    Free