env-validator
Env Validator
Validates environment variable configurations by cross-referencing .env files against
project requirements. Catches missing variables, type errors, insecure defaults, and
orphaned entries before they cause runtime failures.
Reference Files
| File | Contents | Load When |
|---|---|---|
references/validation-rules.md |
Built-in validation rules and severity definitions | Always |
Prerequisites
- A
.envfile (or equivalent) in the project - Optionally:
.env.example,docker-compose.yml, or deployment manifests for cross-referencing
Workflow
Phase 1: Discovery
Locate environment configuration sources in the project:
- Primary file: Find
.envin the project root. If absent, check for.env.local,.env.development,.env.production - Schema file: Find
.env.exampleor.env.template— this defines the expected variables - Code references: Grep for
os.environ,process.env,env::var,os.Getenvpatterns to find variables referenced in code - Deployment manifests: Check
docker-compose.yml,Dockerfile,k8s/manifests for${VAR}orENV VARpatterns
Report what was found before proceeding.
Phase 2: Schema Extraction
Build the expected variable schema from discovered sources:
For each variable found across all sources, record:
| Field | Source |
|---|---|
| Name | Variable name (e.g., DATABASE_URL) |
| Required | Present in code references or marked required in example |
| Type hint | Inferred from usage (URL, integer, boolean, string, path) |
| Default | Value in .env.example if present |
| Used in | List of files that reference this variable |
Phase 3: Validation
Run these checks against the primary .env file:
-
Missing required variables (CRITICAL)
- Variable referenced in code but absent from
.env - Variable in
.env.examplewithout a default but absent from.env
- Variable referenced in code but absent from
-
Type mismatches (HIGH)
PORT=abcwhen code doesint(os.environ["PORT"])DEBUG=yeswhen code expects boolean (true/false)- URL variables without valid URL format
-
Insecure defaults (HIGH)
SECRET_KEY=changeme,PASSWORD=password,API_KEY=xxxDEBUG=trueorDEBUG=1in production-targeted files- Empty values for security-critical variables
-
Unreferenced variables (MEDIUM)
- Variables in
.envnot referenced anywhere in code or manifests - May indicate stale configuration
- Variables in
-
Format issues (LOW)
- Lines without
KEY=VALUEformat - Trailing whitespace in values
- Inconsistent quoting (mixing single/double/no quotes)
- Duplicate variable definitions (last wins, but likely a mistake)
- Lines without
See references/validation-rules.md for the complete rule catalog.
Phase 4: Report
Produce a structured validation report:
# Environment Validation Report
**File:** `.env`
**Schema:** `.env.example` + code references
**Verdict:** PASS | FAIL
## Summary
| Severity | Count |
|----------|-------|
| CRITICAL | N |
| HIGH | N |
| MEDIUM | N |
| LOW | N |
## CRITICAL
### [ENV-001] Missing required variable: DATABASE_URL
- **Referenced in:** `src/db.py:12`, `docker-compose.yml:8`
- **Expected type:** URL (postgresql://...)
- **Fix:** Add `DATABASE_URL=postgresql://user:pass@localhost:5432/dbname` to `.env`
## HIGH
...
## Unreferenced Variables
| Variable | In .env | In Code | In Manifests | Status |
|-----------------|---------|---------|--------------|--------------|
| LEGACY_API_KEY | Yes | No | No | Unreferenced |
## Recommendations
1. [Highest priority fix]
2. [Second fix]
Error Handling
| Error | Resolution |
|---|---|
| No .env file found | Report absence; check for alternative env sources |
| No .env.example or schema | Validate based on code references only |
| Binary or very large .env | Skip; report as unsupported format |
| No code references found | Validate format and security only; skip completeness |
Limitations
- Cannot validate runtime-injected variables (from vault, AWS SSM, etc.)
- Type inference is heuristic — may misclassify complex values
- Does not check variable values against external services (e.g., valid API key format)
- Production vs. development distinction requires file naming conventions
More from mathews-tom/armory
architecture-diagram
Generate layered architecture diagrams as self-contained HTML with inline SVG icons, CSS Grid containers, and connection overlays. Triggers on: "architecture diagram", "infra diagram", "system diagram", "deployment diagram", "topology", "draw architecture". NOT for architecture reviews, use architecture-reviewer.
61architecture-reviewer
Architecture reviews across 7 dimensions (structural, scalability, enterprise readiness, performance, security, ops, data) with scored reports. Triggers on: "review architecture", "critique design", "audit system", "assess scalability", "enterprise readiness", "technical due diligence". NOT for diagrams, use architecture-diagram.
59concept-to-video
Turn concepts into animated explainer videos using Manim (Python) with MP4/GIF output, audio overlay, multi-scene composition. Triggers on: "create a video", "animate this", "make an explainer", "manim animation", "motion graphic". NOT for React video, use remotion-video.
57youtube-analysis
Extract YouTube transcripts and produce structured concept analysis with multi-level summaries, key concepts, takeaways. Uses youtube-transcript-api with yt-dlp fallback. Triggers on: "analyze youtube video", "youtube transcript", "summarize this video", "extract concepts from video", "video key points", or any youtube.com/youtu.be URL.
57code-refiner
Deep code simplification and refactoring preserving behavior across Python, Go, TypeScript, Rust. Targets complexity, anti-patterns, readability debt. Triggers on: "simplify this code", "refactor for clarity", "reduce complexity", "make this more readable", "tech debt cleanup", "too much nesting".
56humanize
Detects and removes AI-generated writing patterns while preserving meaning and facts. Triggers on: "humanize text", "make this sound human", "remove AI patterns", "rewrite to sound natural", "make this less AI", "de-slop this", "not sound like ChatGPT", "human pass".
56