Skip to content
EN · PT

Gate: env-declared

The environment variables a unit’s code reads are the ones its spec declares, and only those.

Property Value
Checker env-declared
Confronts spec
Blocking by default — new project yes
Blocking by default — existing project no — informs
Duplicates a declaration it controls repeated in one file fails it; duplicates: false switches this off

An environment variable is a contract with whoever deploys. A variable the code reads and no spec names is found missing in production; a variable the spec names and the code no longer reads is configured forever for nothing. Like contract-status-declared with the status codes, this gate confronts both sides: the Environment Variables section of the spec against the reads in the code it specifies. A variable declared deprecated may stop being read — it is on its way out.

The code is read with the dialect’s env_read: the project’s own pattern, its language family’s (os.Getenv, process.env, os.environ, System.getenv, ENV[...], getenv, Environment.GetEnvironmentVariable), or every family’s together when the project declares none. A read by a computed name is out of reach of the text.

gates:
- name: env-declared
on: [spec]
check: env-declared

Source: checker · its spec