osmates code
Open a coding agent in a Linux machine of its own, on a copy of a folder.
osmates code [<options>] [<folder>] [-- <arguments> ...]The first open of a folder makes a Debian machine named after it, with 4 CPUs, 4 GiB of memory and a 32 GiB disk. The folder goes in as a copy, never a share. The network reaches package registries, GitHub and AI model APIs, not this Mac or your local network.
Each open starts the machine, installs the harness if missing, takes a snapshot and opens the harness through osmates ssh. A credential whose variable is ANTHROPIC_API_KEY or OPENAI_API_KEY is granted for 24 hours, and the harness sees only its placeholder.
When the harness ends, osmates workspace diff <machine> takes its changes back as a git patch. The machine keeps running. With --json, nothing opens and the command prints the session. It exits with ssh's status.
Credentials, diffs and undo: https://osmates.com/docs/code
Examples
osmates code .
osmates code ~/src/app --agent codex
osmates code . --undoArguments
<folder>The folder the agent works on.
--agent <agent>The harness: claude (Claude Code) or codex (Codex CLI). Default: the last session's, else claude.
Without a credential, the harness keeps your API key or sign-in inside the machine, and the command says how to add one.
One of
claude,codex.--vm <machine>The machine to use or make. Default: the one holding the folder.
One that holds another folder's workspace is refused.
--undoReturn the machine to before its latest session instead of opening one.
What the session changed, in the workspace and outside it, is gone.
--jsonPrint machine-readable JSON.
<arguments>RepeatableArguments for the harness, after --.
JSON output
With --json, it prints an object with these fields.
JSON Schema: /schemas/0/cli/code.json
agentstringRequiredOne of
claude,codex.credentialobjectcredential.changedAtstring (date-time)Requiredcredential.createdAtstring (date-time)Requiredcredential.grantsarray of objectsRequiredcredential.idstring (uuid)Requiredcredential.namestringRequiredcredential.usesarray of objectsRequiredcredential.variablestringegressobjectRequiredegress.modestringRequiredOne of
open,allowlist,blocked.egress.rulesarray of stringsRequiredfolderstringRequiredguestPathstringRequiredmachinestringRequiredmadeMachinebooleanRequiredsharesarray of objectsRequiredshares[].eventsbooleanRequiredshares[].folderstring (uri)Requiredshares[].namestringRequiredshares[].readOnlybooleanRequiredsnapshotobjectRequiredsnapshot.createdAtstring (date-time)Requiredsnapshot.discstring (uri)snapshot.discControllerbooleansnapshot.firmwareobjectsnapshot.frameworkSoundobjectsnapshot.guestToolsbooleansnapshot.hardwareobjectRequiredsnapshot.hostBuildstringsnapshot.idstring (uuid)Requiredsnapshot.includesMemorybooleanRequiredsnapshot.isCrashConsistentbooleanRequiredsnapshot.isKeptbooleanRequiredsnapshot.namestringRequiredsnapshot.networkPathstringOne of
direct,detached,filtered.snapshot.originstring or objectRequiredOne of
manual, or an object that holds one key:agentSession,agent,beforeRevert,schedule,beforeUpdate,beforeDrivers,guest,beforeGuestRevert,codeSession,beforeMacOSUpdateorbeforeFirmwareUpdate.snapshot.partitionGrowthobjectsnapshot.rosettabooleansnapshot.windowsDriversobjectsnapshot.withoutNetworkbooleanRequiredterminalarray of stringsRequired
Fields nested deeper are in the schema.
With --undo
With --json and --undo, it prints an object with these fields.
JSON Schema: /schemas/0/cli/code.undo.json
notSavedBecausestringsavedBeforeobjectsavedBefore.createdAtstring (date-time)RequiredsavedBefore.discstring (uri)savedBefore.discControllerbooleansavedBefore.firmwareobjectsavedBefore.frameworkSoundobjectsavedBefore.guestToolsbooleansavedBefore.hardwareobjectRequiredsavedBefore.hostBuildstringsavedBefore.idstring (uuid)RequiredsavedBefore.includesMemorybooleanRequiredsavedBefore.isCrashConsistentbooleanRequiredsavedBefore.isKeptbooleanRequiredsavedBefore.namestringRequiredsavedBefore.networkPathstringOne of
direct,detached,filtered.savedBefore.originstring or objectRequiredOne of
manual, or an object that holds one key:agentSession,agent,beforeRevert,schedule,beforeUpdate,beforeDrivers,guest,beforeGuestRevert,codeSession,beforeMacOSUpdateorbeforeFirmwareUpdate.savedBefore.partitionGrowthobjectsavedBefore.rosettabooleansavedBefore.windowsDriversobjectsavedBefore.withoutNetworkbooleanRequiredstatusobjectRequiredstatus.canSuspendbooleanRequiredstatus.controlobjectstatus.detailstringstatus.displayobjectstatus.failureobjectstatus.idstring (uuid)Requiredstatus.namestringRequiredstatus.pauseReasonstring or objectOne of
person,hostAsleep, or an object that holds one key:volumeFull,volumeLowortpmStateUnsaved.status.shutdownWaitobjectstatus.startWaitobjectstatus.statestringRequiredOne of
starting,running,paused,stopping,stopped,failed,suspended,offline.status.suspensionobjectstatus.updatedAtstring (date-time)Requiredstatus.workerBuildstringstatus.workerProcessIdentifierinteger
Fields nested deeper are in the schema.
Exit statuses
Its exit status is one of these.
| Status | Meaning |
|---|---|
| 0 | The command did what it was asked. |
| 1 | The command failed; with --json, standard error's last line is the error object. |
| 64 | The command line is wrong, as ArgumentParser found before the command ran. |
| 65 | What was given is wrong, found while the command ran; the same command fails until it changes. |
| 75 | The same command can work later with nothing changed, as while an update finishes. |
| 130 | Control-C cancelled what the command started. |
| 0 to 255 | ssh's own status: the remote command's, or 255 when ssh failed. |