Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>EnvArchitexNew to Visual Studio Code? Get it now.
EnvArchitex

EnvArchitex

envArchitex

| (0) | Free
AST-based detection of environment variables in JS/TS/Python/Rust/PHP/Go/Ruby/Java/C#/C++ with type inference and configurable auto-sync.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

EnvArchitex

EnvArchitex 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 (.env.example, .env.sample, etc.) synchronized with .env files — without ever reading or copying real secret values.

Table of Contents

  • Why EnvArchitex?
  • Features
    • AST-Based Detection
    • Supported Languages & Patterns
    • Type Inference
    • Multi-Environment & Monorepo Sync Mappings
    • Three-Way Sync & Deferred Flushing
    • Lossless & Secret-Safe .env Parser
    • Diagnostics & Quick Fixes
    • Status Bar
  • Commands
  • Settings Reference
  • How It Works
  • Building, Testing & Packaging

Why EnvArchitex?

Most projects keep secrets in .env (gitignored) and document required variable keys in .env.example (committed). Manual maintenance breaks down quickly:

  • A developer references STRIPE_SECRET_KEY in code and forgets to add it to .env.example.
  • A teammate pulls new code and hits runtime errors because .env is missing newly introduced keys.
  • Type expectations (number, boolean, string) go undocumented until deployment fails.

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.


Features

AST-Based Detection

Instead of fragile regexes, EnvArchitex uses Tree-sitter (bundled web-tree-sitter CJS + WASM runtime) to parse source files into ASTs and evaluate language-specific S-expression queries. Comments, unrelated identifiers, and string literals outside environment-access calls are ignored.

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 & Patterns

EnvArchitex supports 13 VS Code language IDs across 11 bundled Tree-sitter WASM grammars:

