> ## Documentation Index
> Fetch the complete documentation index at: https://psychiatrist.sudo.la/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandboxes

> Every agent’s whole process, and the MCP servers it starts, inside the operating system’s own sandbox.

> [!NOTE]
>
> Planned: #14 builds it for Claude Code, #15, #16 and #17 for Codex, opencode and pi. The shape below is settled ([ADR 0004](https://github.com/psychiatrist/psychiatrist/blob/main/docs/adr/0004-native-sandbox-whole-agent-by-default.md), [ADR 0009](https://github.com/psychiatrist/psychiatrist/blob/main/docs/adr/0009-agents-and-sandboxes-as-provider-values.md)); it is not in the package yet.

A sandbox is a provider value, like an agent. With none given, a session runs in the native sandbox for this OS: Seatbelt on macOS, Bubblewrap on Linux.

```ts theme={null}
import { claudeCode, seatbelt, start } from "@psychiatrist/core";

await start({
  agent: claudeCode("claude-opus-5-5", { env: { CLAUDE_CODE_OAUTH_TOKEN: token } }),
  sandbox: seatbelt(),
});
```

| Provider | Runs the agent in |
| - | - |
| `seatbelt()` | macOS's Seatbelt |
| `bwrap()` | Bubblewrap, on Linux |
| `noSandbox()` | nothing: on your machine as it is |

## What a sandboxed agent can reach

The whole agent process runs inside, with the MCP servers it starts; each harness's own sandbox is off, since sandboxes don't nest reliably.

* **Writes:** its worktree, the main checkout's git directory (its hooks and config read-only, so a script cannot plant a hook the bot later runs outside), a private temp, and a private home for the session.
* **Reads:** the toolchain on your `PATH`.
* **Network:** full.
* **Never:** your home directory, other repos, or a GitHub token. The guard still checks every tool call.

## Logins

The private home holds no login of yours. Give the agent its own through the provider's `env` (an OAuth token from `claude setup-token`, say); the bot uses the login `psychiatrist init` stored. A sandbox's own `env` must not share a key with the provider's.

## Sessions

A session's record lives in its private home while it runs. After every turn the provider copies it to your own harness folder, so the harness's own resume works from your terminal (`claude --resume <id>`, `codex resume <id>`); `captureSessions: false` turns that off. A resume or fork moves the record back in, after checking it exists.

## Per harness

| Harness | How it runs inside |
| - | - |
| Claude Code | through its spawn hook Planned · #14 |
| Codex | app-server through a wrapper script, its own sandbox set to external; a private Codex home with a copy of its auth file Planned · #15 |
| opencode | its server started inside, with private config and data folders Planned · #16 |
| pi | as an RPC subprocess, the guard loaded as a pi extension inside Planned · #17 |

Windows, and Linux without Bubblewrap, run unsandboxed with a warning.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.