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 initnpx varlock inityarn dlx varlock initpnpm dlx varlock initScans 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 onesExamples:
# Load and validate environment variablesvarlock load
# Output validation results in JSON formatvarlock load --format json
# Show all environment variables, including valid onesvarlock load --show-allvarlock 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 variablesExamples:
# 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.pyvarlock encrypt
Section titled “varlock encrypt”Encrypts sensitive environment variables in your .env.* files and replaces the values with the encrypted values.
varlock encrypt [options]Examples:
# Encrypt all sensitive variables in .env filesvarlock encrypt
# Encrypt a specific .env filevarlock encrypt .env.productionvarlock doctor
Section titled “varlock doctor”Diagnoses your environment configuration and provides recommendations for improvements. This command checks for common issues and best practices.
varlock doctor [options]Examples:
# Run diagnostics on your environment setupvarlock doctor
# Check a specific .env filevarlock doctor .env.productionvarlock 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