Goal
Run code in a clean, isolated machine from your terminal or a pipeline without creating or cleaning up a sandbox.Prerequisites
- A signed-in profile or an API key
- A sandbox template reference with its digest, from Sandbox templates in the dashboard
Workflow
1
Pass the template with
--template.2
Put the command after
--, or pass a script with --script.3
Copy in local files with
--file REMOTE=LOCAL and set variables with --env KEY=VALUE.4
Read the output in your terminal and check the exit code.
Usage
Flags
--template(required): the template reference with its digest.--sandbox-profile: the size of the sandbox, such asci,customer_codeorplugin. Defaults toci.--file REMOTE=LOCAL: copy a local file to a path in/workspace. Repeat it for more files, up to 100 files and 8 MB in total.--env KEY=VALUE: set an environment variable for the command. Repeat it for more.--script FILE: run a script file instead of a command. Use-to read the script from standard input.--interpreter PROGRAM: the program that runs--script, such aspython3ornode. Defaults tosh.--shell: run the words after--as one shell line, so pipes,&&and variables work. Without it the command runs directly, without a shell.--cwd: the working directory. Defaults to/workspace.--command-timeout: seconds the command may run, from 1 to 600. Defaults to 60.
Examples
Output and exit code
The command’s standard output goes to your standard output and its standard error to your standard error, so you can pipe and redirect them as usual. When the command exits with a non-zero code, the CLI exits with the same code. With--output json, the CLI prints the whole result instead: state, exit_code, stdout, stderr, the truncation flags, start_ms and duration_ms.
The sandbox is deleted whether the command succeeds, fails or runs out of time.
Expected result
The command’s standard output and standard error are printed to yours, the CLI exits with the command’s exit code, and the sandbox is deleted.
Common failures
Related guides
Run code in one call
Send code and a command, get back the exit code and output. StackShift starts a fresh sandbox, runs it and deletes the sandbox, all in one request.
Logs, remote execution, and environment variables
Inspect runtime output, execute structured commands, and mutate environment variables safely.