Where to get the list of required keys
| Source | Reliability | How |
|---|---|---|
| Your source code | high: it's what actually runs | switch to scan source code and paste the files that read env |
| Startup schema (zod, envalid, pydantic-settings) | high, if kept up to date | copy the field names |
.env.example | medium: drifts over time | paste it as is, values are ignored |
| Hosting dashboard export | shows what is set, not what is needed | use it as the .env side |
Quick way to collect code references across a repository:
# list every process.env / import.meta.env key used in src/ grep -rhoE '(process\.env|import\.meta\.env)\.[A-Z_][A-Z0-9_]*' src | sed 's/.*\.//' | sort -u
Failing fast when a variable is missing
The detector catches gaps before a deploy; a startup check catches them at deploy time, before the first request:
import { z } from "zod";
export const env = z
.object({
DATABASE_URL: z.string().url(),
JWT_SECRET: z.string().min(32),
STRIPE_SECRET_KEY: z.string().startsWith("sk_"),
})
.parse(process.env); // throws with a list of every missing/invalid keyPython has the same pattern with pydantic-settings, see the Python .env generator. For the runtime symptoms of missing keys, read how to fix .env errors.
Keeping .env.example in sync
- Scan the code here and compare against
.env.exampleas the .env side: missing keys belong in the template. - Regenerate the template from a complete .env with the .env.example generator.
- Compare environments with the ENV diff checker before promoting a release.