CLI: Exec
valet exec runs a local command with Valet-managed env vars injected into its environment. It fetches env var values (both kinds) from the control plane and executes the given command with those values added to the environment. The current process is replaced by the command.
There are two modes:
Integration mode (no --)
Without a -- separator, the first argument is looked up as an integration name. If a command integration is found, its secrets are fetched and injected, and the integration's command is executed. Extra arguments are appended after the integration's configured args.
valet exec [-a <agent>] <connector-name> [extra-args...]# Run a command integration named "gh" (with its secrets injected)
valet exec --agent my-agent gh pr list
# Use the linked agent from the current directory
valet exec gh pr listExplicit env vars mode (with --)
With a -- separator, env var names are passed as the first positional argument, comma-separated. The command and its arguments follow after --.
valet exec [-a <agent>] NAME[,NAME...] -- command [args...]# Run gh with GITHUB_TOKEN injected as an env var
valet exec --agent my-agent GITHUB_TOKEN -- gh pr list
# Inject multiple env vars
valet exec --agent my-agent GITHUB_TOKEN,SLACK_TOKEN -- envTemplate syntax
Use {{NAME}} in command arguments to pass env var values directly as CLI arguments. This is useful for tools that accept credentials as flags, URLs, or header values rather than reading from the environment. Env vars are also injected as environment variables, so tools that read credentials from the environment (like gh) work without templates.
# Env var as URL parameter
valet exec --agent my-agent API_KEY -- curl "https://api.example.com?key={{API_KEY}}"
# Env var embedded in a header value
valet exec --agent my-agent API_KEY -- curl -H "Authorization: Bearer {{API_KEY}}" https://api.example.com
# Multiple env vars, one as env var and one as an argument
valet exec --agent my-agent DB_HOST,DB_PASSWORD -- psql "postgresql://user:{{DB_PASSWORD}}@{{DB_HOST}}/mydb"Template substitution applies only to user-supplied arguments. It does not apply to a integration's preconfigured args in integration mode.
Flags
--agentor-a— Agent that owns the env vars. If omitted, Valet uses the linked agent from the current directory.--orgor-o— Org that owns the agent.