EnvArchitexEnvArchitex is a VS Code extension that uses Tree-sitter AST analysis to detect environment variable references across 13 languages, infer variable types from usage context, surface missing-variable diagnostics, and keep environment template files ( Table of ContentsWhy EnvArchitex?Most projects keep secrets in
EnvArchitex parses your source code into Abstract Syntax Trees, highlights undocumented or unconfigured variables directly in the editor, and appends missing keys automatically on save. FeaturesAST-Based DetectionInstead of fragile regexes, EnvArchitex uses Tree-sitter (bundled Language grammars are loaded lazily on demand and cached for the session, with concurrent load deduplication so only languages present in your workspace consume memory. Supported Languages & PatternsEnvArchitex supports 13 VS Code language IDs across 11 bundled Tree-sitter WASM grammars:
All detected key names must match Type InferenceWhen enabled (
When appending missing keys to target or source files under
Multi-Environment & Monorepo Sync MappingsConfigure one or more source ↔ targets pairs in
The default mapping is Three-Way Sync & Deferred FlushingEnvArchitex synchronizes keys in three independently configurable directions (all debounced by 300 ms and serialized per file via
If a target env file is open with unsaved edits when a sync runs, EnvArchitex defers the disk write and displays a status bar reminder. As soon as you save that target file, the queued variables are flushed automatically before Target → Source sync runs. Lossless & Secret-Safe
|
| Code | Default Severity | Meaning | Setting |
|---|---|---|---|
missing-from-example |
Warning | Variable referenced in code is missing from one or more configured target files. | envarchitex.diagnostics.envExample |
missing-from-local |
Information | Variable referenced in code has no key in the local source env file. | envarchitex.diagnostics.envLocal |
When diagnostics are set to off for both categories, AST scanning for diagnostics is skipped completely. Otherwise, editor edits are debounced (300 ms), scan results are cached in memory per (uri, version) (plus mtime/size caching for closed workspace files), and the lightbulb (💡) menu provides deduplicated Add 'VAR' to <target>, Add 'VAR' to <source> (empty placeholder), and Add N missing variables to <target> Quick Fixes.
Status Bar
- Primary item (
$(database) EnvArchitex: auto | manual): Shows the activesyncMode; clicking it runsEnvArchitex: Sync .env.example with detected variables. - Pending hint item (
$(warning) EnvArchitex: N pending (KEY…) — save target file): Appears whenever target writes are deferred due to unsaved changes and clears automatically when the target file is saved and flushed.
Commands
Available from the Command Palette (Ctrl+Shift+P / Cmd+Shift+P):
| Command | Description |
|---|---|
EnvArchitex: Sync .env.example with detected variables |
Scans eligible visible editors and syncs missing variables to configured targets. |
EnvArchitex: Sync .env with keys from .env.example |
Populates missing keys from target templates into paired source env files across all workspace folders. |
EnvArchitex: Sync .env.example with keys from .env |
Mirrors missing key names from source env files into paired targets across all workspace folders (values are never copied). |
EnvArchitex: Re-scan workspace |
Streams files matching envarchitex.languages.enabled (respecting ignore.globs and maxFileBytes) in bounded batches with a cancellable progress notification to refresh workspace diagnostics. |
EnvArchitex: Sync all workspace files |
Streams eligible workspace files, aggregates inferred types across all files per folder, and writes missing keys in a single batch per target/source. |
EnvArchitex: Toggle auto/manual sync |
Toggles envarchitex.syncMode between auto and manual (using Workspace settings when a folder is open, or Global settings otherwise). |
EnvArchitex: Open .env.example |
Opens the configured target env file for the active editor's workspace folder (or prompts for folder/target when multiple exist), creating it if absent. |
EnvArchitex: Show output channel |
Reveals the EnvArchitex output channel with scan, sync, and grammar logs. |
Settings Reference
All settings live under envarchitex:
| Setting | Type | Default | Description |
|---|---|---|---|
envarchitex.syncMappings |
array |
[{ "source": ".env", "targets": [".env.example"] }] |
Source ↔ target env file paths relative to each workspace folder root. |
envarchitex.syncMode |
"auto" | "manual" |
"auto" |
Controls Code → Target sync (auto on save, or manual via command / Quick Fix). |
envarchitex.syncEnvFromExample.mode |
"auto" | "manual" |
"auto" |
Controls Target → Source sync on target save or after target updates. |
envarchitex.syncExampleFromEnv.mode |
"auto" | "manual" |
"auto" |
Controls Source → Target key mirroring on source .env save. Values are never copied. |
envarchitex.diagnostics.envExample |
"warning" | "off" |
"warning" |
Severity of diagnostics for variables missing from target template files. |
envarchitex.diagnostics.envLocal |
"info" | "off" |
"info" |
Severity of diagnostics for variables missing from local source env files. |
envarchitex.languages.enabled |
string[] |
All 13 language IDs | Language IDs scanned by EnvArchitex (used for diagnostics, sync, and workspace discovery). |
envarchitex.typeInference.enabled |
boolean |
true |
Infer string / number / boolean types from AST usage context and defaults. |
envarchitex.typeInference.emitTypeComment |
boolean |
true |
Append # type: number / # type: boolean inline comments for non-string variables. |
envarchitex.notifications.onSync |
"always" | "summary" | "off" |
"always" |
Notification behavior: per-file (always), single batch toast (summary), or disabled (off). |
envarchitex.ignore.globs |
string[] |
["**/node_modules/**", "**/.venv/**", "**/dist/**", "**/build/**", "**/out/**", "**/target/**", "**/vendor/**", "**/.gradle/**", "**/bin/**", "**/obj/**"] |
Workspace-relative (or explicit absolute) globs to skip, supporting **/, *, ?, nested {a,b} braces, and case-insensitive matching on Windows. |
envarchitex.maxFileBytes |
number |
1048576 |
Skip source files larger than this byte threshold (1 MB default). |
How It Works
┌───────────────┐ ┌───────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
│ Source Files │──▶│ ParserManager │──▶│ EnvReferenceScanner │──▶│ TypeInferenceEngine │
│ (13 langs) │ │ (bundled WASM)│ │ (versioned LRU) │ │ (AST + defaults) │
└───────────────┘ └───────────────┘ └─────────────────────┘ └─────────────────────┘
│ │
▼ ▼
┌───────────────┐ ┌───────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
│ FileFilter │──▶│ EnvWorkspace │◀──│ Diagnostic │ │ AutoSyncCoordinator │
│ (globMatcher) │ │ (env watchers)│ │ Orchestrator │ │ + EnvExampleWriter │
└───────────────┘ └───────────────┘ └─────────────────────┘ │ (KeyedMutex+Parser) │
│ └─────────────────────┘
▼ │
┌─────────────────────┐ ▼
│ Squiggles & Quick │ ┌─────────────────────┐
│ Fixes │ │ .env / .env.example │
└─────────────────────┘ └─────────────────────┘
- Bundled Runtime & Grammars:
esbuildbundlesweb-tree-sitter.cjsdirectly intodist/extension.jsand copiesweb-tree-sitter.wasmplus 11tree-sitter-*.wasmgrammars intodist/resources/. - Filtering & Performance:
FileFilter+globMatchercompile ignore globs once per config change;EnvReferenceScannermaintains a 64-entry LRU cache;DiagnosticOrchestratordebounces edits (300 ms), coalesces env changes (50 ms), and caches closed-file scans by(mtime, size); andAutoSyncCoordinatorserializes writes per URI throughKeyedMutex.
Building, Testing & Packaging
Run inside envarchitex/:
# Install dependencies
npm install
# Type-check, lint, and build development bundle (dist/extension.js + WASM resources)
npm run compile
# Run standalone Mocha unit & Tree-sitter grammar tests
npm run test:unit
# Build minified production bundle (strips sourcemaps)
npm run package
# Create a self-contained .vsix package
npx @vscode/vsce package
Press F5 in VS Code with envarchitex/ open to launch an Extension Development Host.