Request an invite
Docs menu

Code with an agent in its own machine

Open your project in Claude Code or Codex CLI inside a Linux machine that sees only a copy of it.

Open a project

sh
cd ~/Projects/shop
osmates code .

The first time, osmates code makes shop-code from the template for agents, with 4 CPUs, 4 GiB of memory, and a 32 GiB disk. It copies your folder in, installs Claude Code, takes a snapshot, and opens Claude Code in the copy. That takes a few minutes, and later opens take seconds.

The machine keeps running after you quit Claude Code. Stop it with osmates vm stop shop-code, or open a shell with osmates ssh shop-code.

Your folder goes in as a workspace, a copy in the account's home. The machine can't reach the rest of your Mac, and the clipboard isn't shared. Later edits on your Mac don't reach the copy.

The machine reaches the same hosts as an agent sandbox, plus platform.claude.com for Claude Code. To allow another host:

sh
osmates vm egress shop-code --allow registry.example.com

Keep your API key on your Mac

Requires OSMates Pro.

Add your API key once as a credential, which OSMates keeps in your Keychain. For Claude Code:

sh
osmates credential add anthropic --host api.anthropic.com --header x-api-key --variable ANTHROPIC_API_KEY

For Codex CLI:

sh
osmates credential add openai --host api.openai.com --header Authorization --prefix "Bearer " --variable OPENAI_API_KEY

Each osmates code then grants the key for 24 hours and allows the API's host. The agent gets a placeholder, never the key. When Claude Code asks to use the key it found, say yes.

While the grant lasts, anything in the machine can use the key, but only with that API. A grant you made for another time, such as --until-stop, stays. Remove any key you put in ~/.profile.

To end the grant early, run osmates credential revoke anthropic shop-code. The next open grants it again, unless you run osmates credential remove anthropic.

Sign in without a credential

Without a credential, the agent keeps its key or sign-in inside the machine, where anything running can read it. To add an API key there:

sh
osmates ssh shop-code
echo 'export ANTHROPIC_API_KEY=<key>' >> ~/.profile

Codex CLI reads OPENAI_API_KEY instead.

For a Claude or ChatGPT subscription, first run the osmates vm egress command that osmates code prints. For Codex CLI, turn on device code sign-in in ChatGPT's security settings. Then run codex login --device-auth in the machine.

Take the changes back

sh
osmates workspace diff shop-code
git apply shop-code-*.patch

workspace diff writes a patch of every change since the first open, and a report. Read the report before you apply the patch. It lists changes that could run code on your Mac, such as Git hooks, CLAUDE.md, CI files, and build scripts.

Undo a session

Each open takes a snapshot named for the agent, such as "Before Claude Code, 2026-11-10 09:14". To go back to the start of the latest session:

sh
osmates code --undo .

This removes everything the session changed in the machine, packages and a sign-in included. Files on your Mac and granted credentials stay. A running machine restarts from the snapshot, and the state before the undo is saved as a snapshot too.

A machine keeps 5 session snapshots by default, or what its Keep setting says.

Choose the agent or the machine

sh
osmates code . --agent codex
osmates code . --vm agents

--agent takes claude or codex, and installs a new choice from its npm package. Without it, osmates code opens the last session's agent.

--vm uses another Linux machine from your library, or makes one with that name. A machine that holds another folder's workspace, a template, or a temporary machine is refused. A machine you name keeps its own network access and shared folders.

Options after -- go to the agent, such as osmates code . -- --resume.

Report a problem with this page