Skip to main content
Coding agents such as Claude Code can fix bugs, add features and upgrade dependencies on their own. They work best when they can actually run the code while they work: install packages, run the tests, and try again when something fails. On your laptop, that means letting a model run commands on your own machine. In a sandbox, the agent gets a machine of its own, and you decide what comes back out of it. The whole process is a simple loop:
  1. Start a sandbox and put your repository in it.
  2. Give the agent its task, together with an API key for its model, for that one command only.
  3. Check the agent’s work yourself: run the tests and read the changes.
  4. Ship the change by pushing a branch, or ask for more changes. Between rounds, the sandbox sleeps with everything in place.

The task

To keep the example small, the repository is a single Python file with a real bug: average([]) divides by zero, but a test says it should return 0. Follow the steps to have Claude Code fix it.
1

A sandbox with the repo

2

See the failure

3

Install the agent

Claude Code’s installer takes about a minute. You can install it in each sandbox, or install it once in a snapshot and start every task from that.
4

Give it the task

Now give the agent its task. The model’s API key goes in this command’s env only, so other commands in the sandbox never see it. --allowedTools lists what the agent may do without asking for permission. Since nobody is there to answer its questions, anything not on that list is simply refused. Here it may read and edit files, and run the tests.The output is streamed, so you can watch the agent work as it happens:
5

Check its work yourself

An agent can be wrong, even when it says it has finished. So run the tests and read the changes yourself before anything leaves the sandbox:
6

Ship it, or ask for more

If you are happy with the change, push a branch from the sandbox, using a token that can only push to that repository. Or read the diff out of the sandbox and apply it on your side.If the change needs more work, send your next instruction to the same sandbox, even hours later. It wakes up with the repository, the installed agent and the agent’s session exactly where they were, and --continue picks up the same conversation:

Clean up

Make it production-ready

These changes turn the example into something you can run for real:

Claude Code in a sandbox

Every Claude Code option, its sessions, and the API key, explained in detail.

Many agents in parallel

One task per sandbox, with many running at once.