Validate .env files against a JSON schema (string, int, bool, enum, url, duration, pattern) and generate a .env.example. Use when checking a .env file, documenting required variables or catching config drift. Prints key names only, never values.
95%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
A schema is a JSON object with a vars map and an optional allowUnknown flag. Unknown fields
anywhere are rejected.
{
"allowUnknown": false,
"vars": {
"APP_ENV": { "type": "enum", "values": ["development", "staging", "production"], "required": true },
"PORT": { "type": "int", "min": 1, "max": 65535, "default": "8080" },
"DEBUG": { "type": "bool", "default": "false" },
"DATABASE_URL": { "type": "url", "required": true, "secret": true },
"REQUEST_TIMEOUT": { "type": "duration", "default": "30s" },
"SESSION_SECRET": { "type": "string", "required": true, "secret": true, "minLength": 32 },
"SERVICE_NAME": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$", "maxLength": 40 }
}
}| Field | Type | Meaning |
|---|---|---|
type | string, required | string, int, bool, enum, url or duration. |
required | boolean | The key must appear in the file, unless it has a default. |
secret | boolean | Value is left empty in the generated .env.example. |
default | string | Used in .env.example (when not secret); must satisfy the variable's own rules. |
min, max | integer | Bounds for int (min must not exceed max). |
values | list of strings | Allowed values for enum; at least one is required. |
pattern | string | Regular expression for string, searched in the value. |
minLength, maxLength | integer | Length bounds for string, counted in bytes. |
int: optional sign and decimal digits that fit in 64 bits.bool: exactly true, false, 1 or 0.url: has a scheme and a host (https://example.test/path); no spaces or control characters.duration: Go duration syntax such as 30s, 1h30m, 250ms, 1.5s, or 0; units ns,
us, ms, s, m, h.enum: exactly one of values, case-sensitive.string: any text, optionally bounded by minLength, maxLength and pattern.| Code | Meaning | Message form |
|---|---|---|
E001 | Required key missing (line 0). | KEY is required |
E002 | Value has the wrong type. | KEY must be an int (or bool, url, duration) |
E003 | Number outside min/max or string outside minLength/maxLength. | KEY must be >= 1 |
E004 | Value does not match pattern. | KEY does not match the required pattern |
E005 | Value is not one of the enum values. | KEY must be one of a|b|c |
E006 | Key not in the schema (only when allowUnknown is false). | KEY is not in the schema |
E007 | Key defined more than once. | KEY is defined more than once |
Messages never contain the value. Issues are sorted by line, then key, then code.
.env.exampleFor each variable, sorted by name:
# <type>[, required][, secret]
KEY=<default, or empty for secrets and variables without a default>