CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

trysac/dotenv-schema

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.

Quality

95%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files
name:
dotenv-schema
description:
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.
license:
MIT
compatibility:
Needs Python 3 only (standard library). No network access. Reads only the files you give by path and never the process environment.

dotenv-schema

Check that a .env file has the variables an application expects, with the right shapes, and keep .env.example in sync from the same schema. The bundled script works on its own: nothing to install or build.

Safety rules (always apply)

  • Work on files the user points to by path. Never read the process environment, never run env, printenv or echo $VAR, and never open .env files nobody asked you to check.
  • Never print, quote or paste a value from a .env file. The script reports key names, line numbers and issue codes only; keep your own answers to that level too.
  • Never write real secrets into a schema, an example or your reply. Use obviously fake values.

When to use

  • A user asks whether a .env file is valid, complete or misconfigured.
  • A project needs a documented list of its variables, or a .env.example that matches reality.
  • CI should fail when a required variable is missing or has the wrong type.

Workflow

  1. Find or write the schema (a JSON file). Format and a full example are in references/schema.md. If none exists, draft one from the code that reads configuration, mark credentials "secret": true, and show it to the user.

  2. Validate one or more files:

    python3 scripts/dotenv_schema.py --schema schema.json .env
    python3 scripts/dotenv_schema.py --schema schema.json --json .env .env.production

    Put options before the file names. Output is one line per issue, file:line: CODE message (--json prints an array of {code, key, line, message}). Line 0 means the issue is not tied to a line, for example a missing required key.

  3. Explain each issue using the codes in references/schema.md: E001 required, E002 type, E003 range or length, E004 pattern, E005 enum, E006 unknown key, E007 duplicate key. Say which key and line to change and what shape is expected, never what the current value is.

  4. Generate the template:

    python3 scripts/dotenv_schema.py --schema schema.json --example > .env.example

    Variables are sorted by name, each preceded by # <type>[, required][, secret]. Secrets and variables without a default are written empty.

  5. Exit codes: 0 valid, 1 issues found, 2 usage, I/O, syntax or schema error. A syntax error in the .env file stops the run and reports the line and reason, not the content.

Parsing rules in short

Blank lines and # comment lines are skipped; an export prefix is accepted; keys match ^[A-Za-z_][A-Za-z0-9_]*$ and = is required. Unquoted values are trimmed and cut at the first #. Single-quoted values are literal. Double-quoted values support \n, \t, \" and \\ and cannot span lines. There is no variable expansion. Limits: 1 MiB per file, 10,000 lines, 65,536 bytes per value.

Limits

  • The schema is strict: unknown fields are rejected, at most 1,000 variables, 1 MiB.
  • Patterns use Python regular expressions in this script, searched anywhere in the value; anchor with ^ and $ for a full match.
  • Only .env syntax as described above. No shell semantics, no ${VAR} expansion, no multi-line values.
  • The script never writes files except through your shell redirection, never uses the network and never reads environment variables.

Source

This skill bundles a standard-library port of the validator implemented by the dotenv-schema Go package: https://github.com/Trysac/u275-dotenv-schema

Workspace
trysac
Visibility
Public
Created
Last updated
Source
CLI
Repository
No repository linked. Set repository in the plugin manifest, or publish from a GitHub Action to verify it.
Badge
trysac/dotenv-schema badge