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.

If you have installed varlock as a package.json dependency, rather than a standalone binary, the best way to invoke the CLI is via your package manager:

Terminal window
npm exec -- varlock ...

Also note that within package.json scripts, you can use it directly:

package.json
{
"scripts": {
"start": "varlock run -- node app.js"
}
}

Starts an interactive onboarding process to help you get started. Will help create your .env.schema and install varlock as a dependency if necessary.

Terminal window
varlock init

Loads and validates environment variables according to your .env files, and prints the results. Default prints a nicely formatted, colorized summary of the results, but can also print out machine-readable formats.

Useful for debugging locally, and in CI to print out a summary of env vars.

Terminal window
varlock load [options]

Options:

  • --format: Format of output [pretty|json|env]
  • --show-all: Shows all items, not just failing ones, when validation is failing
  • --env: Set the default environment flag (e.g., --env production), only useful if not using @envFlag in .env.schema

Examples:

Terminal window
# Load and validate environment variables
varlock load
# Load and validate for a specific environment (when not using @envFlag in .env.schema)
varlock load --env production
# Output validation results in JSON format
varlock load --format json
# When validation is failing, will show all items, rather than just failing ones
varlock load --show-all

Executes a command in a child process, injecting your resolved and validated environment variables from your .env files. This is useful when a code-level integration is not possible.

Terminal window
varlock run -- <command>

Examples:

Terminal window
varlock run -- node app.js # Run a Node.js application
varlock run -- python script.py # Run a Python script

Opts in/out of anonymous usage analytics. This command creates/updates a configuration file at ~/.varlock/config.json saving your preference.

Terminal window
varlock telemetry disable
varlock telemetry enable

Displays general help information, alias for varlock --help

Terminal window
varlock help

For help about specific commands, use:

Terminal window
varlock subcommand --help