Pass environment variables
Declare which variables reach the sandbox, agent and commands.
Select variables for the process that needs them. Model-provider, storage and sandbox-allocation credentials usually belong to host clients; agent and tool credentials may need to enter the sandbox. Do not forward the whole host environment.
Choose where to declare a variable
Section titled “Choose where to declare a variable”Declare each variable where it is needed: on the sandbox provider, on a CLI harness or on one command. Outpost forwards declared names; choose the scope that reaches only the processes needing the value.
| Where | Reaches | Use it for |
|---|---|---|
Sandbox provider variables | Every command in the sandbox, the agent included | Tool settings such as CI or NODE_ENV |
Harness variables (CLI agents) | The agent’s processes only | API keys, agent settings, MCP secrets |
Command variables | That one command | A per-call override |
.outpost/.env in the target repository | Every command in the sandbox, like the provider’s | Values you keep out of code for a checkout |
Values are strings. Select each name from process.env explicitly: spreading process.env would send every host secret into the sandbox. Per-command variables are shown in Sandbox sessions.
Load declared names from secret managers with fromSecrets() before composing your agent or sandbox. Vault/OpenBao, 1Password, Infisical, AWS, Google Cloud and Azure adapters return variables without an environment file.
Understand value precedence
Section titled “Understand value precedence”For an ordinary command, command variables override provider variables, which override values loaded from .outpost/.env. Harness variables target agent processes; they are not an override layer for provider variables. Declare each name in only one of those two places.
Outpost also sets GIT_AUTHOR_* and GIT_COMMITTER_* from the repository’s Git configuration; any declared source overrides them.
File workspaces (directory and ephemeral) never load .env implicitly. Pass their variables explicitly.
Keep values in .outpost/.env
Section titled “Keep values in .outpost/.env”Outpost reads .outpost/.env at the root of the target repository when it prepares a sandbox. A missing file is ignored.
A nonempty value is used as written. An empty declaration such as LINEAR_API_KEY= takes the value from the environment of the process running Outpost. Lines accept export, quotes and trailing # comments.
Load a file from your script
Section titled “Load a file from your script”Node.js can load an environment file before running your script:
Your code then selects the values to forward with variables. Loading the file into Node.js does not automatically send its contents to the sandbox. The .env path is relative to the directory where you run the command.
Secrets for MCP servers and the built-in harness
Section titled “Secrets for MCP servers and the built-in harness”MCP servers name their secrets; Outpost never writes the values into their configuration.
- CLI agentsDeclare the secret on the harness
variables, the sandbox provider or in.outpost/.env. - Built-in harness
createHarness()has novariables. Declare the secret on the sandbox provider or in.outpost/.env. - Model providersThe
apiKeystays on the host, in your code. Do not forward it to the sandbox.
A missing secret fails before the server starts, with Missing NAME.
Host or sandbox
Section titled “Host or sandbox”Declare only what code in the sandbox needs. Sandbox allocation keys and storage keys stay on the host with their clients: see Authentication.
Limits
Section titled “Limits”- With host execution, commands also inherit the whole environment of the Outpost process.
- An unset
process.env.NAME ?? ""forwards an empty string, not an absent variable.
API: Variables · Command · createDockerSandboxProvider · createClaudeHarness · createHarness.

