Encryption commands
varlock encrypt
Section titled “varlock encrypt”Encrypts sensitive values using device-local encryption. Encrypted values are stored in .env files using the varlock() resolver function and are automatically decrypted at load time.
On macOS, encryption is hardware-backed via the Secure Enclave (with Touch ID / biometric authentication). On Windows, keys are TPM-sealed when a TPM is available (Windows Hello gates interactive decrypts). On Linux, TPM2 and/or Secret Service is used. A pure-JavaScript file-based fallback is available on all platforms.
See the local encryption guide for platform details. On Windows, existing DPAPI keys are automatically upgraded to TPM sealing on the next decrypt.
varlock encrypt [options]Options:
--file: Path to a.envfile; encrypts all sensitive plaintext values in-place
Examples:
# Interactive mode: encrypt a single value (prompts with hidden input)varlock encrypt
# Pipe a value via stdin (keeps secrets out of shell history)printf '%s' "$SECRET" | varlock encryptvarlock encrypt < secret.txt
# Encrypt all sensitive plaintext values in a .env filevarlock encrypt --file .env.localIn single-value mode, you’ll either be prompted to enter a value (hidden input) or the value will be read from stdin when piped. The encrypted output is printed for you to copy into your .env.local file:
SOME_SENSITIVE_KEY=varlock("local:<encrypted>")In file mode, varlock loads the env graph, identifies @sensitive items with plaintext values, and lets you select which to encrypt in-place.
varlock reveal
Section titled “varlock reveal”Securely view or copy the value of a @sensitive environment variable. The value is displayed in an alternate terminal screen buffer so it doesn’t persist in your scrollback history.
🔒 Usually sensitive values are redacted, so this is needed to actually view the value without exposing it in plaintext on disk or in your terminal history.
varlock reveal [VAR_NAME] [options]Options:
--copy: Copy the value to clipboard instead of displaying (auto-clears after 10s)- Common options:
--path/-p,--env
Examples:
# Interactive picker to browse and reveal sensitive valuesvarlock reveal
# Reveal a specific variablevarlock reveal MY_SECRET
# Copy a value to clipboard (auto-clears after 10s)varlock reveal MY_SECRET --copyvarlock lock
Section titled “varlock lock”Locks the encryption daemon, requiring biometric authentication (e.g., Touch ID) for the next decrypt operation. This invalidates the current biometric session cache.
varlock lockThis command only has an effect when using a biometric-enabled encryption backend (macOS Secure Enclave, Windows Hello, or Linux with polkit/PAM biometric setup). On other backends, it will display a message and exit.
varlock audit
Section titled “varlock audit”Scans your source code for environment variable references and compares them against keys defined in your schema.
This command reports two drift categories:
- Missing in schema: key is used in code but not declared in schema
- Unused in schema: key is declared in schema but not referenced in code
Pure execution-environment plumbing, meaning variables that reflect where/how the process runs (e.g. PATH, HOME, SHELL, NODE_OPTIONS, npm_*), is read from process.env in normal code but is never part of your schema, so it is not reported as missing. Semantically meaningful variables your app or CI may depend on (e.g. NODE_ENV, CI, GitHub Actions vars) are still reported, so you can decide whether to declare them or suppress them with @auditIgnore.
Exit codes:
0when schema and code are in sync1when drift is detected
varlock audit [paths...] [options]Positional arguments:
[paths...]: Optional list of directories to scan. When provided, only these directories are scanned instead of the auto-detected scan root.
Options:
- Common options:
--path/-p(here it sets the schema entry point, single path only) --ignore/-i: Directory to exclude from code scanning (can be specified multiple times)
Examples:
# Audit current projectvarlock audit
# Audit using a specific .env file as schema entry pointvarlock audit --path .env.prod
# Audit using a directory as schema entry pointvarlock audit --path ./config
# Only scan specific directoriesvarlock audit ./src ./lib
# Exclude directories from scanningvarlock audit --ignore vendor
# Exclude multiple directoriesvarlock audit -i vendor -i generatedvarlock generate-key
Section titled “varlock generate-key”Generates a random 256-bit encryption key for use with _VARLOCK_ENV_KEY. This key is used to encrypt the resolved env blob that gets baked into your build output on certain frameworks/platforms.
varlock generate-keyvarlock generate-key --plainFlags:
--plain: Print only the key (no surrounding help text). Useful for piping into platform CLIs, e.g.varlock generate-key --plain | vercel env add _VARLOCK_ENV_KEY production --sensitive.
See the encrypted deployments guide and the Next.js / Vite integration docs for setup instructions.