Skip to main content

Remote sandboxes

Run OpsCode in isolated cloud environments instead of on your local machine

Remote sandboxes let OpsCode execute tools (shell commands, file operations, scripts) in an isolated cloud container instead of on your workstation. This is useful for:

  • Blast radius isolation — Safely run infrastructure commands without risking your local environment.
  • Reproducibility — Consistent Linux container environments every time.
  • Credential safety — Prevent access to local SSH keys, env vars, or personal files.
  • CI/CD — Spin up ephemeral sandboxes for automated checks in pull requests.

Launch a sandbox

# Use the default sandbox provider
ops --sandbox

# Use a specific provider
ops --sandbox daytona

# Attach to an existing sandbox
ops --sandbox-id sb-prod-cluster-98234

# Use a pre-baked snapshot with a setup script
ops --sandbox modal \
--sandbox-snapshot-name terraform-k8s-base \
--sandbox-setup ./scripts/sandbox-init.sh

CLI flags

FlagWhat it does
--sandbox [TYPE]Enable a sandbox provider (agentcore, daytona, langsmith, modal, runloop, vercel)
--sandbox-id IDAttach to an already-running sandbox
--sandbox-snapshot-name NAMELaunch from a pre-baked container snapshot
--sandbox-setup PATHShell script to run inside the sandbox after it starts

Supported providers

ProviderIDWorking directoryWhat it offers
AgentCoreagentcore/tmpManaged AWS execution
Daytonadaytona/home/daytonaSelf-hosted & cloud dev environments
LangSmithlangsmith/rootEphemeral evaluation sandboxes
Modalmodal/workspaceServerless GPU/CPU containers
Runlooprunloop/home/userSnapshots and fast container boot
Vercelvercel/vercel/sandboxEphemeral Vercel code sandboxes

Workspace sync

When a sandbox starts, OpsCode automatically uploads your project files to the remote environment. It detects project boundaries, traverses the repository tree, and skips common ignored directories (.git/, node_modules/, .venv/, __pycache__/).


Setup scripts

Run initialization tasks inside the sandbox immediately after it starts:

ops --sandbox modal --sandbox-setup ./scripts/ci-setup.sh

./scripts/ci-setup.sh:

#!/usr/bin/env bash
set -euo pipefail

# Install DevOps tools
apt-get update && apt-get install -y opentofu kubectl helm awscli

# Verify
tofu version
kubectl version --client=true
helm version

How routing works

When a sandbox is active, OpsCode routes tool calls intelligently:

  • Shell commands, file reads/writes, grep, glob → Remote sandbox
  • Web search, URL fetching → Local host (no need to proxy these)

Sandboxes are automatically cleaned up when your session ends.


CI/CD example

Combine sandboxes with headless mode and rubrics for zero-trust automation:

ops -n "Run OpenTofu plan and check for security violations" \
--sandbox runloop \
--sandbox-setup ./scripts/ci-init.sh \
--rubric "tofu plan succeeds with zero syntax errors and no open security group ingress" \
--quiet \
-y