Skip to main content
Three ways to run code in a sandbox, from the one that needs no code of your own to the one you drive entirely from your backend. They stack, so most setups use more than one. For anything heavy or slow, do not script it at all: bake it into a template sandbox so it is already installed when the sandbox starts.

Repository setup scripts

Attached to a repository in Dashboard > Environment. Runs once when the sandbox starts, inside that repository’s folder, with your environment’s variables and secret files already in place.
Mark it blocking when the sandbox is not usable until it finishes. A blocking script delays the sandbox reaching ready; a non-blocking one runs alongside everything else.

Talking back to the sandbox

Setup scripts can steer the agent running in the Sandbox: That turns a failing step into an instruction rather than a dead end:

Per-Sandbox setup file

When the work differs from Boat to Boat, pass a local script at create time. Up to 64KB, UTF-8.
It runs in the background once the sandbox is ready and never delays ready. Watch it with boat info:

Driving setup from your code

Configure secrets in the environment first, then run whatever you need. The script reads normal environment variables and the secret files at their configured paths, so nothing sensitive passes through the command line.
Wait for the sandbox to reach ready first; earlier calls are refused with a retryable boat_starting. Synchronous commands cap at 600 seconds, so anything longer should detach and be polled. See Long-Running Tasks. To pipe a script that is not on the sandbox yet, use SSH instead. It streams stdin, stdout and stderr, so nothing has to be copied to a temporary path first:
On Windows, run this from Node, Python, WSL, Git Bash, or cmd.exe. Native PowerShell pipelines can keep stdin open for native executables, which hangs the command.