clavis run
Run a command with secrets injected and output masked
clavis run [flags] [COMMAND [ARGS...]]Start your app with the environment's secrets as environment variables. Clavis starts the command itself, so you keep one terminal; anything the command prints is masked, so secret values don't end up in logs.
Clavis flags go before the command. Everything from the first word of the command on belongs to your command, so -- is optional: clavis run rails s -p 3001 passes -p 3001 to Rails.
Without a command, clavis run starts the run: command saved in .clavis.yaml. clavis init fills it in when it recognizes the project.
In a terminal, interactive programs such as rails c, irb or psql work normally: the command runs on a pseudo-terminal (a ConPTY on Windows 10 version 1809 and later), so it draws its prompt, colors and line editing, and its output is still masked. In scripts and CI the command's output is piped instead. Use --no-pty to force pipes in a terminal.
Examples
A Rails console with secrets
clavis run rails cShow one value in a console, keep the rest masked
clavis run --reveal SIDEKIQ_WEB_PASSWORD rails cRead real values in a console, on your own screen
clavis run --no-mask rails cRun the command saved in .clavis.yaml
clavis runNode.js
clavis run npm run devRails, with its own flags
clavis run rails s -p 3001Django
clavis run python manage.py runserverUse another environment
clavis run --env staging npm startRestart when a secret changes
clavis run --watch pnpm devFile secrets become private temporary files
clavis run --mount ./start.shUse -- when your command itself starts with a dash
clavis run -- -my-tool --flagFlags
--mount- write file secrets to a private temp directory and expose their paths as env vars
--no-mask- disable output masking (dangerous)
--no-pty- in a terminal, run the command on pipes instead of a pseudo-terminal (no prompts, colors or line editing for interactive programs)
--reveal strings- show these keys' values in the output while masking the rest (terminal only), e.g. --reveal SIDEKIQ_WEB_PASSWORD
--watch- restart the command when the environment's secrets change
Details
- Masking replaces injected values in the command's output with
••••••, in a console too:ENV['API_KEY']prints"••••••", though your code still gets the real value. It protects logs and screen shares; it is not a security boundary. Put--no-maskbefore the command to see real values, for example to debug inrails c. Only do that on your own screen: values print in clear text, so keep it out of screen shares, recordings and pasted output. To show only some keys, use--reveal KEY(repeat it or separate keys with commas): those values print in clear text and everything else stays masked. It only works when the output is your own terminal. To read a single value without a console,clavis secrets get KEYis enough. More in Consoles and masking. --watchlistens for changes and restarts the command with fresh values whenever this environment's secrets change.--mountwritesfilesecrets to a0700temporary directory as0600files, puts each file's path in the variable, and removes the directory when the command exits.- Offline: with
cache: truein.clavis.yaml, the last values are used for up to 24 hours when the server is unreachable. See offline cache. clavis runexits with your command's exit code.
Global flags
These work with every command.
--debug- enable debug logging
--env string- environment slug
--json- output machine-readable JSON
--org string- organization slug
--overlay string- tenant/region overlay slug
--path string- folder path (default /)
--project string- project slug
--server string- Clavis server URL (default: from .clavis.yaml or saved login)
-h, --help- help for any command