Claude Code and Codex in the cloud
Updated 27 October 2026
To run Claude Code or Codex in the cloud, send its command to an Ortam Sandbox. A Sandbox is a Linux VM with both CLIs preinstalled. Its disk is saved, so the next run starts with the repository, the dependencies and the agent’s session files in place. Each session gets its own Sandbox and keeps running when you disconnect. It uses your Claude or ChatGPT plan without the login on the machine.
What does a cloud session need?
- A machine that runs the whole project, with sudo and systemd. The agent can install what it needs, Docker included, and run the tests. A Sandbox is a VM with Ubuntu 24.04 and Node.js, Python, git, Claude Code and Codex CLI preinstalled. Install other agents or versions with sudo, and the next save keeps them.
- The repository, ready. Set a Sandbox up once and take a Snapshot, a saved copy of its files that never changes. Every session starts from it with the checkout and dependencies in place.
- The provider login outside the VM. A long-lived login on the machine is a file that every save and Snapshot would copy. Connections keep the login outside the VM. They deliver credentials into storage that is never saved, though a program can still copy or print what it’s given.
- A way to leave and come back. A session that runs for an hour shouldn’t depend on your laptop, your terminal or the service that started it staying connected.
How do you start a session?
Start by following Keep environments warm. This walkthrough uses three things from it: the ortam.sh helpers, which wait for each step and retry without acting twice; a Snapshot of the set-up repository; and git_env, which gives git a token without writing it to the disk. You also need the ID of a Claude Code Connection.
Create a Sandbox for the session from the repository’s Snapshot, with the Connection as its default. The trap tries to stop the Sandbox when the script exits, including when the agent fails. Stopping keeps its files and ends its compute cost. stop_sandbox fails if the stop or its final save doesn’t complete, so check how the script ended:
source ortam.sh
body=$(jq -n --arg s "$SNAPSHOT_ID" --arg c "$CONNECTION_ID" --arg n "claude-$TASK_ID" \
'{name: $n, snapshot_id: $s, settings: {connection_id: $c}}')
session=$(ortam_api POST /v1/sandboxes "$body" | jq -er .resource.id)
trap 'stop_sandbox "$session"' EXITA new Sandbox gets no credentials, so grant it the Connection now, before the agent starts. The route for grants is to be published. Until it is, this walkthrough can’t show that step or run end to end against the service.
Check out the task’s commit on a branch of its own. Run Claude Code in print mode, claude -p, which works through the task without a terminal and exits. In print mode nobody can approve a tool, so the command says what Claude Code may do: edit files and run shell commands, such as the tests. The Sandbox belongs to this task alone. To allow less, narrow --allowedTools to commands such as Bash(npm test *). Passing the task in the environment keeps its quotes intact. Then commit what the agent changed under the name and email in GIT_NAME and GIT_EMAIL, and push the branch:
task_env=$(jq --arg c "$TASK_COMMIT" --arg i "$TASK_ID" --arg t "$TASK" \
--arg n "$GIT_NAME" --arg e "$GIT_EMAIL" \
'. + {TASK_COMMIT: $c, TASK_ID: $i, TASK: $t, GIT_NAME: $n, GIT_EMAIL: $e}' <<<"$git_env")
run "$session" 'cd app && git fetch origin "$TASK_COMMIT" &&
git checkout -B "claude/$TASK_ID" "$TASK_COMMIT"' "$task_env"
run "$session" 'cd app && claude -p "$TASK" \
--permission-mode acceptEdits --allowedTools Bash' "$task_env"
run "$session" 'cd app && git add -A &&
git -c user.name="$GIT_NAME" -c user.email="$GIT_EMAIL" commit -m "$TASK"' "$task_env"
run "$session" 'cd app && git push origin "HEAD:refs/heads/claude/$TASK_ID"' "$task_env"Each run waits for its command and fails the script unless the command exits with code 0. A session that fails, or changes nothing, never pushes.
A command doesn’t depend on the script that sent it. ortam_api retries through a short outage. If the script gives up, its trap tries to stop the Sandbox, which ends the command.
Ortam keeps a command’s output with stable positions, so a program reading it can reconnect and continue where it stopped, but the API route for reading it is to be published. Until then, read the output in a terminal on the Sandbox, through a private link that names the Sandbox and expires.
For Codex, grant a Codex Connection and run codex exec --sandbox workspace-write "$TASK" instead. Without that flag, codex exec can’t edit files. Even with it, Codex keeps .git read-only, so the script commits instead of the agent.
Can you use a Claude or ChatGPT plan instead of an API key?
Yes. A Connection is a Claude or ChatGPT account, by subscription or API key, for one client: a Claude account for Claude Code, a ChatGPT account for Codex. For a subscription, the account holder signs in once through the provider’s own sign-in. Ortam keeps the login encrypted outside every Sandbox and renews it as it expires. Each Sandbox you grant gets short-lived credentials in storage that is never saved. An API-key account’s key is delivered the same way.
When the provider ends the session, the Connection’s status says that the holder must sign in again. Until they do, commands that need the Connection fail before they start.
How do you run several sessions at once?
Start a Sandbox per session from the same Snapshot. Each one writes to its own disk, so sessions don’t share a working tree. You can run the same task several ways and keep the best result. How many run at once depends on your plan’s limits, which are to be published.
Does a session keep its context between runs?
Yes, through its files. Claude Code writes its sessions to files, and Ortam saves the whole disk. A later run in the same Sandbox finds them as of the last completed save. Memory and running processes don’t survive a stop.
To give the agent a follow-up, run Claude Code again in the same Sandbox with --continue, which picks up its most recent session there. For Codex, run codex exec resume --last. The Sandbox starts from its saved disk, and the trap tries to stop it again. Commit and push as above:
source ortam.sh
trap 'stop_sandbox "$SESSION_ID"' EXIT
follow_up_env=$(jq -n --arg f "$FOLLOW_UP" '{FOLLOW_UP: $f}')
run "$SESSION_ID" 'cd app && claude -p --continue "$FOLLOW_UP" \
--permission-mode acceptEdits --allowedTools Bash' "$follow_up_env"Common questions
What does a session cost?
Ortam bills a running Sandbox by the second at its size’s hourly price, never more than the size’s monthly cap. A stopped Sandbox pays only for its saved disk. Ortam doesn’t host models. The agent calls its provider with the account its Connection names. Prices are planned for launch. Pricing and limits has the sizes.
Can the agent push to GitHub?
Yes. Your script gives each git command a credential through its environment instead of a file, so the credential isn’t saved with the disk. Keep environments warm shows how.