Skip to main content
Templates define the starting state of a sandbox: the base image, installed packages, and startup configuration. Use built-in templates or create custom ones.

Default Templates

TemplateDescription
basePython 3.11, Node.js 20, Yarn, Git, and GitHub CLI
claude-agent-pythonClaude Agent SDK with Python 3.11, Node.js 20, and Claude Code CLI
from moru import Sandbox

# Use default templates
sandbox = Sandbox.create("base")
sandbox = Sandbox.create("claude-agent-python")
See Default Templates for detailed specifications of each template.

Custom Templates

Create templates with your specific dependencies:
from moru import Template

# Define a custom template
template = (
    Template()
    .from_python_image("3.11")
    .pip_install(["requests", "beautifulsoup4", "selenium"])
    .apt_install(["chromium-browser", "chromium-chromedriver"])
    .set_envs({"CHROME_BIN": "/usr/bin/chromium-browser"})
    .set_start_cmd("bash", "echo 'Ready'")
)

# Build the template
info = Template.build(template, alias="web-scraper")
print(f"Template built: {info.template_id}")

# Now use it
sandbox = Sandbox.create("web-scraper")

Template Lifecycle

  1. Define: Specify base image, packages, and configuration
  2. Build: Moru builds and caches the template
  3. Ready: Template is available for use
  4. Create: Sandboxes start instantly from the cached template

Template Benefits

Fast Startup

Sandboxes start in seconds with all dependencies pre-installed.

Consistency

Every sandbox starts with the exact same environment.

Cost Efficiency

Install once, use many times - no repeated package downloads.

Template Components

Base Image

Start from an official image:
Template().from_python_image("3.11")
Template().from_node_image("lts")
Template().from_ubuntu_image("22.04")
Template().from_base_image()  # Moru's optimized base

Packages

Install packages during build:
template = (
    Template()
    .from_python_image("3.11")
    .pip_install(["numpy", "pandas", "scikit-learn"])
    .apt_install(["libpq-dev", "build-essential"])
    .npm_install(["typescript", "eslint"], g=True)
)

Files

Copy files into the template:
template = (
    Template()
    .from_base_image()
    .copy("./config", "/app/config")
    .copy(["./src", "./lib"], "/app")
)

Startup

Configure how sandboxes start:
template = (
    Template()
    .from_node_image()
    .copy("./app", "/app")
    .set_workdir("/app")
    .set_start_cmd("node server.js", "curl localhost:3000/health")
)

Next Steps