Skip to content

CLI Commands

Varlock provides a command-line interface for managing environment variables and secrets. This reference documents all available CLI commands.

See installation for instructions on how to install Varlock.

Terminal window
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.

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.

Terminal window
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:

Terminal window
# Load and validate environment variables
varlock load
# Load and validate for a specific environment
varlock load --env production
# Output validation results in JSON format
varlock load --format json
# Show all environment variables, including valid ones
varlock load --show-all

Executes a command with the environment variables loaded from your schema. This is useful for running your application with the correct environment configuration.

Terminal window
varlock run <command> [options]
Options:
--watch Watch for changes and reload the environment variables

Examples:

Terminal window
# Run a Node.js application
varlock run node app.js
# Run with environment variable watching enabled
varlock run --watch npm start
# Run a Python script
varlock run python script.py

Opts out of anonymous usage analytics. This command creates a configuration file at ~/.varlock/config.json that permanently disables analytics collection.

Terminal window
varlock opt-out

Displays help information about Varlock commands and options.

Terminal window
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