TripWire - Smart Environment Variable Management for VS Code

Stop environment variable errors before they crash your Python applications. TripWire brings intelligent autocomplete, real-time validation, and seamless navigation to your environment variables workflow.
Features
🎯 Smart Autocomplete
Get intelligent suggestions as you type env.require()
or env.optional()
in your Python code:
- Auto-suggests variable names from
.tripwire.toml
or .env.example
- Shows type information and validation rules inline
- Prioritizes required variables
- Visual indicators for secrets
Hover over any environment variable to see:
- Variable type and format validators
- Required/optional status
- Default values
- Validation rules (min/max values, length, patterns, choices)
- Security warnings for secrets
- Source file location
🔍 Real-Time Validation
Instant feedback as you edit .env
files:
- Errors for missing required variables
- Warnings for invalid formats (email, URL, PostgreSQL, UUID, IPv4)
- Hints for undefined variables not in schema
- Type checking for int, float, bool, list, dict
🧭 Go-to-Definition
Jump seamlessly between files:
- From Python code →
.env
file
- From
.env
file → .tripwire.toml
schema
- Bidirectional navigation support
🎨 Syntax Highlighting
Beautiful syntax highlighting for .env
files:
- Variable names, values, and comments
- String interpolation with
${VAR}
syntax
- Quoted strings (single and double)
Installation
Install from VS Code Marketplace:
- Open VS Code
- Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
- Search for "TripWire"
- Click "Install"
Install TripWire Python Library:
pip install tripwire-py
Create a schema file (optional but recommended):
cd your-project
tripwire schema from-code # Generate from Python code
# OR
tripwire schema from-example # Generate from .env.example
Requirements
- VS Code 1.85.0 or higher
- Python 3.11+ with TripWire installed (for full validation)
- A
.tripwire.toml
schema or .env.example
file in your workspace
Quick Start
- Create a
.tripwire.toml
schema in your project root:
[variables.DATABASE_URL]
type = "string"
required = true
format = "postgresql"
description = "PostgreSQL database connection string"
secret = true
[variables.PORT]
type = "int"
required = false
default = "8000"
min_val = 1
max_val = 65535
description = "Application server port"
[variables.DEBUG]
type = "bool"
required = false
default = "false"
description = "Enable debug mode"
- Use in your Python code:
from tripwire import env
# Autocomplete kicks in as you type! ✨
DATABASE_URL: str = env.require("DATABASE_URL") # Hover for details
PORT: int = env.optional("PORT", default=8000)
DEBUG: bool = env.optional("DEBUG", default=False)
- Edit your
.env
file:
# TripWire validates in real-time! 🔍
DATABASE_URL=postgresql://localhost/mydb # ✅ Valid
PORT=8080 # ✅ Valid
# DEBUG=maybe # ❌ Error: invalid boolean
Extension Commands
Access from the Command Palette (Ctrl+Shift+P / Cmd+Shift+P):
- TripWire: Validate Configuration - Manually validate all .env files
- TripWire: Show Variable Information - Browse all environment variables
Extension Settings
Configure TripWire in your VS Code settings:
{
"tripwire.schemaPath": ".tripwire.toml",
"tripwire.enableDiagnostics": true,
"tripwire.enableAutoComplete": true,
"tripwire.pythonPath": "python"
}
How It Works
Schema-Based Validation
TripWire uses your .tripwire.toml
schema as the source of truth:
[variables.API_KEY]
type = "string"
required = true
secret = true
min_length = 32
max_length = 128
pattern = "^sk-[a-zA-Z0-9]+$"
The extension parses this schema and provides:
- Autocomplete suggestions
- Hover documentation
- Real-time validation errors
- Go-to-definition navigation
Fallback to .env.example
If no .tripwire.toml
exists, TripWire falls back to .env.example
:
# API key for external service
API_KEY=your-key-here
The extension infers:
- Variable names
- Basic type detection
- Comments as descriptions
- Caching: Schema parsed once and cached (1-minute TTL)
- Incremental: Only re-validates changed files
- Non-blocking: All operations run asynchronously
- Efficient: <100ms response time for autocomplete
Supported Validators
TripWire validates the following formats:
Basic Types
string
, int
, float
, bool
list
(comma-separated or JSON array)
dict
(JSON object)
email
- Valid email address
url
- Valid HTTP/HTTPS URL
postgresql
- PostgreSQL connection string
uuid
- UUID v4 format
ipv4
- IPv4 address
Range Validators
min_val
/ max_val
- Numeric ranges
min_length
/ max_length
- String length
pattern
- Regular expression matching
choices
- Enum/allowed values
Troubleshooting
Autocomplete not working?
- Check your schema file exists (
.tripwire.toml
or .env.example
)
- Verify schema syntax:
tripwire schema check
- Reload VS Code window:
Cmd+Shift+P
→ "Reload Window"
Diagnostics showing false errors?
- Update schema:
tripwire schema from-code
- Check file encoding (must be UTF-8)
- Disable diagnostics:
"tripwire.enableDiagnostics": false
Go-to-definition not jumping?
- Ensure variable exists in both files
- Check file paths are correct
- Verify workspace folder is open
Use Cases
FastAPI Projects
from tripwire import env
from fastapi import FastAPI
# TripWire validates at startup! 🚀
DATABASE_URL: str = env.require("DATABASE_URL", format="postgresql")
API_KEY: str = env.require("API_KEY", min_length=32)
DEBUG: bool = env.optional("DEBUG", default=False)
app = FastAPI(debug=DEBUG)
Django Settings
from tripwire import env
# Fail fast if config is invalid
SECRET_KEY: str = env.require("SECRET_KEY", min_length=50)
ALLOWED_HOSTS: list[str] = env.require("ALLOWED_HOSTS", type=list)
DATABASE_URL: str = env.require("DATABASE_URL", format="postgresql")
Data Science Workflows
from tripwire import env
# Validate API keys for cloud services
AWS_ACCESS_KEY_ID: str = env.require("AWS_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY: str = env.require("AWS_SECRET_ACCESS_KEY")
S3_BUCKET: str = env.require("S3_BUCKET", pattern="^[a-z0-9-]+$")
Comparison with Other Extensions
Feature |
TripWire |
DotEnv |
Env File |
Python-native validation |
✅ |
❌ |
❌ |
Schema-based autocomplete |
✅ |
❌ |
❌ |
Real-time type checking |
✅ |
❌ |
❌ |
Hover tooltips with metadata |
✅ |
❌ |
❌ |
Go-to-definition |
✅ |
❌ |
✅ |
Syntax highlighting |
✅ |
✅ |
✅ |
Secret detection warnings |
✅ |
❌ |
❌ |
Contributing
TripWire is open source! Contributions welcome:
Links
License
MIT License - see LICENSE for details.
Support
- Discord: Join our community (coming soon)
Made with ❤️ by the TripWire team. Catch config errors before they explode! 💥