Skip to main content
Setup scripts are bash scripts that run automatically when a workspace starts. They let you define reproducible environments - install packages, clone repos, seed databases, configure tools - so every workspace boots into a ready-to-use state.

How Setup Scripts Work

When a workspace starts, Rigbox executes all attached setup scripts inside the VM as the developer user. Scripts run sequentially in the order you specify, with full network access and sudo privileges. Each script has a run mode that controls when it executes:
Use first_boot for one-time setup like installing packages or cloning repos. Use every_start for configuration that might change between restarts, like refreshing tokens or syncing files.

Create a Setup Script

Write the script to a local file, then create it with the CLI. Once created, you can attach it to any number of workspaces.
See the Setup Scripts API reference for the full request and response schema.

Script Content Guidelines

Setup scripts run as bash inside the workspace VM. Here are guidelines for writing reliable scripts:
Always use set -e at the top of your scripts. Without it, a failing command will not stop execution, and subsequent commands may run in a broken state.

Attach Scripts to a Workspace

Pass --setup-script-id (repeatable) when spawning a workspace. Scripts run in the order you list them.

Script Ordering

Scripts execute sequentially in array order. This is important when scripts have dependencies:

List Your Scripts

Retrieve all setup scripts in your account.
See the List Setup Scripts API reference for pagination and filtering options.

Update a Script

Modify an existing script’s name and/or body. Pass --name, --file, or both.
Updating a script affects all future workspace starts that reference it. Already-running workspaces will pick up the change on their next restart (for every_start scripts) or not at all (for first_boot scripts that have already executed).

Delete a Script

Deleting a script that is still attached to workspaces will cause those workspaces to skip that script on future starts. The workspace itself is not affected.

Combining with Templates

Templates can include their own setup scripts. When you create a workspace with both a template and additional setup_script_ids, the template’s scripts run first, followed by yours.
Execution order:
  1. Template dev scripts (e.g., install Node.js, npm packages)
  2. Your script ss_my_custom_config (e.g., clone your repo, set up environment)
This layering lets you build on top of standard templates without duplicating their setup logic.

Use Case: Team Onboarding

Create a single setup script that configures everything a new team member needs. Every workspace they create starts fully configured.
Then set this as the default for all new workspaces via a template, and every new hire gets an identical development environment in seconds.

Use Case: Ephemeral Demo Environments

For product demos, create a setup script that loads sample data and starts services:
Combine this with a service spec that auto-starts the app server, and you have a one-click demo environment.

Debugging Setup Scripts

If a setup script fails, the workspace will still start, but the script’s exit code and output are captured. To check script execution results, look at the workspace status after it starts:
Add echo statements throughout your scripts for visibility. The output is captured and available in the workspace details, making it easier to pinpoint where a script failed.

Next Steps

  • Service Specs - define background services that auto-start after setup completes
  • Snapshots - snapshot a fully configured workspace and restore it later
  • Managed AI Proxy - add AI capabilities to your scripted environments