For anything heavy or slow, do not script it at all: bake it into a template Box so it is already installed when the Box starts.
Repository setup scripts
Attached to a repository in Dashboard > Environment. Runs once when the Box starts, inside that repository’s folder, with your environment’s variables and secret files already in place.Pre-commit hooks
Also per repository, run before each commit made in that repository. Mark a hook blocking to fail the commit when the hook fails.Talking back to the Box
Setup scripts and hooks can both steer the agent running in the Box:
That turns a failing hook into an instruction rather than a dead end:
Per-Box setup file
When the work differs from Box to Box, pass a local script at create time. Up to 64KB, UTF-8.ready. Watch it with box 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.ready first; earlier calls are refused with a retryable box_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 Box 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.