Skip to content

Cache and codegen

Manage the encrypted disk cache used by cache() and plugin authors when cache mode is set to disk. When run in a TTY, opens an interactive browser; otherwise prints a status summary.

Terminal window
varlock cache [status|clear] [options]

Sub-commands:

  • status: print a non-interactive cache status summary (location, file size, entry counts by group)
  • clear: remove cache entries. Requires --yes for non-interactive use.

Options:

  • --plugin <name>: When clearing, only remove entries for a specific plugin
  • --yes / -y: Skip confirmation prompts (required when clearing without a TTY)

Examples:

Terminal window
# Interactive cache browser (or status summary in CI)
varlock cache
# Print a non-interactive status summary
varlock cache status
# Clear all cache entries (prompts to confirm)
varlock cache clear
# Clear all cache entries without confirming (e.g. CI)
varlock cache clear --yes
# Clear cache for a specific plugin only
varlock cache clear --plugin 1password --yes

See the Caching guide for cache mode strategy and troubleshooting.

Runs the code-generation decorators in your schema: typed env accessors like @generateTsTypes (type declarations) and @generatePythonEnv (a loadable module), plus any generators contributed by plugins. Uses only your schema definitions, so output is deterministic regardless of which environment is active. Keys (and decorators) that come only from value files like .env or .env.local are ignored. Only items declared in your .env.schema (or imported into it) are included. When run directly, the command reports any keys found only in a plain .env so you can move them into your schema if they belong there.

Add a per-language decorator for each output file you want: @generateTsTypes, @generatePythonEnv, @generateRustEnv, @generateGoEnv, @generatePhpEnv, @generateJavaEnv, or @generateCsharpEnv. Each generates its own file. Each decorator can also take a filter= arg to scope its output to a subset of items, using the same selectors as the --filter CLI flag; see the code generation reference.

This command is particularly useful when you have set auto=false on a generator decorator to disable automatic generation during varlock load or varlock run.

Terminal window
varlock codegen [options]

Options:

Examples:

Terminal window
# Generate using the default schema
varlock codegen
# Generate from a specific .env file
varlock codegen --path .env.prod
# Generate from multiple directories
varlock codegen -p ./envs -p ./overrides