Language Language ID Scanned Extensions Detected Patterns
JavaScript javascript .js, .mjs, .cjs process.env.VAR, process.env['VAR'], process.env["VAR"], const { VAR, OTHER = default } = process.env, const { VAR: alias, OTHER: a = default } = process.env
TypeScript typescript .ts, .mts, .cts Same as JavaScript
JSX javascriptreact .jsx Same as JavaScript (uses TSX grammar)
TSX typescriptreact .tsx Same as JavaScript (uses TSX grammar)
Python python .py os.environ['VAR'], os.environ.get('VAR', default?), os.getenv('VAR', default?) (single, double, prefixed, and triple-quoted strings)
Rust rust .rs std::env::var("VAR"), env::var("VAR"), var("VAR"), var_os("VAR") (standard "..." and raw r#"..."# strings; scoped calls constrained to std::env / env)
PHP php .php getenv('VAR'), getenv('VAR', $local_only), env('VAR', default?), $_ENV['VAR'], $_SERVER['VAR'] (single and double quotes)
Go go .go os.Getenv("VAR"), os.LookupEnv("VAR") (interpreted "..." and raw `...` strings)
Ruby ruby .rb ENV['VAR'], ENV.fetch('VAR', default?)
Java java .java System.getenv("VAR"), System.getenv().get("VAR")
C# csharp .cs Environment.GetEnvironmentVariable("VAR") (standard "..." and verbatim @"..." strings)
C c .c, .h getenv("VAR"), std::getenv("VAR") (shares C++ grammar)
C++ cpp .cpp, .cc, .cxx, .hpp, .hh, .hxx getenv("VAR"), std::getenv("VAR")

All detected key names must match ^[A-Za-z_][A-Za-z0-9_]*$. For JS/TS object destructuring, diagnostics attach directly to each individual destructured identifier rather than the entire multi-line declarator.

Type Inference

When enabled (envarchitex.typeInference.enabled), EnvArchitex uses context-first AST inference:

  1. Surrounding AST context is checked first (walking up to 4 parent AST nodes, or 8 in Rust for .unwrap() / .expect() chains) for numeric conversions, boolean parsers, casts, fallbacks, or comparisons against boolean literals.
  2. Default/fallback values are checked second if the surrounding context resolves to string, so expressions like int(os.getenv("PORT", "8080")) or ENV.fetch("PORT", "3000").to_i still infer number.
  3. Cross-reference aggregation combines multiple usages across a file or workspace using precedence: boolean > number > string.
Language number signals boolean signals
JS / TS parseInt, parseFloat, Number, Number.parseInt, Number.parseFloat, unary +, \|\| / ?? with numeric literal, destructuring numeric defaults ({ PORT = 3000 }) Boolean(...), === / !== / == / != against boolean literals (true/false/"true"/"false", case-insensitive), \|\| / ?? with boolean literal, destructuring boolean defaults
Python int(...), float(...), unary + / -, numeric defaults bool(...), comparisons against boolean literals, boolean defaults
Rust .parse() and turbofish .parse::<u8..u128 \| i8..i128 \| usize \| isize \| f32 \| f64>() across .unwrap()/.expect() chains .parse::<bool>(), == / != against boolean literals
PHP intval(...), floatval(...), (int) / (float) / (double) casts, numeric env() defaults boolval(...), (bool) / (boolean) casts, == / === / != / !== against boolean literals, boolean env() defaults (note: getenv($name, $local_only)'s 2nd flag is ignored)
Go strconv.Atoi, ParseInt, ParseFloat, numeric casts strconv.ParseBool, == / != against boolean literals
Ruby .to_i, .to_f, numeric ENV.fetch defaults == / != against boolean literals, boolean ENV.fetch defaults
Java Integer.parseInt/valueOf, Long.parseLong/valueOf, Double.parseDouble/valueOf, Float.parseFloat/valueOf, Short.parseShort/valueOf Boolean.parseBoolean/valueOf, .equals / .equalsIgnoreCase against boolean string literals
C# Qualified Parse/TryParse on int/Int32/long/Int64/short/Int16/double/Double/float/Single/decimal/Decimal, Convert.ToInt32/ToInt64/ToInt16/ToDouble/ToSingle/ToDecimal, numeric casts bool.Parse/TryParse, Boolean.Parse/TryParse, Convert.ToBoolean, (bool) cast, == / != against boolean literals
C / C++ atoi, atof, atol, strtol, strtod, strtof, std::stoi, std::stod, std::stof, numeric casts (bool) cast, == / != against boolean literals

When appending missing keys to target or source files under # Added by EnvArchitex, empty placeholders are written alongside optional # type: <type> comments (envarchitex.typeInference.emitTypeComment):

# Added by EnvArchitex
DB_HOST=""
PORT= # type: number
DEBUG_MODE= # type: boolean

Multi-Environment & Monorepo Sync Mappings

Configure one or more source ↔ targets pairs in envarchitex.syncMappings. Paths are matched relative to each workspace folder root (case-insensitively on Windows), supporting both multiple environments and monorepo subdirectories or custom filenames:

// .vscode/settings.json
{
  "envarchitex.syncMappings": [
    { "source": ".env", "targets": [".env.example", ".env.sample"] },
    { "source": ".env.production", "targets": [".env.production.example"] },
    { "source": "packages/api/.env", "targets": ["packages/api/.env.example"] }
  ]
}

The default mapping is [{ "source": ".env", "targets": [".env.example"] }].

Three-Way Sync & Deferred Flushing

EnvArchitex synchronizes keys in three independently configurable directions (all debounced by 300 ms and serialized per file via KeyedMutex):

  1. Code → Target (envarchitex.syncMode): On source file save (in auto mode), appends missing referenced keys with empty placeholders and inferred # type: comments to each configured target.
  2. Target → Source (envarchitex.syncEnvFromExample.mode): On target file save or after target updates (in auto mode), populates missing keys from the target into the paired local source env file.
  3. Source → Target (envarchitex.syncExampleFromEnv.mode): On source env file save (in auto mode), mirrors missing key names from source to its targets without copying values.

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 .env Parser

  • Secrets are never copied: Only valid environment variable key names and inferred type comments are synced.
  • Formatting is preserved: Existing comments, blank lines, export prefixes (including indented export), custom inline comment spacing (spaces or tabs), unquoted # values without preceding whitespace (COLOR=#007bff, URL=https://example.com/#hook), literal backslashes in single quotes ('C:\dir\'), and mixed CRLF/LF line endings are preserved on round-trip.
  • Multi-line quoted values are safe: Multi-line values inside "..." or '...' (such as PEM/RSA private keys with Base64 = padding) are tracked as continuation lines and never misread as new keys or leaked into .env.example.

Diagnostics & Quick Fixes

EnvArchitex reports two diagnostic categories in the editor and Problems panel:

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 active syncMode; clicking it runs EnvArchitex: 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: esbuild bundles web-tree-sitter.cjs directly into dist/extension.js and copies web-tree-sitter.wasm plus 11 tree-sitter-*.wasm grammars into dist/resources/.
  • Filtering & Performance: FileFilter + globMatcher compile ignore globs once per config change; EnvReferenceScanner maintains a 64-entry LRU cache; DiagnosticOrchestrator debounces edits (300 ms), coalesces env changes (50 ms), and caches closed-file scans by (mtime, size); and AutoSyncCoordinator serializes writes per URI through KeyedMutex.

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.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft