Skip to content

Environment Variables

Terminal window
tinkerise add env

The env module checks for existing env-related files:

  • .env
  • .env.example
  • src/env.ts or src/env.js
  • env.ts or env.js

If any are found, the enhancement is considered installed.

env installs two packages:

  • @t3-oss/env-core
  • zod

Then it generates:

  • Env validation module at src/env.ts (or env.ts if src/ does not exist)
  • .env.example
  • .env (initialized from the same template)

It also ensures .env is added to .gitignore.

The generated module uses createEnv() and validates:

  • DATABASE_URL as an optional URL string
  • NODE_ENV as development | production | test with default development

It enables emptyStringAsUndefined for cleaner optional handling.

  • Creates or updates env module source file
  • Creates .env.example and .env
  • Appends .env to .gitignore when missing
  • Adds env validation dependencies

If env files already exist, detection reports the enhancement as installed. For write conflicts during enhancement runs, tinkerise shows a diff and lets you accept or skip changes.