Scan a codebase for environment variables and generate a documented .env.example.
Every project has environment variables. Few have documentation. You join a project, clone the repo, and then spend 30 minutes hunting through code to figure out what env vars you need.
env-audit fixes this in one command.
- 🔍 Multi-language scanning - Python, Node, Go, Rust, Ruby, Shell, Docker
- 🧠 Smart extraction - Finds default values, marks required vs optional
- 🔒 Sensitive detection - Flags SECRET, KEY, PASSWORD, TOKEN vars
- ✅ CI-friendly -
--checkmode for automated verification - 📝 Multiple formats - .env, TypeScript types, Zod schemas
- 🤖 MCP Server - Agent-friendly tools for Claude, Cursor, etc.
# Scan current directory
python env_audit.py
# Scan a specific path
python env_audit.py /path/to/project
# Save to file
python env_audit.py -o .env.example
# Get JSON output (for tooling)
python env_audit.py --json > env-vars.json
# Just show stats
python env_audit.py --statsUse --check mode to fail CI if there are undocumented env vars:
# In your CI pipeline
python env_audit.py --check
# Exit codes:
# 0 = all vars documented
# 1 = undocumented vars foundExample GitHub Actions workflow:
- name: Check env vars are documented
run: python env_audit.py --checkpython env_audit.py -o .env.exampleGenerates:
# Database connection string (required, sensitive)
# Found in: src/db/connect.py, src/models/user.py
DATABASE_URL=postgresql://user:pass@localhost:5432/dbname
# Server port number (optional, default: 3000)
# Found in: src/server.py
PORT=3000python env_audit.py --format=typescript -o env.d.tsGenerates:
declare namespace NodeJS {
interface ProcessEnv {
/** Database connection string | @sensitive */
DATABASE_URL: string;
/** Server port number | @default 3000 */
PORT?: string;
}
}python env_audit.py --format=zod -o envSchema.tsGenerates:
import { z } from 'zod';
export const envSchema = z.object({
DATABASE_URL: z.string().describe("Database connection string"),
PORT: z.string().default("3000").describe("Server port number"),
});
export type Env = z.infer<typeof envSchema>;For tooling integration, use --json:
python env_audit.py --jsonReturns:
{
"DATABASE_URL": {
"name": "DATABASE_URL",
"category": "database",
"files": ["src/db.py", "src/models.py"],
"occurrences": 5,
"required": true,
"sensitive": true,
"default": null
},
"PORT": {
"name": "PORT",
"category": "api",
"files": ["src/server.py"],
"occurrences": 2,
"required": false,
"sensitive": false,
"default": "3000"
}
}env-audit includes an MCP server for integration with Claude, Cursor, and other AI tools.
pip install fastmcpAdd to ~/.config/claude/claude_desktop_config.json:
{
"mcpServers": {
"env-audit": {
"command": "python",
"args": ["/path/to/env-audit/mcp_server.py"]
}
}
}| Tool | Description |
|---|---|
env_audit_scan |
Scan a project for all env vars |
env_audit_check |
Check if all vars are documented |
env_audit_add |
Add a variable to .env.example |
Claude or other agents can:
> What environment variables does this project need?
[uses env_audit_scan]
> Are all env vars documented?
[uses env_audit_check]
> Add STRIPE_SECRET_KEY to the env example
[uses env_audit_add]
| Language | Patterns |
|---|---|
| Python | os.environ.get(), os.getenv(), os.environ[] |
| Node.js | process.env.VAR, process.env["VAR"], process.env.VAR || "default" |
| Go | os.Getenv() |
| Rust | std::env::var(), env::var() |
| Ruby | ENV[], ENV.fetch(), ENV["VAR"] || "default" |
| Shell | $VAR, ${VAR}, ${VAR:-default} |
| Docker | docker-compose.yml, Dockerfile |
env-audit extracts default values from common patterns:
# Python
os.getenv('PORT', '3000') # → default: 3000
# Node.js
process.env.PORT || '3000' # → default: 3000
# Shell
${PORT:-3000} # → default: 3000Variables with defaults are marked as optional.
Variables containing these keywords are flagged as sensitive:
- SECRET, KEY, PASSWORD, TOKEN, CREDENTIAL, PRIVATE, AUTH
Variables are auto-categorized:
- database: DATABASE, DB_, POSTGRES, MYSQL, MONGO, REDIS
- auth: AUTH, JWT, SECRET, TOKEN, PASSWORD, API_KEY
- api: API_, ENDPOINT, URL, HOST, PORT
- cloud: AWS_, GCP_, AZURE_, S3_
- email: SMTP, EMAIL, MAIL, SENDGRID
- logging: LOG_, DEBUG, SENTRY
- feature: FEATURE_, ENABLE_, DISABLE_, FLAG_
# pip (coming soon)
pip install env-audit
# Or just run directly
python env_audit.py /path/to/project
# With MCP server support
pip install fastmcpSaw this pattern across many projects:
- New dev joins → spends hours figuring out env vars
.env.exampleexists but is outdated- Code has new env vars not in the template
This tool can be run in CI to catch undocumented env vars before they cause onboarding pain.
MIT