claude-code template gives you a ready-to-use, isolated environment where Claude Code can read and edit code, run commands, and complete multi-step engineering tasks autonomously — without directly modifying files on your local machine.
Typical use cases:
- Autonomous coding tasks — hand Claude Code a prompt (e.g. “add error handling to all API endpoints”) and let it implement changes end to end.
- Working on real repositories — clone a Git repo into the sandbox and have Claude Code refactor, fix bugs, or add features.
- Safe, unattended automation — run the agent fully automatically inside an isolated sandbox, so file and command actions never affect your own environment.
- Multi-step workflows — start a session to plan, then resume it to carry out each step.
claude-code template comes with Claude Code pre-installed, so you can spin up a sandbox and drive Claude Code in just a few lines. The example below runs Claude Code in headless mode — a non-interactive, one-shot run that takes a prompt, produces its output, and exits, with no interactive terminal session — which is exactly what you want when driving it programmatically inside a sandbox. Create a sandbox from the template, run the claude CLI through commands.run, stream its output, then kill the sandbox.
Quick start
-p "<prompt>" (--print): runs Claude Code in non-interactive mode — it processes the prompt, prints the result to stdout, and exits, instead of opening an interactive session. This is what makes it scriptable inside a sandbox.--dangerously-skip-permissions: skips the interactive approval prompts Claude Code normally shows before running tools (editing files, executing commands, etc.). It lets the agent act fully unattended, which is convenient in an isolated sandbox — but as the flag name warns, use it only in trusted, sandboxed environments, since the agent can take file and command actions without asking.Custom Claude configuration
To make Claude Code use a custom LLM (custom API token, base URL, or model), write the configuration to~/.claude/settings.json after creating the sandbox and before running claude. The env block in settings.json is injected into Claude Code as environment variables.
Python
Work on a cloned repository
A common workflow is to clone a Git repository into the sandbox and let Claude Code work on it. Usesandbox.git.clone to check out the repo (with credentials for private repos), then run claude from inside the cloned directory.
Resume a session
Claude Code can continue a previous session, so you can run a multi-step workflow across several invocations. Start a session with--output-format json to get a session_id in the response, then pass it to --resume on the next run to continue where you left off.