Load and run
varlock load
Section titled “varlock load”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.
varlock load [options]Options:
--format: Format of output [pretty|json|env|shell|json-full]--agent: Agent-safe mode: defaults to JSON output and redacts sensitive values. Not compatible with--format envor--format shell.--compact: Compact output (json-full: no indentation, env/shell: skip undefined values)--show-all: Shows all items, not just failing ones, when validation is failing--include-internal: Include@internalitems in--format json-fulloutput. Excluded by default (json-fullis commonly consumed programmatically, e.g. by framework integrations, not just for local human inspection) - pass this for local debugging of a secret-zero credential.- Common options:
--env,--path/-p,--clear-cache,--skip-cache,--filter
Examples:
# Load and validate environment variablesvarlock load
# Load and validate for a specific environment (when not using @currentEnv in .env.schema)varlock load --env production
# Output validation results in JSON formatvarlock load --format json
# Output full serialized graph (including errors/configErrors fields)varlock load --format json-full
# Compact outputvarlock load --format json-full --compact
# Output as shell export statements (useful for direnv / eval)eval "$(varlock load --format shell)"
# When validation is failing, will show all items, rather than just failing onesvarlock load --show-all
# Load from a specific .env filevarlock load --path .env.prod
# Load from a specific directoryvarlock load --path ./config/
# Load from multiple directories (later paths take higher precedence)varlock load -p ./envs -p ./overrides
# Agent-safe JSON output with sensitive values redactedvarlock load --agent
# Only show STRIPE_* keys, excluding onevarlock load --filter="STRIPE_*,!STRIPE_DEBUG_KEY"
# Only show items marked @sensitivevarlock load --filter="@sensitive"
# Only show items tagged with @tag(billing)varlock load --filter="#billing"Exit codes:
0when all config is valid- non-zero when validation fails (missing required values, failed coercion, or resolver errors)
Output formats (for scripts & agents)
Section titled “Output formats (for scripts & agents)”--format json: a flat{ "KEY": value }map of resolved values on stdout--agent: the same flat map, but@sensitivevalues are redacted (e.g."su▒▒▒▒▒"), so it is safe to print in logs or agent transcripts. Implies JSON output; not compatible with--format env/shell. Combine with--agent --format json-fullto get the redacted full graph.--format json-full: the full serialized graph: top-levelbasePath,sources,config(per-item metadata including resolved value, validation state, and sensitivity),settings. Use this when you need per-item validation/error detail rather than just values. ⚠️ This includes raw resolved secret values, so add--agent(--agent --format json-full) to redact them before logging or feeding to an agent.@internalitems are excluded unless you pass--include-internal.--format env/--format shell: dotenv lines / shellexportstatements with raw values. Never pipe these somewhere that gets logged when secrets are involved.
When emitting machine-readable output, add --summary-stderr (or --summary-file) to get a human-readable, redacted summary on stderr while keeping clean JSON on stdout. This is handy for agents and CI.
varlock run
Section titled “varlock run”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.
varlock run -- <command>Exit codes: varlock run exits with the child command’s exit code, so it is transparent in scripts and CI. If varlock itself fails before the command starts (e.g. invalid config or a failed resolver), it exits non-zero without running the command.
Options:
--redact-stdout/--no-redact-stdout: Override automatic stdout/stderr redaction.--redact-stdoutforces redaction of piped/redirected output (e.g., to override@redactLogs=false) and errors if output is attached to an interactive terminal, where redaction is not possible without breaking TTY behavior.--no-redact-stdoutdisables redaction entirely.--inject <mode>/-i: Control what gets injected into the child process environment:all(default: individual vars plus the__VARLOCK_ENVserialized config graph blob),vars(individual vars only, no blob), orblob(only the__VARLOCK_ENVblob, no individual vars)--include-internal: Pass@internalitems through to the child process. By default they are stripped from the child env, even if set in the ambient environment, so a secret-zero token never reaches your app. Use this for a nestedvarlock runwhose own resolution needs the internal value.- Common options:
--path/-p,--clear-cache,--skip-cache,--filter
Examples:
varlock run -- node app.js # Run a Node.js applicationvarlock run -- python script.py # Run a Python script
# Use a specific .env file as entry pointvarlock run --path .env.prod -- node app.js
# Use a specific directory as entry pointvarlock run --path ./config/ -- node app.js
# Use multiple directories as entry pointsvarlock run -p ./envs -p ./overrides -- node app.js
# Only inject STRIPE_* keys, excluding one (also strips them from the __VARLOCK_ENV blob)varlock run --filter="STRIPE_*,!STRIPE_DEBUG_KEY" -- node app.jsvarlock printenv
Section titled “varlock printenv”Resolves and prints the value of a single environment variable to stdout. Only the requested item and its transitive dependencies are resolved, making this faster than loading the full graph.
This is useful within larger shell commands where you need to embed a single resolved env var value.
Exit codes: 0 when the value resolves; non-zero when no variable name is given, the variable is not in the schema, or it fails to resolve.
varlock printenv <VAR_NAME> [options]Positional arguments:
<VAR_NAME>: The variable to print. Required; printenv errors if omitted.
Options:
- Common options:
--path/-p,--clear-cache,--skip-cache
Examples:
# Print the resolved value of MY_VARvarlock printenv MY_VAR
# Use a specific .env file as entry pointvarlock printenv --path .env.prod MY_VAR
# Use multiple directories as entry pointsvarlock printenv -p ./envs -p ./overrides MY_VAR
# Embed in a shell command using subshell expansionsh -c 'some-tool --token $(varlock printenv MY_TOKEN)'varlock explain
Section titled “varlock explain”Shows detailed information about how a single config item is resolved: all of its definitions, sources, overrides, and the final resolved value. This is the go-to command for debugging why a value is what it is (and an agent-friendly way to inspect resolution without dumping every value).
Sensitive values are redacted in the output.
Exit codes: 0 when the item is found and explained; non-zero when no key is given or the key is not in the schema.
varlock explain <VAR_NAME> [options]Positional arguments:
<VAR_NAME>: The config item to explain. Required; explain errors if omitted.
Options:
- Common options:
--env,--path/-p
Examples:
# Explain how a value is resolvedvarlock explain DATABASE_URL
# Explain in the context of a specific environmentvarlock explain --env production API_KEY