Back to Agent Skills
Security & Quality
dotenv Environment Management
Load environment variables from .env files into process.env for local development and configuration.
Claude Code Cursor Copilot Windsurf Gemini CLI Codex
Overview
dotenv is a zero-dependency module that loads environment variables from a .env file into process.env. It follows the twelve-factor app methodology by separating configuration from code, making it easy to change settings between environments without modifying application code.
The library supports variable expansion (referencing other variables), multiline values, and comments. The dotenv-expand companion package enables variable interpolation within .env files. For TypeScript projects, dotenv provides type definitions and works seamlessly with validation libraries like Zod or t3-env to ensure all required environment variables are present and correctly typed.
Security best practices with dotenv include never committing .env files to version control (add to .gitignore), providing a .env.example file with placeholder values for documentation, and using different .env files for different environments (.env.local, .env.production). The dotenv-vault extension adds encrypted .env file management for team collaboration and CI/CD deployments.
The library supports variable expansion (referencing other variables), multiline values, and comments. The dotenv-expand companion package enables variable interpolation within .env files. For TypeScript projects, dotenv provides type definitions and works seamlessly with validation libraries like Zod or t3-env to ensure all required environment variables are present and correctly typed.
Security best practices with dotenv include never committing .env files to version control (add to .gitignore), providing a .env.example file with placeholder values for documentation, and using different .env files for different environments (.env.local, .env.production). The dotenv-vault extension adds encrypted .env file management for team collaboration and CI/CD deployments.
Who Is This For?
- Load database URLs and API keys from .env files
- Set up environment-specific configuration for dev/staging/prod
- Validate environment variables with Zod schemas
- Share environment configs securely across a team
Installation
Setup for Claude Code
npm install dotenv Configuration
// .env
DATABASE_URL="postgresql://user:pass@localhost:5432/mydb"
API_KEY="sk-1234567890"
// app.ts
import "dotenv/config"
// or
import dotenv from "dotenv"
dotenv.config()
console.log(process.env.DATABASE_URL) Explore AI Tools
Discover the best AI tools that complement your skills
Read AI & Design Articles
Tips and trends in the world of design and AI
Related Skills
Security & Quality
Snyk Security Scan
Detect vulnerabilities in your dependencies and application code. Get actionable remediation advice and automatic fix pull requests.
Claude Code Codex Copilot
Security & Quality SonarQube Code Quality
Run continuous code quality and security analysis to catch bugs, code smells, and vulnerabilities before they reach production.
Claude Code Codex Copilot
Security & Quality OWASP ZAP Security Testing
Perform automated web application security testing to find common vulnerabilities like XSS, injection flaws, and misconfigurations.
Claude Code Codex