CLI Commands
Varlock provides a command-line interface for managing environment variables and secrets. This reference documents all available CLI commands.
Installation
Section titled “Installation”See installation for instructions on how to install Varlock.
Commands
Section titled “Commands”varlock init
Section titled “varlock init”varlock init
npx varlock init
yarn dlx varlock init
pnpm dlx varlock init
Scans your project for .env.*
files and scans code for environment variable usage and creates a .env.schema
file with the appropriate variables.
It will prompt you to mark items as required and sensitive and do its best to infer the type.
varlock load
Section titled “varlock load”Loads environment variables from your .env.schema
file and any additional .env.*
files it finds colocated. This command ensures all required variables are validated per the schema.
varlock load [options]
Options: --format # Format of output [pretty|json|env] --show-all # Shows all items, not just the failing ones --env # Set the default environment flag (e.g., --env production)
Examples:
# Load and validate environment variablesvarlock load
# Load and validate for a specific environmentvarlock load --env production
# Output validation results in JSON formatvarlock load --format json
# Show all environment variables, including valid onesvarlock load --show-all
varlock run
Section titled “varlock run”Executes a command with the environment variables loaded from your schema. This is useful for running your application with the correct environment configuration.
varlock run <command> [options]
Options: --watch Watch for changes and reload the environment variables
Examples:
# Run a Node.js applicationvarlock run node app.js
# Run with environment variable watching enabledvarlock run --watch npm start
# Run a Python scriptvarlock run python script.py
varlock opt-out
Section titled “varlock opt-out”Opts out of anonymous usage analytics. This command creates a configuration file at ~/.varlock/config.json
that permanently disables analytics collection.
varlock opt-out
varlock help
Section titled “varlock help”Displays help information about Varlock commands and options.
varlock help [command]
Examples: varlock help # Show general help varlock help init # Show help for init command varlock init --help # Alternative way to show command help