How to run Claude Code in a cloud sandbox
A Claude Code cloud sandbox on Impello is a remote Linux box you create from the claude template, pass ANTHROPIC_API_KEY into, and drive with the SDK: run claude -p non-interactively, read files back, set timeouts, pause to keep state, and kill when you are done.
Anyone can sign up. Impello is sold to businesses only. SDK calls match templates, commands, filesystem, timeouts and pause.
What this tutorial is
Search for a Claude Code sandbox, how to run Claude Code in the cloud, or a Claude Code cloud sandbox and you will mostly find laptop recipes: Dockerfiles, Dev Containers, or Anthropic's own cloud sessions. This page is the Impello path: an isolated Linux microVM in Germany or Finland that your TypeScript or Python code starts with Sandbox.create.
It is a step-by-step tutorial, not a comparison. The product surface for coding agents, including Codex and the other CLIs we ship, is coding agents. The SDK examples below are the same calls as Run an agent CLI.
Cloud-VM isolation is not Claude Code sandboxing
Two different products use the word sandbox. Mixing them up is how people ship an agent that still has the laptop's files.
Anthropic's sandboxed Bash tool is a boundary the operating system enforces around the shell commands Claude runs on your machine. It is off by default. It covers Bash, PowerShell and Monitor commands and the processes they start. Anthropic is explicit that it does not cover Claude's file tools, MCP servers or hooks — those still run outside it. To put the whole Claude Code process behind one boundary, Anthropic's sandbox environments page tells you to use a container, a virtual machine, or the sandbox runtime.
Impello is that outer boundary: a hardware-virtualised Linux microVM on servers Impello owns in the EU, not a Seatbelt or namespace around a local Bash. The claude binary runs inside the VM. Claude Code's own Bash sandbox can still be turned on inside that VM; it is optional, and it is still only a command boundary.
| Impello cloud sandbox | Claude Code Bash sandbox | |
|---|---|---|
| Where it runs | A remote microVM in Germany or Finland | The machine that started the Claude Code session |
| What is isolated | The whole guest OS, including the Claude Code process | Shell commands only. File tools, MCP servers and hooks run outside it |
| Who documents it | Impello templates and privacy | code.claude.com/docs/en/sandboxing |
Anthropic also sells cloud sessions, isolated by default in a VM Anthropic hosts. That is not this product. This tutorial uses Impello's claude template and SDK.
1. Before you start
You need three things, then an install.
- An Impello account. Sign up; the 7-day trial needs a card, one trial per card. Sandboxes are billed against team credit; a team with no plan cannot create one. See the quickstart.
- An Impello API key, in
IMPELLO_API_KEY. Create one at dashboard.impello.ai/keys. Both SDKs read that name. Details: API keys. - An Anthropic API key, in
ANTHROPIC_API_KEY. Nothing in theclaudetemplate is signed in. Anthropic documents that in non-interactive-pmode the key is used automatically when present (environment variables, authentication).
TypeScript
npm install @impello/sdk
Python
pip install impello
@impello/sdk needs Node 20.18.1 or later on the 20 line, or Node 22 or later. impello needs Python 3.10 or later. Both SDKs also read IMPELLO_API_KEY from the environment:
export IMPELLO_API_KEY=imp_... export ANTHROPIC_API_KEY=sk-ant-...
2. Create a sandbox from the claude template
Pass claude or its alias claude-code to Sandbox.create. Either name boots the same image: Ubuntu 25.04, Claude Code at ~/.local/bin/claude, Docker enabled at boot, Node 22, Python 3, pipx and uv. Size is 2 vCPU / 2 GB. The working directory is /home/user.
Pass the Anthropic key in envs. Those variables are set for every command you run; envs on a single command overrides them. They are ordinary process environment, not a secret store — Impello does not ship one.
Set a sandbox timeout. The default is 5 minutes (timeoutMs: 300_000 in TypeScript, timeout: 300 in Python) and activity does not move it. A Claude Code turn is usually longer than that.
TypeScript
import { Sandbox } from '@impello/sdk'
const key = process.env.ANTHROPIC_API_KEY
if (!key) throw new Error('Set ANTHROPIC_API_KEY')
const sandbox = await Sandbox.create('claude', {
envs: { ANTHROPIC_API_KEY: key },
timeoutMs: 600_000,
})Python
import os
from impello import Sandbox
sandbox = Sandbox.create(
"claude",
envs={"ANTHROPIC_API_KEY": os.environ["ANTHROPIC_API_KEY"]},
timeout=600,
)Sandbox.create('claude-code', …) is the same sandbox. Creating takes 1–3 seconds, not the ~80–200 ms some other cloud sandboxes advertise.
3. Run Claude Code non-interactively
Call the binary by its full path. commands.run uses bash -l -c, a login shell, which reads ~/.profile, not the PATH line the template appended to ~/.bashrc.
-p (also --print) is Claude Code's print mode: one prompt, the answer on stdout, then exit. That is Anthropic's flag, documented in the CLI reference and headless / programmatic page, not an Impello option.
Raise the command timeout. A command gives up after 60 seconds unless you pass timeoutMs (timeout, in seconds, in Python). 0 removes that limit.
TypeScript
const result = await sandbox.commands.run(
'~/.local/bin/claude -p "List the files in this directory"',
{ timeoutMs: 300_000 }
)
console.log(result.stdout)
console.log(result.exitCode)Python
result = sandbox.commands.run(
'~/.local/bin/claude -p "List the files in this directory"',
timeout=300,
)
print(result.stdout)
print(result.exit_code)A non-zero exit raises. See errors. Listing files can use Claude Code's read-only tools, which Anthropic says still run in Manual mode. A prompt that writes files needs an allowlist or a permission mode — the next step shows that. Anthropic's headless docs also cover --allowedTools, --output-format json and --bare; those flags belong to Claude Code. Impello only runs the command you pass.
For unattended runs that skip permission prompts, Anthropic says to put the whole Claude Code process in a container, a VM, or the sandbox runtime, and documents --dangerously-skip-permissions that way on sandbox environments. An Impello sandbox is the VM layer. This tutorial does not add that flag to the snippets; use it only if you have read Anthropic's conditions for it.
4. Read files back
After claude -p exits, the sandbox disk is still there. files.write creates or overwrites a file (and any missing parent directories). files.read returns the contents as text by default.
TypeScript
await sandbox.files.write(
'/home/user/hello.txt',
'hello\n'
)
const result = await sandbox.commands.run(
'~/.local/bin/claude -p "Write a one-line README.md that names this directory" --permission-mode acceptEdits',
{ timeoutMs: 300_000 }
)
const readme = await sandbox.files.read('/home/user/README.md')
console.log(result.stdout)
console.log(readme)Python
sandbox.files.write("/home/user/hello.txt", "hello\n")
result = sandbox.commands.run(
'~/.local/bin/claude -p "Write a one-line README.md that names this directory" --permission-mode acceptEdits',
timeout=300,
)
readme = sandbox.files.read("/home/user/README.md")
print(result.stdout)
print(readme)A claude -p run that writes files needs a permission mode. Anthropic's headless docs say that from Claude Code v2.1.302, -p starts in Manual mode: a call that needs approval is denied unless something approves it. --permission-mode acceptEdits lets Claude write files without prompting. Listing tools with --allowedTools is the other documented path. Neither flag is Impello's; both belong to Claude Code.
In TypeScript the format is an option: read(path, { format: 'bytes' }). In Python it is the second argument: read(path, format="bytes"). More formats, listing, and HTTP upload/download: filesystem.
5. Set timeouts
Three clocks. The sandbox itself defaults to 5 minutes. A single command defaults to 60 seconds. The API request is also 60 seconds, and does not bound a streaming command. TypeScript counts milliseconds; Python counts seconds.
setTimeout (set_timeout in Python) replaces the remaining sandbox life, measured from the moment the call arrives. A long job is a short timeout plus a heartbeat, not one enormous deadline.
TypeScript
await sandbox.setTimeout(900_000) await Sandbox.setTimeout(sandbox.sandboxId, 900_000)
Python
sandbox.set_timeout(900) Sandbox.set_timeout(sandbox.sandbox_id, 900)
The longest sandbox you can ask for depends on the plan: 1 hour on the 7-day trial, 12 hours on $20, 24 hours on $100 and $500. At the deadline the sandbox is killed and its disk goes with it, unless you set lifecycle: { onTimeout: 'pause' } at create time (on_timeout: "pause" in Python). A paused sandbox can be resumed from the same ID. Timeouts.
6. Pause and resume to keep state
A coding agent spends wall clock waiting on a model. Leave the sandbox running and Impello meters the reserved vCPUs the whole time: $0.018 an hour at 2 vCPU, idle or not. Call pause() and it costs nothing.
By default pause snapshots memory and disk, so processes and open files survive. Resume with Sandbox.connect(sandboxId); that starts a fresh timeout (5 minutes unless you pass one). Pass keepMemory: false (keep_memory=False) to persist only the filesystem — resume then cold-boots from disk.
TypeScript
const sandboxId = sandbox.sandboxId
await sandbox.pause()
const resumed = await Sandbox.connect(sandboxId, {
timeoutMs: 600_000,
})
console.log(await resumed.files.read('/home/user/README.md'))Python
sandbox_id = sandbox.sandbox_id
sandbox.pause()
resumed = Sandbox.connect(sandbox_id, timeout=600)
print(resumed.files.read("/home/user/README.md"))A sandbox that has sat paused for 14 days is deleted. The clock restarts every time you pause. Paused sandboxes do not count against concurrency, and there is no cap on how many you keep paused. Pause, resume and snapshots.
7. Kill the sandbox
kill() destroys the sandbox. It returns true when it killed one and false if the sandbox was not found, so killing twice is safe. Pause keeps the box; kill does not.
TypeScript
await sandbox.kill() await Sandbox.kill(sandbox.sandboxId)
Python
sandbox.kill() Sandbox.kill(sandbox.sandbox_id)
Put it in a finally (or Python with Sandbox.create(…), which kills on exit) so a failed prompt does not leave a running box on the meter.
Pricing and honest limits
Every plan meters at $0.0000025 per vCPU-second. The claude template is 2 vCPU, so an hour is $0.018. RAM, disk, egress, snapshots and paused time are not billed. Only running time, from start or resume until pause or kill.
A 7-day trial with $5 of credit (a card is required), then $20 / $100 / $500 a month, each plan returning its price as monthly credit. Plan credit expires at the end of the month; credit packs do not, while the account is open.
The same trade-offs we print everywhere else apply here:
- Starts take 1–3 seconds, not the ~80–200 ms some others advertise.
- Burst is modest: 5 starts a minute on the trial, 65 a minute and 300 concurrent sandboxes on the $500 plan. A create over the cap is refused, not queued.
- A sandbox may run for 1 hour on the trial, 12 hours on $20, or 24 hours on $100 and $500.
- A paused sandbox is kept 14 days, then deleted.
- Compute is EU only. There is no region option, no GPU, no Windows, no macOS, no SLA, no status page and no support channel.
- We do not ship a CLI, volumes, a secrets store, or a code-interpreter / desktop client package.
The agent CLI is installed unpinned. Each weekly rebuild of the default templates picks up Anthropic's current Claude Code release. To freeze a version, build your own template from fromTemplate('claude').
FAQ
How do I run Claude Code in a cloud sandbox on Impello?
Create a sandbox from the claude template (also named claude-code), pass ANTHROPIC_API_KEY in envs, and run ~/.local/bin/claude -p. Raise the command timeout: the default is 60 seconds. Anyone can sign up for a 7-day trial.
Is an Impello sandbox the same as Claude Code sandboxing?
No. Anthropic's built-in Bash sandbox restricts the shell commands Claude runs on the machine that started the session; file tools, MCP servers and hooks still run outside it. An Impello sandbox is a remote Linux microVM in the EU. The whole Claude Code process runs inside that VM.
How do I pass the Anthropic API key?
Pass ANTHROPIC_API_KEY in envs on Sandbox.create. Impello does not ship a secrets store. Anthropic documents that in non-interactive -p mode the key is used automatically when present.
Does pause keep Claude Code state?
By default pause snapshots memory and disk, so processes and open files survive. Resume with Sandbox.connect(sandboxId). A sandbox paused for 14 days is deleted. Pause costs $0; a sandbox left running still meters.
How long can a Claude Code run last?
The sandbox timeout defaults to 5 minutes. The plan cap is 1 hour on the 7-day trial, 12 hours on the $20 plan, and 24 hours on the $100 and $500 plans. At the deadline the sandbox is killed unless you set lifecycle onTimeout to pause. A single command times out after 60 seconds unless you raise it (or pass 0 to remove the limit).
Sign up
Anyone can sign up. If a Claude Code cloud sandbox in the EU is what you need, start a 7-day trial.
The product page for this use case is coding agents. Code, not copy: templates, commands, filesystem, timeouts, pause and snapshots. How to choose among providers: best AI agent sandboxes.
Sources
Impello facts are from this site's docs and code. Claims about Claude Code itself are from Anthropic's official docs, read for this page. No competitor list rate is quoted.
- Templates, aliases, binaries,
envs, login-shellPATH: /docs/templates,templates/claude/template.ts - Create, commands, files, timeouts, pause, kill: quickstart, commands, filesystem, timeouts, pause and snapshots, sandbox lifecycle
- Rate, trial, plans, EU regions, no SLA: limits and pricing, pricing,
PAID_PLANS/ trial constants in@impello/site-contract - Isolation as a hardware-virtualised VM: privacy (Security)
- Claude Code Bash sandbox (shell commands only; file tools, MCP and hooks outside): code.claude.com/docs/en/sandboxing
- Whole-process isolation needs a container, VM, or sandbox runtime;
--dangerously-skip-permissionsthe same way; Anthropic-hosted cloud sessions: code.claude.com/docs/en/sandbox-environments -p/--printnon-interactive mode: CLI reference, headless- Writes in
-pneed--permission-mode acceptEditsor--allowedTools(Manual mode from v2.1.302): auto-approve tools ANTHROPIC_API_KEYused automatically in-pmode: environment variables, authentication