Skip to content

Claude Code template

This template installs a pinned Claude Code release together with Git and ripgrep. A sandbox can use the CLI immediately without downloading packages at startup.

mjs
import { Sandbox, Template } from "@abox-dev/sdk";

const templateName = process.env.TEMPLATE_NAME ?? "claude-code";
const template = Template()
  .fromNodeImage("24-bookworm-slim")
  .aptInstall(["git", "ripgrep"])
  .npmInstall("@anthropic-ai/claude-code@2.1.252", { g: true });

await Template.build(template, templateName, {
  cpuCount: 2,
  memoryMB: 2_048,
});

const sandbox = await Sandbox.create(templateName);
try {
  const version = await sandbox.commands.run("claude --version");
  console.log(version.stdout);
} finally {
  await sandbox.kill();
}

The example prints the installed CLI version without calling Anthropic. To run an authenticated Claude Code session, pass ANTHROPIC_API_KEY when you create the sandbox. Do not store the key in the template or its build instructions.

Change the pinned package version and rebuild the template when you update Claude Code.