Managing Variables
Day-to-day workflow for adding, editing, and removing variables.
show, edit, hide. That's it. add, remove, ls, and toggle exist for when you'd rather not open the file at all.
show
npx dotvars show [file]Decrypts a config.vars file and renames it to config.unlocked.vars. The encrypted values are replaced with their plaintext. Edit the file directly, then run hide.
Before it decrypts, vars auto-fixes safety issues:
- Warns if
.vars/keyis missing - Warns if the pre-commit hook isn't installed
Flags
| Flag | Short | Description |
|---|---|---|
--file <path> | -f | Target a specific .vars file |
npx dotvars show -f staging.varshide
npx dotvars hideEncrypts ALL unlocked .unlocked.vars files. Scans for any *.unlocked.vars file in the current project and encrypts each one, renaming it back to .vars. You don't need to specify a file.
Encryption is all-or-nothing per file — if any value fails, that file stays untouched. No partial writes, no corrupted state.
If schemas changed since the last gen run, hide regenerates the TypeScript types automatically.
Flags
| Flag | Short | Description |
|---|---|---|
--file <path> | -f | Target a specific file only |
npx dotvars hide -f staging.varstoggle
npx dotvars toggle [file]Checks the current lock state of the file (by extension) and runs the right command. File is .unlocked.vars? Hides it. File is .vars? Shows it. Same command either way.
Flags
| Flag | Short | Description |
|---|---|---|
--file <path> | -f | Target a specific .vars file |
add
npx dotvars add NAMEAdds a variable without opening the file. vars prompts you for a Zod schema, then asks for a value per environment (default, dev, staging, prod). Skip any env you don't need yet.
The variable is encrypted and written straight into config.vars.
Names must be UPPER_SNAKE_CASE. Mark a variable as non-secret with the public keyword prefix — public variables are stored in plaintext and do not require a key to read.
Flags
| Flag | Short | Description |
|---|---|---|
--schema <zod> | -s | Skip the schema prompt |
--file <path> | -f | Use a different vars file |
npx dotvars add STRIPE_KEY --schema "z.string().startsWith('sk_')"remove
npx dotvars remove NAMEDeletes the variable, every env value, and all metadata. Prompts for confirmation first.
Flags
| Flag | Short | Description |
|---|---|---|
--yes | -y | Skip the confirmation prompt |
--file <path> | -f | Use a different vars file |
npx dotvars remove OLD_API_URL --yesls
npx dotvars lsWithout a file argument: prints an overview of all *.vars files in the project with their lock state and variable count.
FILE STATE VARS
config.vars locked 12
staging.vars unlocked 5With a file argument: prints a table of every variable in that file — schema, which envs have values, required vs optional, and any metadata (description, owner, expiry, deprecation). Deprecated vars show with strikethrough.
npx dotvars ls config.varsNAME SCHEMA ENVS STATUS
DATABASE_URL z.string().url() dev, staging, prod required
PORT z.coerce.number() default optional
~~OLD_API_URL~~ z.string().url() default deprecatedFlags
| Flag | Short | Description |
|---|---|---|
--file <path> | -f | Use a different vars file |
Day-to-day
# Unlock (config.vars → config.unlocked.vars)
npx dotvars show
# Edit config.unlocked.vars directly
# Lock (config.unlocked.vars → config.vars)
npx dotvars hideOr skip the file entirely and use add and remove.