Leap0

Claude Code

Run Claude Code inside Leap0 sandboxes.

Run Claude Code, Anthropic's agentic coding tool, inside Leap0 sandboxes. You can either bake it into a template or install it at runtime using process.execute.

Install at runtime

Install Claude Code directly in a running sandbox using the process API:

import { Leap0Client } from "leap0";

const client = new Leap0Client();
const sandbox = await client.sandboxes.create();

// Install Claude Code
await sandbox.process.execute({
  command: "curl -fsSL https://claude.ai/install.sh | bash",
  timeout: 120,
});

// Verify installation
const result = await sandbox.process.execute({
  command: "claude --version",
});

console.log(result.stdout);
await client.close();
from leap0 import Leap0Client

client = Leap0Client()
sandbox = client.sandboxes.create()

# Install Claude Code
sandbox.process.execute(
    command="curl -fsSL https://claude.ai/install.sh | bash",
    timeout=120,
)

# Verify installation
result = sandbox.process.execute(command="claude --version")
print(result.stdout)

Template Dockerfile

To avoid installing on every boot, bake Claude Code into a template:

FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    curl \
    git \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Install Node.js 18+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
    apt-get install -y nodejs && \
    rm -rf /var/lib/apt/lists/*

# Install Claude Code
RUN npm install -g @anthropic-ai/claude-code

CMD ["bash"]

Build and publish the image

docker build -t registry.example.com/my-org/claude-code-template:v1 ./claude-code
docker push registry.example.com/my-org/claude-code-template:v1

Create the Leap0 template

import { Leap0Client } from "leap0";

const client = new Leap0Client();

const template = await client.templates.create({
  name: "claude-code",
  uri: "registry.example.com/my-org/claude-code-template:v1",
});

console.log(template.id);
await client.close();

Start a sandbox

const sandbox = await client.sandboxes.create({
  template_name: "claude-code",
});

// Run Claude Code with your API key
await sandbox.process.execute({
  command: "claude 'explain the main function in this project'",
  env: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY },
  cwd: "/home/user/project",
  timeout: 300,
});

Was this page helpful?

On this page