Skip to content

Run a whole agent with openmoat run

Terminal window
openmoat run --write ~/.claude --write ~/.claude.json -- claude
openmoat run --isolate --write ~/.claude --write ~/.claude.json -- claude # Linux: refuse without bubblewrap

The two --write paths are Claude Code’s own state, which it must write to run. Start openmoat run in a project, never in your home directory. Inside it:

  • Network goes only through the run’s proxy, on a loopback port, with a credential made for the run; a request without it gets 407. On Linux, where bubblewrap can run, the agent gets a network namespace of its own with only loopback.
  • The agent’s hooks still decide each call. They run inside the sandbox and send each call to the openmoat run process outside it, which decides and records it.
  • npm and uv install no version published in the last 7 days (npm_config_before, UV_EXCLUDE_NEWER).
  • Brokered secrets’ variables are removed before the agent starts. A secret with tls: terminate is put into HTTPS here and nowhere else, only for the requests its allow rules name (Secrets over HTTPS); openmoat run refuses to start when no pinned CA covers such a secret’s host.
  • Nothing types into your terminal: TIOCSTI is denied.
  • No open files are handed in (from 0.21.0). Files, sockets and directories the program that started openmoat run left open do not reach the agent: every descriptor from 3 up is marked close-on-exec before the sandboxed program starts, so the agent gets only standard input, output and error, and the run refuses to start where that cannot be done. So bash -c 'exec 3<~/.ssh/id_rsa; openmoat run -- sh -c "cat <&3"' fails with Bad file descriptor. Process substitution is a descriptor too: openmoat run -- tool <(cmd) no longer works; write the output to a file in the project first, or pipe it on standard input (cmd | openmoat run -- tool -).
  • Agent configuration in the project is read-only (from 0.21.0): commands cannot write .claude/commands, .gemini/commands, .github/agents, .cline/hooks/, OpenCode’s commands, agents and skills, and the like. A git pull, git checkout or package install that changes them fails partway: run those outside openmoat run (Project files on Linux).
  • No hard links to protected files (macOS, from 0.15.0): the Seatbelt profile also denies hard links to every path it denies reading or writing, so a sandboxed command cannot link ~/.moat/proxy.key or audit.db into the project.
  • Turn the agent’s own sandbox off: sandboxes do not nest. Claude Code’s sandbox.enabled fails inside, and Codex needs --sandbox danger-full-access. Credentials must not come from the keychain: use an API key or apiKeyHelper.

Before the agent starts, openmoat run prints how many places the sandbox is stricter or wider than the policy; --verbose lists each one. It needs macOS 13 or later, or Linux; on native Windows it starts a preview tier that holds writes only.

Since 0.26.0:

  • Protection score: the run’s boundary record carries a 0 to 100 score, and sandbox.strict: true refuses a run below 100 (Protection score and strict mode).
  • Qwen Code and Crush: openmoat run --write ~/.qwen -- qwen and openmoat run --write ~/.local/share/crush --write ~/.cache/crush -- crush (Linux adds --isolate).
  • Windows: a preview tier that refuses writes outside the project and ends every process with the run; reads and the network are not held (openmoat run on Windows).

The boundary record. Every run records the sandbox it really started with (rule run-boundary), and openmoat run --print-boundary -- <agent> prints it without starting anything. On Linux the run checks the agent’s /proc status right after it starts and stops it when a part is missing (The boundary record).

Snapshots. Before the agent starts and after it exits, openmoat run takes a snapshot of the project’s files into OpenMoat’s own store; openmoat restore puts them back (Undo an agent’s changes). --no-snapshot takes none, on record.

Environment. Every inherited variable reaches the agent except brokered secrets; one line says how many look like credentials. Under require.run: full-boundary only an allowlist does; add a name with --env NAME or sandbox.env_allow. Since 0.25.0, sandbox.env: scrubbed and --scrub-env turn the allowlist on by themselves (Scrubbed environment), and openmoat init can make typing a hook-only agent’s name start it in openmoat run (Start agents sandboxed).

More on auto-approve: Auto-approve and CI.