# Run Claude Code in the cloud

Run Claude Code inside an isolated KVM Ubuntu 24.04 VM so autonomous runs with `--dangerously-skip-permissions`, package installs, and Docker builds stay off your laptop.

## 1. Create a VM and open a shell

Create a `default` machine (4 vCPUs, 8 GB RAM, 51 GB disk) with a 2-hour idle timeout, then open a shell on it.

```console
$ arvm new --idle-timeout 2h
$ arvm ssh calm-river-otter
```

The examples below use `calm-river-otter`. Replace it with the name `arvm new` prints. The login user is `dev` with passwordless `sudo`, and Node.js LTS, Git, Docker, Python, and `tmux` are preinstalled on the `ubuntu-24.04` image.

## 2. Install Claude Code

Inside the VM, install Claude Code globally and verify the binary:

```console
dev@calm-river-otter:~$ npm install -g @anthropic-ai/claude-code
dev@calm-river-otter:~$ claude --version
```

The installed CLI and your repositories stay on the VM's 51 GB disk across stops and starts.

## 3. Run Claude Code in an isolated session

Clone your repository, start a `tmux` session (or attach through [Rex](rex.md)) so a dropped SSH connection does not interrupt the run, and launch Claude Code.

```console
dev@calm-river-otter:~$ git clone https://github.com/example/app.git
dev@calm-river-otter:~$ cd app
dev@calm-river-otter:~$ tmux new -s claude
dev@calm-river-otter:~$ claude --dangerously-skip-permissions
```

Because each machine boots its own Linux kernel on KVM, Claude Code can run Docker containers, `systemd` services, database migrations, and `sudo apt install` without touching your workstation.

For a one-shot non-interactive task over the API without SSH, pass `-p` through `arvm exec`:

```console
$ arvm exec calm-river-otter --cwd /home/dev/app --timeout 30m -- claude -p "Run the test suite and fix failing unit tests" --dangerously-skip-permissions
```

## 4. Stop or delete the VM

Push your branch to Git before ending the session. Stop the machine to keep its disk at $0 an hour, or delete it when the task is disposable:

```console
$ arvm stop calm-river-otter
$ arvm rm calm-river-otter --yes
```

Omit `arvm rm` if you plan to resume the same workspace later with `arvm ssh calm-river-otter`.

## Idle stop and billing

A `default` VM uses $0.018 an hour from your $20 monthly plan, $13.14 for a full month. For large monorepo builds or Rust compiles, pass `--size large` (8 vCPUs, 16 GB RAM, 111 GB disk, $0.036 an hour, $26.28 for a full month). Stopped machines cost $0.

Active SSH sessions, `arvm exec` calls, and sustained CPU work keep the machine awake. If you leave an interactive terminal idle after disconnecting, the machine stops after its idle timeout and preserves its disk. Turn idle stop off with `--idle-timeout never` before starting a long unattended task, and see [Idle stop](../machines.md#idle-stop).

Machine disks live on one drive with no automatic backups. Push commits to Git regularly.

## Troubleshooting

| Symptom | What to do |
|---|---|
| `arvm exec` exits after 30 seconds while Claude is still running | Pass `--timeout 30m` (up to `1h`). For runs longer than an hour, launch with `sudo systemd-run` as shown in [Run a job that outlives the request](../exec-and-files.md#run-a-job-that-outlives-the-request). |
| `claude` asks to sign in again after you recreate a VM | A deleted VM removes `~/.claude`. Stop the VM instead of deleting it to keep credentials and caches on disk, or pass `ANTHROPIC_API_KEY` at creation time. |
| Docker builds fail with permission errors | User `dev` is in the `docker` group on the `ubuntu-24.04` image. Run `docker info` to verify the daemon is active. |
| Out-of-memory kills during large builds | Stop the VM, resize to `large` (16 GB RAM) with `arvm resize calm-river-otter large`, and start it again. |

## Related guides

- [Use Rex with a cloud Linux VM](rex.md)
- [Run Codex CLI in the cloud](run-codex-in-the-cloud.md)
- [Run parallel coding agents across isolated VMs](parallel-agents.md)
- [Run commands and move files](../exec-and-files.md)
