Skip to main content
Claude Code is Anthropic’s CLI coding agent — it reads your code, writes changes, runs commands, and iterates on errors. That power comes with risk: it has full shell access. Running it inside a BoxLite sandbox means it can do its job without touching your host system.

Prerequisites

Requires Python 3.10+.
You also need an Anthropic API key.

Step 1: Run Claude Code on your project

The core workflow: mount your project read-only into the sandbox, let Claude Code work on a writable copy, and collect the results on your host.
claude_code.py
After running, check ./output/ on your host — Claude Code’s changes are already there via the volume mount. You can review them, diff against the original, and merge what you want:
Always mount your source code as read-only. Let Claude Code work on a copy inside the sandbox. This way your original files are never modified until you explicitly merge the changes.
Installing Claude Code at runtime takes 30-60 seconds. For repeated use, build a custom Docker image with Claude Code pre-installed and use it as image="your-registry/claude-code:latest".

Step 2: Chain multiple tasks

Reuse the same sandbox for a multi-step pipeline. Files persist between claude --print invocations, so each step builds on the previous one.
claude_code_pipeline.py
All generated files land in ./output/ on your host.

Security tips

Never hardcode API keys. Pass them via environment variables. In production, use a secrets manager.
  • Read-only source mounts — Your original code is never modified. Review diffs before merging.
  • Resource limits — Claude Code can be resource-intensive. 4096 MiB and 2 CPUs is a good starting point.
  • Disposable sandboxes — Each sandbox is ephemeral. If Claude Code installs something dangerous, it disappears when the box stops.

What’s next?

Connect to an LLM

Build your own LLM tool-calling loop with BoxLite for custom code execution.

Execute AI-generated code

Run untrusted Python code safely with CodeBox — auto-install packages and capture output.

Upload & download files

Move source code and results in and out of your sandbox.

AI agent integration

Production patterns for running AI agents with BoxLite.