Skip to content
Learn.env.example

What is a .env.example file?

Also known asenv templatesample env file
Example. Kiteline is a fictional company.
On this page

A .env.example file is a committed template of a project's .env file: it lists every variable the application expects, with placeholder or harmless default values, so a new developer knows what to fill in without anyone sending them the real file.

What it is for

The real .env stays out of version control because it holds secrets. That leaves a gap: how does someone cloning the repository learn which variables exist? The template fills it. Laravel ships one in every new project, and its documentation suggests teams keep "including and updating the .env.example file", because "by putting placeholder values in the example configuration file, other developers on your team can clearly see which environment variables are needed" (Laravel). The same file goes by other names: .env.sample, .env.template, .env.dist.

.env
# Copy to .env and fill in. Ask in #payments for staging values.
DATABASE_URL=postgres://localhost:5432/payments
STRIPE_SECRET_KEY=sk_test_REPLACE_ME
STRIPE_WEBHOOK_SECRET=
LOG_LEVEL=info

A good template also documents. A comment next to a variable can say what format it takes, which values are safe locally, and where the real value comes from.

Common mistakes

  • A real value in the template. Someone copies their .env to .env.example and forgets to blank one line. The template is committed on purpose, so the value is now in Git history, which is the same as a leaked secret.
  • Drift. A developer adds REDIS_URL to their own file and the code, but not to the template. The next person to clone gets a crash, or worse, a silent fallback. This is configuration drift between the template and reality.
  • Defaults that work in production. A placeholder such as SESSION_SECRET=changeme that the app accepts will, sooner or later, be deployed unchanged.
  • The template as the handover. It tells people which values they need, not how to get them. "Ask a colleague" usually ends in a chat message with the real file.

How to keep it in sync

The simplest check compares names, not values: every variable the code reads should appear in the template, and every name in the template should still be used. Some teams fail the build on a mismatch. The compare two .env files tool shows the names that are present in one file and missing from the other, in the browser. A longer treatment is in keeping .env.example in sync.

How Crunu relates to it

Crunu has no special support for template files; it doesn't read or update .env.example. What it changes is the step after the template. Instead of each developer filling in a copy, the team keeps the real values in environments such as payments-api / development, and people get them through their access. Compare environments shows which variables exist only in one environment and which values differ, with values hidden until you choose to show them. When you create an environment with Variable names only, no values, it starts with the names of another environment and none of its values, which is the template idea applied inside the vault.

The template still earns its place in the repository: it documents the variables for people who don't have access yet, and it is the file you can safely let an AI coding agent read. More on the overall setup: how to share .env files with your team.

Sources

From the blog

  • Practices

    Keeping .env.example in sync with every environment

    A .env.example drifts because nothing breaks when it's wrong. Compare names, never values, fail CI on missing variables, and compare real environments.

    Sharing .env files guide

  • Secrets

    Should you commit .env files? What belongs in Git

    Commit the template, never the values. Which .env files go in Git, what frameworks say, encrypted .env files, and where the real values should live.

    Sharing .env files guide

  • Secrets

    source .env can run code: loading env files into a shell

    set -a; source .env runs the file as a shell script, so $(…) and backticks execute. Why shells and dotenv parsers disagree, and safer ways to load .env.

    Sharing .env files guide