Agent Sandbox Registry

awesome-templates

Sandbox runtime for Anthropic Claude Code

无英文版

claude-code/README.md

claude-code

中文版 | English


English

Sandbox runtime for Anthropic Claude Code, preinstalled with the Claude Code CLI to support AI-driven coding, debugging, and refactoring.

Environment

This template comes preinstalled with the following tools and dependencies:

Category Details
Base image python:3.12-slim
Node.js Node.js 22.x + npm (core runtime)
Python Python 3.12 + venv (at /opt/venv)
Node packages @anthropic-ai/claude-code
Python packages anthropic, httpx, rich
System tools git, curl, ripgrep, build-essential
Resources 2 CPU / 4096 MB memory

Installation

Install from a local path:

abx template install ./claude-code --registry-type local

Install from GitHub:

abx template install alibaba-agent-sandbox/awesome-templates//claude-code

Usage

Create a sandbox instance and pass in the API key:

abx create --template claude-code --env ANTHROPIC_API_KEY=sk-ant-xxx

Launch Claude Code inside the sandbox:

abx exec <sandbox-id> -- claude "Write a Python HTTP server"

Run a task in non-interactive mode:

abx exec <sandbox-id> -- claude -p "Refactor this function for better performance" --allowedTools "Edit,Read,Write"

Using the Python SDK:

from agent_sandbox import Sandbox

sandbox = Sandbox.create_sync(
    template="claude-code",
    env={"ANTHROPIC_API_KEY": "sk-ant-xxx"}
)

result = sandbox.commands.run("claude -p 'Generate a REST API scaffold'")
print(result.stdout)

Configuration

Environment Variables

Variable Description Required
ANTHROPIC_API_KEY Anthropic API key Yes
WORKSPACE Working directory path, defaults to /workspace No

Custom Configuration

To install extra dependencies on top of this template, run the following after the sandbox is created:

abx exec <sandbox-id> -- pip install <package-name>
abx exec <sandbox-id> -- npm install -g <package-name>

Notes


中文

Anthropic Claude Code 的沙箱运行环境,预装 Claude Code CLI,支持 AI 驱动的代码编写、调试和重构。

环境说明

本模板预装以下工具和依赖:

类别 内容
基础镜像 python:3.12-slim
Node.js Node.js 22.x + npm(核心运行时)
Python Python 3.12 + venv 虚拟环境(位于 /opt/venv)
Node 包 @anthropic-ai/claude-code
Python 包 anthropic、httpx、rich
系统工具 git、curl、ripgrep、build-essential
资源配置 2 CPU / 4096 MB 内存

安装方式

从本地安装:

abx template install ./claude-code --registry-type local

从 GitHub 安装:

abx template install alibaba-agent-sandbox/awesome-templates//claude-code

使用示例

创建沙箱实例并传入 API Key:

abx create --template claude-code --env ANTHROPIC_API_KEY=sk-ant-xxx

在沙箱中启动 Claude Code:

abx exec <sandbox-id> -- claude "编写一个 Python HTTP 服务器"

非交互模式执行任务:

abx exec <sandbox-id> -- claude -p "重构这个函数以提高性能" --allowedTools "Edit,Read,Write"

使用 Python SDK:

from agent_sandbox import Sandbox

sandbox = Sandbox.create_sync(
    template="claude-code",
    env={"ANTHROPIC_API_KEY": "sk-ant-xxx"}
)

result = sandbox.commands.run("claude -p '生成一个 REST API 框架'")
print(result.stdout)

配置说明

环境变量

变量名 说明 必填
ANTHROPIC_API_KEY Anthropic API 密钥 是
WORKSPACE 工作目录路径,默认 /workspace 否

自定义配置

如需在模板基础上安装额外依赖,可在创建沙箱后执行:

abx exec <sandbox-id> -- pip install <package-name>
abx exec <sandbox-id> -- npm install -g <package-name>

注意事项

Deploy and local e2e

Install and register this template:

abx template install alibaba-agent-sandbox/awesome-templates//claude-code

From this directory (build, push, and register):

abx deploy

From the repository root, with agent-sandbox-server and httpx installed:

python3 scripts/run_local_e2e.py

That starts python3 commands.py in this directory and runs e2e_test.py.