Klef docs
Commands

Running commands

Launch a process with the current environment's secrets injected as environment variables.

klef run

Run a command with the current environment's secrets injected as environment variables. The secrets exist only in the child process's environment. They are never written to disk.

klef run -- npm run dev

Use -- to separate Klef's own flags from the command you want to run. Everything after the command name is forwarded to the child process untouched, so flags like node --version are passed through rather than consumed by Klef.

Options

FlagDescription
-e, --env <name>Override the environment from .klef.
--cleanDrop parent env vars except PATH, HOME, and locale. Secrets only.
--quietSuppress override warnings and the "Running" banner.

Examples

Run your dev server with development secrets:

klef run -- npm run dev

Run against production secrets:

klef run --env production -- node server.js

Run with only your secrets in the environment, dropping inherited variables:

klef run --clean -- ./migrate.sh

Why klef run over a .env file

klef run keeps secrets out of files entirely. Nothing is written to disk, so there is no .env.local to accidentally commit or leave behind.

On this page