# CLI reference https://fenzi.dev/docs/cli Every `fenzi` command, its flags, and its exit codes. You only type `fenzi`. For an auditor, each command lists what it calls upstream in a collapsed block. Exit codes at the end · Team-only commands are marked · `--json` for scripts ## Commands | Command | Does | | --- | --- | | `fenzi` | With no command, a menu for the current folder. | | `setup` | Guided setup: checks the machine, picks the agent, stores its key, and offers to start it. | | `doctor` | Checks the machine and the gateway, and names the pinned OpenShell version when it is missing. | | `init` | Writes a starter `fenzi.yaml`. | | `key` | Stores, replaces, or removes an agent's model key on this machine. | | `run` | Starts an agent in a new sandbox. `--headless` runs it unattended, for CI. | | `ps`, `connect`, `stop` | Lists sandboxes, resumes the agent or opens a shell in a running one, and ends them. | | `rm` | Forgets finished sandboxes: the record, the staged changes, and the saved log. | | `requests`, `approve`, `deny` | Lists and decides requests for more access. | | `log` | Shows allow and deny decisions. | | `diff`, `apply` | Reviews the agent's changes and merges its commits into your branch. | | `policy compile`, `policy check`, `policy apply` | Shows the compiled policy, runs the prover, and loads a host change onto sandboxes running from this folder. | | `agents` | Lists agents and builds their images. | | `tools` | Names the folder's languages and where their commands come from in the sandbox. | | `policy host`, `policy path` | Adds, changes, or removes a host or a path in `./fenzi.yaml`, without editing YAML. | | `update`, `version` | Installs the latest release of the CLI, and prints the one you have. | | `uninstall` | Removes Fenzi and what it left on this machine, the optional parts on request. | | `login`, `logout`, `status` | Team. Signs this machine in to a team, signs it out, and shows the sign-in. | | `policy publish` | Team, admins. Publishes a complete org policy to the console. | | `sync` | Team. One pass: fetches the newest revision, loads a host change onto running sandboxes, and sends waiting decisions. | | `forward` | Team. Sends decisions and requests to the console and applies its reviews, every five seconds until stopped, or as a service with `--install`. | ## Set up ### `fenzi` With no command, in a terminal, it shows the current folder, the agent from setup, how many sandboxes are running, and whether changes are waiting to be applied. Then it offers the next steps: start the agent, review the changes, connect to a running sandbox, answer requests, check the machine, run setup again, or list every command. Before setup has finished once, it starts setup instead. Without a terminal it prints the list of commands. ### `fenzi setup` Asks questions in five steps: this machine, agent, model key, project folder, and agent image. Then it shows the policy the agent starts with in that folder, resolved as `run` resolves it, and names where it comes from: `developer-default` with the folder's `fenzi.yaml` over it, or the team's signed revision on a signed-in machine. Then it offers to run it. The installer starts it when a person is at the terminal, and so does `fenzi` with no command until setup has finished once. Answers are saved in `~/.config/fenzi/setup.json`. Every change asks first. If OpenShell is missing, it offers to install release 0.1.8 with the upstream installer and shows the command before it runs it. If an older 0.1 release is installed, it offers the upgrade once no sandbox is left: a sandbox made by the older release does not start after the upgrade, so setup names the ones in the way and asks you to end each with `fenzi stop` first, which brings its changes back. On a Mac with Homebrew, it offers to start a stopped gateway as a Homebrew service. It turns off automatic approval and the gateway-wide settings `doctor --fix` removes, only if you say yes. It runs the same DNS check as `doctor`. On colima, when the TTL is too short, it offers to set `dns` in colima's config and restart colima, which stops running sandboxes. It stores the key as `key set` does and builds the image as `agents build` does. The build log is written to `~/.cache/fenzi/builds/`. Use the arrow keys or `j` and `k`, then Enter. Esc or the left arrow goes back to the previous question, as far as the agent step. Ctrl-C stops setup with exit code 130. Without a terminal, questions are numbered and read one line at a time; type `b` or `<` to go back from a choice, and `<` from a typed answer. ### `fenzi setup --runtime` For a machine nobody sits at, such as a CI runner. Asks nothing. Installs OpenShell at the release this `fenzi` is built for when no OpenShell is installed, with the same checked upstream installer as `setup`, checks that the installed release is inside the pinned range, and waits up to a minute for the gateway. Exits `3` when any of that fails. It does not pick an agent or store a key. On a Mac that needs Homebrew first it refuses, because that installer asks for a password. See [CI with Fenzi](https://fenzi.dev/docs/ci). ### `fenzi doctor [--fix] [--json]` Checks the runtime version against the pinned range, the gateway connection, the sandbox driver, the image builder, the approval mode, the sandbox settings Fenzi turns on, and the bad-revision setting. It also looks up a host from the policy inside a running sandbox, as the agent would, and fails when the answer's TTL is 1 second or less. With no sandbox running it asks colima's resolver on colima, and skips the check on other runtimes. See [Short DNS TTLs](https://fenzi.dev/docs/troubleshooting#dns). If the runtime is missing, it names the pinned version, skips the gateway checks, and still checks the prover, the image builder and the plan. `fenzi setup` installs the runtime. Fails if the gateway approves requests automatically for every sandbox, or if it turns off the audit log or agent requests for every sandbox. Those gateway-wide values override what `run` sets. `--fix` removes them. It changes nothing else, and says what it will change first. It does not configure colima; see [colima on a Mac](https://fenzi.dev/docs/troubleshooting#colima). **What it calls upstream** `openshell status`, `openshell gateway info`, `openshell settings get --global`. With `--fix`: `openshell settings delete --global`. For the DNS check: `openshell sandbox list`, `openshell sandbox get --policy-only` and one query with `openshell sandbox exec --no-login-shell -- python3`. On colima with no sandbox running: `colima ssh -- python3` instead. ### `fenzi init` Writes `fenzi.yaml` in the current folder, with example hosts commented out. It does not read the project. Nothing is allowed until you uncomment a host. ### `fenzi key list [--json] | set | remove ` `list` shows which agents have a key stored on this machine. It never prints a key. `set` asks for the key without showing it, or reads one line from a pipe, and stores it in the gateway's provider store; run it again to replace a key. New sandboxes use the new key. `remove` deletes the stored key. It refuses while a sandbox that was started for that agent is still running, and names it: `fenzi-web-4f2a is running with the Claude Code key; stop it first (fenzi stop fenzi-web-4f2a)`. A sandbox running another agent does not block it. See [Model keys](https://fenzi.dev/docs/keys). **What it calls upstream** `openshell provider get`, `openshell provider create --from-existing` or `openshell provider update --from-existing`, with the key passed in the environment of that one command, never as an argument. `remove` calls `openshell provider delete`. ## Run an agent ### `fenzi run [flags] [agent] [agent args]` Without an agent name, it runs the agent chosen in setup, or Claude Code if setup has not run. `fenzi run codex` picks another one. Everything after the agent's name goes to the agent: `fenzi run claude --resume`. Fenzi's own flags go before the agent: `fenzi run --no-upload claude`. If one of them comes after the name, `fenzi run` stops before it makes a sandbox and says where to put it. To pass arguments to the agent from setup without naming it, put `--` first: `fenzi run -- --resume`. This page is the only one that uses that form. On a machine signed in to a team, it also forwards while the agent runs; see [Forwarding decisions](https://fenzi.dev/docs/forwarder#run). If the console could not be reached during the session, it says so after the agent exits; `fenzi forward` sends what was queued. It refuses to start in your home folder, at `/`, or in a folder that holds your home folder, before it asks the gateway anything. `cd` into one project folder first. Compiles and checks the policy, builds the agent's image if needed, with the commands the folder's languages call for (see `tools`), creates the sandbox, copies the project in, and starts the agent in your terminal. When the agent exits, it saves the log and stages the changes. In a terminal it then shows the changes and asks what to do with them. The sandbox keeps running, with the agent's session, its files and the run's approvals: `fenzi connect` resumes the agent where it stopped, and `fenzi stop` ends it. `--rm` deletes it instead, after the changes are staged; deleting does not touch staged or applied changes. When a sandbox started from the same folder for the same agent is still running, `run` asks first whether to resume it or start a new sandbox. Resuming opens the agent's last session there, with the files as it left them; your folder is not copied again. `--new` skips the question and starts a new sandbox. Without a terminal it starts a new one. Claude Code starts with `--permission-mode bypassPermissions`: Claude does not ask before commands or refuse them itself, so every command reaches the sandbox, and the policy decides what it can reach. In a new sandbox Claude warns about the mode once; choose **Yes, I accept**. Pass your own mode after the agent's name to use another: `fenzi run claude --permission-mode manual` asks you before each command. | Flag | Meaning | | --- | --- | | `--rm` | Delete the sandbox when the agent exits, after its changes are staged. Without it the sandbox is kept. | | `--new` | Start a new sandbox even when one for this folder and agent is still running. | | `--keep` | Keep the sandbox when the agent exits. The default now; kept for scripts that pass it. | | `--name ` | Sandbox name, at most 19 characters. Default `fenzi--`, with the folder shortened to fit. | | `--policy ` | Use this policy file instead of `./fenzi.yaml`. Free only. | | `--no-upload` | Start with an empty working folder. | | `--allow-secrets` | Copy files that look like secrets without asking. The warning is still printed. | | `--sign-in` | Start without the stored key, so the agent signs in itself. Claude Code only: it asks you to sign in with your Claude subscription. The key stays stored for other runs. | | `--headless` | Run unattended: the agent's own non-interactive mode on one task, no questions, a time limit, and a summary at the end. Needs a key, stored or exported. The sandbox is deleted at the end unless `--keep`, and nothing is applied to your folder. See [CI with Fenzi](https://fenzi.dev/docs/ci). | | `--task `, `--task-text ""` | With `--headless`, the task: a file, `-` for standard input, or the text itself. At most 32 KiB. | | `--timeout ` | With `--headless`, the time limit for the whole run, such as `30m`, the default. `0` for none. | | `--request-timeout ` | With `--headless`, how long a request the agent files waits for a reviewer before Fenzi refuses it. Default: until the time limit. Nothing is approved without a person. | | `--out ` | With `--headless`, write `summary.json`, `summary.md`, and the agent's commits as `branch.bundle` there. | Before it builds or creates anything, `run` names the files in the copy that look like secrets: `.env` and `.env.*` (not `.example`, `.sample`, or `.template`), `*.pem`, `*.key`, `*.p12`, `*.pfx`, SSH keys named `id_rsa`, `id_ed25519`, or `id_ecdsa`, `.npmrc`, `.pypirc`, `.netrc`, `credentials*.json`, `service-account*.json`, and `*.tfvars`. It reads names only. They are copied because `.gitignore` does not exclude them. In a terminal it asks whether to copy them, and stops with nothing created unless you say yes. Without a terminal it prints the warning and continues. **What it calls upstream** In order: `openshell gateway info`, to build the image with the engine the gateway's driver uses, `openshell settings get --global`, `openshell-prover check`, `openshell profile import` and `openshell provider create` on first use, `openshell sandbox create --detach --policy --provider --approval-mode manual --no-auto-providers`, `openshell sandbox get --policy-only` and the prover again, `openshell settings set` to turn on the JSON audit log, `openshell sandbox upload`, `openshell sandbox exec` to check the languages' commands when the folder has any, `openshell sandbox exec --tty`. On exit: `openshell logs` until the log stops growing, `openshell sandbox download`, and `openshell sandbox delete` when the sandbox is not kept. The project is copied to `/sandbox/` and the agent starts there. `.git` is not copied. The settings change reaches the sandbox on its next poll, and loading it closes open connections, so `run` waits for it before starting the agent. Settings the gateway already turns on for every sandbox are skipped. If the gateway turns one off for every sandbox, `run` stops before creating anything and points to `doctor --fix`. For agents that support it, `run` adds a short guide to the agent's instructions: how to look up a refused connection and how to request access through the sandbox's policy API. Claude Code gets it through `--append-system-prompt`, Codex through a setting on its command line, OpenCode as a file written inside the sandbox, outside the project, and Grok through `--rules`. Your project is not changed. See [Agents](https://fenzi.dev/docs/agents). Exits with the agent's exit code once the agent has started. With `--headless` it exits with the run's own status instead; see Exit codes. ## Sandboxes ### `fenzi ps [--all] [--json]` Lists the sandboxes Fenzi started that are still running, and the ones that stopped because their container stopped, as when Docker or colima restarts. `--all` adds finished ones, whose logs and staged changes you can still read. In `--json`, a stopped one has `"running": false` and `"lost": true`. **What it calls upstream** `openshell sandbox list --selector fenzi=1`, which prints each sandbox's phase. ### `fenzi connect [name] [--new] [--shell] [-- agent args]` Opens the sandbox's agent again in your terminal, in the project folder inside the sandbox, with the same policy and the files as the agent left them. The agent continues its last session there, so it keeps the conversation: Claude Code, OpenCode and Grok with `--continue`, Codex with `codex resume --last`. When there is no session to resume, the agent fails at once, and a new session starts with a line that says so. `--new` starts a new session. `--shell` opens a shell instead. Use it after the agent exits, from a second terminal while the agent works, or when the terminal that ran the agent was closed and the sandbox is still running. Default: the latest running sandbox for the current folder; if several are running elsewhere, it asks which. Exiting leaves the sandbox running. `fenzi stop` ends it and brings the changes back. Arguments for the agent go after `--` here, as in `fenzi connect -- --resume`. **What it calls upstream** `openshell sandbox exec --tty`, as `run` does. ### `fenzi stop [name] [--yes]` Ends a sandbox: saves the log, copies the project out to staging, then deletes the sandbox. If the copy fails, the sandbox is kept. A stopped sandbox is started again first, so its changes can come back. When the sandbox runtime cannot start it, which is the case after the container runtime restarted, its files cannot be copied out: `stop` says so and deletes it only if you agree, after saving the log. Default: the latest running sandbox for the current folder; if several are running elsewhere, it asks which. Asks first unless you pass `--yes`. ### `fenzi rm [...] | --finished [--json]` Forgets finished sandboxes. A finished sandbox is already gone from the gateway; what stays on this machine is its record in `ps --all`, the changes staged when it ended, and the log saved then. `rm` removes those three, in that order, and says which it found. Staged changes that were not applied are lost with it; `fenzi diff --sandbox ` shows them first. `--finished` removes every finished sandbox. A running sandbox is refused: `fenzi-web-4f2a is running; fenzi stop fenzi-web-4f2a ends it first`. A stopped one, whose container stopped, is deleted from the sandbox runtime too, with the files in it; `--finished` includes those. The others named are still removed, and the command exits `1`. A name that is not a sandbox on this machine is an error, and nothing is removed. **What it calls upstream** `openshell sandbox list --names --selector fenzi=1`, to tell running from finished; nothing else. ## Requests ### `fenzi branch [--new [--from ]] [] [--json]` The folder's branch, before a sandbox starts: the sandbox works from whatever the folder has checked out, and `fenzi apply` lands the agent's commits on that branch. Alone, it prints the checked-out branch and the other local ones. With a name, it switches the folder to that branch; with `--new`, it creates the branch first, from `--from` (a branch or a commit) or from the checked-out commit. Uncommitted edits come along, as `git switch` carries them; when they would be overwritten, git refuses and nothing changes. `fenzi run --branch [--from ]` does the same right before the start. The Mac app's New Sandbox sheet offers it under the folder. **What it calls upstream** Nothing in OpenShell: git on this machine, with hooks and the file monitor off, as the rest of the git round trip. ### `fenzi requests [--all] [--sandbox ] [--json]` Lists the pending requests the agent filed in your running sandbox, with the first eight characters of each id, the program, and the agent's reason. Connections the sandbox blocked that the agent did not ask about are counted under the list, with their hosts; `--all` lists them too, under their own heading. A request counts as the agent's when the sandbox log marks it as filed by the agent, when its reason is not the generated one, or when it took the place of a request the agent filed for the same rule. In a terminal it then asks about each one: approve and save, approve once, deny with a reason, or decide later. Approve and save is chosen first; it does what `approve --save` does. On a signed-in machine there is no save, since the team's policy comes from the console, and the first answer is approve. Without a terminal it prints the commands instead, `approve --save` first on the Free plan. If several sandboxes are running and none is in the current folder, it asks which. If the runtime's text format changes, Fenzi shows the raw text instead of a list. **What it calls upstream** `openshell rule get --status pending` and `openshell logs`. OpenShell prints the pending list as text, not JSON. ### `fenzi approve [--save [--dry-run] [--policy-from ]] [--sandbox ] [--json]` Approves a request. The id can be any start of the full id that matches one request. The sandbox loads the new rule on its next poll, about ten seconds later. On Free, the approval also covers the next calls of the same kind: the request's host is added to the running sandbox's policy, `read-only` for a read, or the method and path for a write, checked by the prover and loaded. Other pending requests for that host that it covers are approved with it. It lasts as long as the sandbox, and `fenzi policy apply` keeps it. `--json` names it in `same_kind`. On Team, approve in the console. An approval made here still works, and the console shows it as [drift](https://fenzi.dev/docs/drift). `--save` also adds the host to the project's `fenzi.yaml`, so the next sandbox in that folder starts with it. Comments in the file are kept. A request that allows only `GET` or `HEAD` is saved as `read-only`, which allows `GET`, `HEAD`, and `OPTIONS` on every path. A request for another method is saved as `read-write` with its `METHOD /path` line. A request with no method or path, which lets any traffic through to the host, is saved as `read-only`, and the command says so. A host already in the file, in `developer-default` or in one of the folder's [stacks](https://fenzi.dev/docs/default-access#stacks) at another level is left for you to edit; a write to `github.com`, which `developer-default` opens with allow lines, is saved with those lines and the new one, since the project's entry replaces the default's. Then it runs the check `policy check` runs and prints the result. A request in a form it cannot save is not approved, and it says why. On a signed-in machine `--save` is refused: the team policy is published from the console, and the message names the request's page there, `/console/requests//`. Not with `--json`, except with `--dry-run`. `--save --dry-run` approves nothing and writes nothing. It prints the file it would change, a unified diff of `fenzi.yaml` before and after, the entry it would add or that the host is already there, and the check `policy check` runs, made on the new content in a temporary folder. It exits `0` when the check passes, `2` when it fails, and `1` on an error. With `--json` it prints `file`, `exists`, `before`, `after`, `diff`, `host`, `port`, `access`, `allow`, `already`, `note`, `from` with `--policy-from`, and `check` with `passed`, `result`, `checked`, `agent`, `example`, and `reason`. `--save --policy-from ` takes the new `fenzi.yaml` from the file given, for example the preview after you edited it. It checks that file first. Only when the check passes does it approve the request and write the file; when it fails, nothing is approved or written, and it exits `2`. With `--dry-run` it previews that file instead. ### `fenzi deny --reason "" [--json]` Denies a request and keeps the reason with it. **What it calls upstream** `openshell rule reject --reason`. ## Log and changes ### `fenzi log [flags]` | Flag | Meaning | | --- | --- | | `--deny` | Denies only, with the sandbox's reason for each. | | `--sandbox ` | One sandbox. Default: the latest sandbox for the current folder. Outside a project, the latest one overall, and the command says which. `requests`, `approve`, `deny`, `diff`, and `apply` choose the same way. | | `--since ` | Only decisions newer than this, for example `10m` or `2h`. Running and finished sandboxes. | | `--follow` | Keep printing new decisions as table rows, for a running sandbox. With `--deny`, denies only. With `--raw`, every line as the runtime writes it. | | `--raw` | Everything the sandbox logged, as the runtime wrote it: settings changes, policy loads, closed connections. | | `--requests` | Also the requests the agent filed and the approvals, as the runtime logged them: a `requested` or `approved` row with the program, the destination and the request's short id where a decision has its rule. With `--follow` too. Not with `--raw`, which already prints them. | | `--json` | The decisions as one JSON list instead of the table. With `--follow`, one JSON object per line as each decision arrives. Not with `--raw`. See Output for scripts. | Reads the gateway's log stream for a running sandbox, and the copy saved at exit for a finished one. Fenzi writes that copy before it deletes the sandbox, because deleting the sandbox deletes the gateway's log. The table is network decisions only: time, allow or deny, program, destination, and rule. A deny's reason is in `--deny`. Query strings are left out. A blocked file write is not in the log; see [What the log does not hold](https://fenzi.dev/docs/log#not). A `reset` line is a connection closed because the policy changed; the program reconnects, and `--deny` leaves it out. ### `fenzi diff [--sandbox ] [--stat] [--json]` Lists the agent's changes against your working tree with line counts, including deleted files, then shows each file's changed lines. Long output goes through `$PAGER`, or `less`. `--stat` prints the list only. In a git repository the heading names the branch the agent's commits landed on and how many commits they are. A file marked `!` runs on this machine once applied, with no further step from you: a direnv file, a git hook, an editor's tasks, a `package.json` whose scripts changed. `--json` prints the same as one document; see Output for scripts. ### `fenzi apply [--sandbox ] [--yes]` Lists the changes, then asks: merge them, show them, or keep them for later. Without a terminal it asks `[y/N]` on one line. `--yes` answers yes. In a git repository the agent's commits are already a branch in it, and apply fast-forwards the branch you started on to them. It does that only when that branch is still checked out at the commit it was at, and your folder is clean or still holds exactly the edits it had at start. Otherwise it refuses, says why, and names the merge to run by hand; the branch and your folder are left as they were. A branch you merged yourself is found merged, and nothing is written. See [Apply](https://fenzi.dev/docs/workspace#apply). In a folder with no git history, apply copies the changed files in. It refuses if a file changed on your side since the agent started, and lists those files. When an agent exits, or after `fenzi stop`, the same list and question appear in the terminal. Keeping the changes for later leaves your folder as it was. After an apply, a sandbox that keeps running is compared against what was applied, so the next `stop` brings back only what the agent changed since. ## MCP servers The servers every agent gets in this folder, from the `mcp` section of `./fenzi.yaml` and of `~/.config/fenzi/mcp.yaml`. See [MCP servers](https://fenzi.dev/docs/mcp). ### `fenzi mcp list [--json]` Each server, its URL or command, the tools agents may call, where it comes from (project, machine, project over machine, or team), and whether its token is stored. ### `fenzi mcp add --tool ... [--deny ] [--all-tools] [--token] [--machine]` Adds or replaces a remote server. At least one `--tool`, or `--all-tools`. `--machine` writes `~/.config/fenzi/mcp.yaml` instead of `./fenzi.yaml`. A project entry that would widen a machine server is refused. ### `fenzi mcp add [--secret ]... [--host ]... [--machine] -- [args...]` Adds a local server, which runs inside the sandbox as a child of the agent. `--host` lets it call that host over HTTPS. `--secret` names a variable it reads that holds a secret; the value goes only to its `--host` hosts, and a server with a secret needs at least one. ### `fenzi mcp add --claude-account --tool ... [--deny ] [--all-tools] [--machine]` Lets Claude Code use the connectors of the Claude account it is signed in with, and the tools it may call there, named as the connector names them. No URL and no token: Claude Code finds its connectors and sends its own sign-in. Other agents get nothing from it. ### `fenzi mcp remove [--machine]` Removes the entry. A stored token stays until `fenzi mcp token --remove`. ### `fenzi mcp token [--env ] [--remove]` Stores or replaces a server's token without showing it, or reads one line from a pipe. `--remove` forgets it, and refuses while a sandbox started with it is running. For a local server, it stores the secret the server reads from `VAR`; `--env` can be left out when the server lists one secret. A secret is stored once per variable, and every server that lists the variable uses it. **What it calls upstream** `openshell profile import` of a profile with no endpoints, then `openshell provider create --from-existing` or `provider update`, with the value in the environment of that one command. The sandbox policy binds the provider to the server's endpoint, or to a local server's hosts, with `credential_binding`. ### `fenzi mcp import [file] [--dry-run] [--json]` Copies the servers in `.mcp.json` or `.cursor/mcp.json` into `./fenzi.yaml`, with every tool allowed, no tokens, and a local server's secrets by name only. A server already in `fenzi.yaml` is left as it is. `--dry-run` shows what it would add and skip, and writes nothing. ## Policy `compile` and `check` read the policy `fenzi run` would use unless you name a file: `./fenzi.yaml` merged over the built-in default, or the team's signed revision on a signed-in machine. `--agent` picks the agent to compile for (default `claude`). `--org` treats the file as a complete policy instead of a project file. ### `fenzi policy compile [file] [-o out.yaml]` Prints the OpenShell policy the file compiles to. Needs no gateway. ### `fenzi policy check [file] [--boundary file] [--json]` Runs the policy prover and prints the result with a counterexample if there is one. Needs no gateway. Exits `2` unless the result is `within_boundary`. **What it calls upstream** `openshell-prover check`. ### `fenzi policy apply [--policy file]` Free plan. After you edit `./fenzi.yaml`, brings the change to the sandboxes already running from this folder. It resolves the policy the way `run` does and compares it with the one each sandbox started with, which `run` saves in the sandbox's run folder. A change to hosts only is compiled, checked with the prover, and loaded onto the running sandbox; the line says when `policy list` shows `Loaded`, and the new policy replaces the saved one. A change to workspace access or paths is fixed when a sandbox is created: nothing changes, and the line says it takes effect on the next run. A sandbox started by a release that did not save its policy is left as it is. Exits `2` when the prover does not return `within_boundary`; nothing is loaded then. On a signed-in machine it refuses: the team policy comes from the console, and `fenzi sync` loads a published host change. **What it calls upstream** `openshell sandbox list --names --selector fenzi=1`, `openshell-prover check`, `openshell policy set --wait`, `openshell policy list`. ### `fenzi policy host set [--write "METHOD /path"]... [--port n]` Free plan. Puts the host in `./fenzi.yaml`, read only, or limited to the requests each `--write` names. An entry for the same host and port is replaced, so the file says what you chose. A host the built-in default lists is changed for this project by its entry here. The file is created when there is none, its comments are kept, and the result is checked over the built-in default before anything is written. The next sandbox started in the folder gets it. `fenzi policy host remove ` takes it out again. ### `fenzi policy path add [--write]` Adds a path inside the sandbox, read only or with `--write` read and write; adding it again with the other access moves it. Paths are fixed when a sandbox is created, so the next new sandbox gets it. `fenzi policy path remove ` takes it out. Both take `--json`. ## Agents ### `fenzi agents [--json]` Lists the agents in the catalog, their pinned versions, and their test status. ### `fenzi agents build ` Builds or rebuilds the agent's image with Docker or Podman, whichever the gateway uses. See [Agent images](https://fenzi.dev/docs/images). ### `fenzi tools [agent] [--build] [--json]` Names the languages the folder's files call for (`composer.json`, `go.mod`, `Gemfile` and the like) and, for each, its commands and where they come from: the agent's image, a copy of it that `run` builds with them added, or nowhere yet, with the reason. It says whether that copy is built already. `run` builds it, then checks the commands once the sandbox runs; `--build` builds it now, so the first start does not wait. The Mac app does that as soon as New Sandbox shows a folder that needs it. See [Your project's languages](https://fenzi.dev/docs/images#tools). **What it calls upstream** `openshell gateway info`, to pick the image builder the gateway uses, which says whether the copy exists and, with `--build`, builds it; nothing else. ## Update ### `fenzi update [--check] [--json]` Reads `https://fenzi.dev/dl/latest.txt`. If it names a newer release, downloads the binary for this machine, checks it against that release's sha256 list, and replaces the running command. Nothing changes if the checksum does not match. `--check` only reports. Running sandboxes are not touched. Commands also mention a newer release on their own, at most once a day; see [The update check](https://fenzi.dev/docs/versions#check). ### `fenzi version [--json]` Prints the release of this binary. ## Uninstall ### `fenzi uninstall [--keys] [--command] [--images] [--runtime] [--all] [--dry-run] [--yes] [--json]` Removes Fenzi from this machine. It always deletes Fenzi's sandboxes (changes you have not applied go with them), removes the background forwarder, and deletes `~/.config/fenzi` and `~/.cache/fenzi`, which hold the records, the settings and the Team sign-in. On request it also forgets the model keys and MCP tokens stored in the runtime (`--keys`), removes the `fenzi` command and the PATH line the installer added (`--command`), deletes the agent images (`--images`), and removes the sandbox runtime with its gateway and data (`--runtime`, on a Mac where it came from Homebrew). Docker, colima and your repositories are not touched. It asks first; `--yes` skips the question and `--dry-run` only lists what would go. In the Mac app, Uninstall Fenzi in the Fenzi menu and in Settings, Advanced, runs it with toggles for each part, then clears the app's settings and moves the app to the Trash. **What it calls upstream** `openshell sandbox list`, `openshell sandbox delete`, `openshell provider list --names`, `openshell provider delete`; with `--runtime`, `brew services stop openshell` and `brew uninstall openshell`. ## Team commands These commands are for the Team plan. All but `login` need a machine signed in to a team. ### `fenzi login [--server URL]` Prints a code and a page to open, `https://fenzi.dev/device` unless `--server` names another console. Signed in to the console, you enter the code, check the machine name, and approve. The machine caches the signed policy. A later `fenzi run` uses that policy. `fenzi.yaml` in the project does not add hosts on top of it. In a terminal it then asks whether to keep forwarding after the terminal closes, which is `fenzi forward --install`; without a terminal it only names that command. ### `fenzi login --token-for `, `fenzi login --token-stdin` For a CI runner, where nobody can open a browser. `--token-for github-actions` runs the same sign-in for a new machine of that name. You approve it in the browser, so the machine and its runs belong to you. It prints the machine's token on standard output, for a secret store, and stores nothing on this machine. `--token-stdin` signs in with such a token read from standard input, never from the command line: it asks the server which member, team and machine the token belongs to, fetches the team's key and the signed policy, and caches the policy only if the signature checks. A token the console signed out is refused. See [The team token](https://fenzi.dev/docs/ci#token). ### `fenzi logout` Stops and removes the [forwarder service](https://fenzi.dev/docs/forwarder#service) if it is installed, waits for a forwarder pass in progress to end, then forgets the sign-in and the cached policy. A sandbox that is already running keeps the policy it started with. ### `fenzi status [--json]` Shows who is signed in, the team, and the cached revision. If the console cannot be reached, or signed this machine out, it says so and keeps the cached policy after checking the signature again. If the console sends a revision that fails the signature check, or one older than the cached revision, the machine keeps the cached one, checks it again, and says so: `the server sent r3, which failed the signature check; still on r2`. The heartbeat carries the same note to the console's Drift page. With no policy cached, such a revision is refused and the command fails. `run`, `sync`, and `forward` behave the same way. It also says whether the forwarder service is installed and running, and which forwarder runs now; `doctor` has the same line. ### `fenzi policy publish ` Sends a complete org policy to the console. It compiles it for every agent it names, runs the prover, and refuses it unless the result is `within_boundary`. Only an admin can publish. The new revision is cached on this machine. The same action is on the console's Policy page, which also shows the check before you publish. ### `fenzi sync` One pass: it fetches the team's newest policy revision, loads any host change onto this machine's running sandboxes, and sends the decisions waiting to go. If the new revision only changes hosts, the pass compiles it for each running sandbox and checks it with the prover, as `run` does before it creates a sandbox. Only a result of `within_boundary` is loaded, and the pass says when `policy list` shows `Loaded`. Otherwise, or when the prover is not installed, the sandbox keeps the revision it has and the pass says why. A change to paths, workspace access, or agents still needs a new sandbox: those sandboxes keep the policy they started with, and the next run creates a new one. ### `fenzi forward [--once] [--every ] [--install | --uninstall]` Sends this machine's decisions, pending requests, and a report on the machine to the team console, and applies the reviews made there. The console does not connect to this machine. Without `--once` it repeats the pass every five seconds until you stop it; `--every 30s` changes that. If the console is unreachable, records wait on this machine and the pass still exits 0. While another forwarder repeats on this machine, such as the service, it says so, waits, and takes over when that one stops. What one pass does, gaps, and the local queue are on [Forwarding decisions](https://fenzi.dev/docs/forwarder). `--install` keeps it running for your user after the terminal closes and at every login: a launchd agent on macOS, a systemd user unit on Linux, with its log in `~/.cache/fenzi/forward.log`. `--uninstall` stops it and removes it. See [Run it as a service](https://fenzi.dev/docs/forwarder#service). ## Output for scripts `--json` prints one JSON document on standard output and nothing else there. Errors stay on standard error with the same exit codes. The text output does not change. Field names are lower case with underscores, as in `key_env`. ```bash fenzi ps --json ``` Output ``` [ { "name": "fenzi-web-4f2a", "agent": "claude", "folder": "/Users/dana/web", "created": "2026-10-03T10:41:52Z", "running": true } ] ``` | Command | The document | | --- | --- | | `doctor` | `checks`, one per line of the text output, each with `name`, `status` (`ok`, `fail`, or `skip`), and `detail`; and `ready`, false when a check failed. | | `version` | `version`. | | `agents` | A list, one per agent: `name`, `display`, `version`, `key_env`, `status`, `available`, `sign_in`. `sign_in` is true for an agent that can start with no key stored and sign in itself. | | `ps` | A list, one per sandbox: `name`, `agent`, `folder`, `created` (RFC 3339, empty for a sandbox Fenzi did not start), `running`, `ended` (RFC 3339, only once fenzi saw the agent exit or stopped the sandbox), `lost` (true when its container stopped), and in a git repository `git`: `branch`, `head`, `dirty`, `history`, `files_only`, `start`, `agent_branch`, `landed`, `tip`, `commits`, `checkpoint`, `merged`, as [What comes back](https://fenzi.dev/docs/workspace#out) describes them. The agent's commits are `start..landed`. | | `requests` | A list, one per request: `id` in full, `destination`, `binary`, `rationale`, `draft`, true for a request the agent did not ask for. Those are in it only with `--all`. Empty when nothing waits. If the runtime's text format changed, it exits `1` rather than print the raw text. | | `approve`, `deny` | `id`, `sandbox`, `result` (`approved` or `denied`), `note`. `approve --save --dry-run` prints the preview described above instead. | | `log` | A list of decision records, the ones [the forwarder ships](https://fenzi.dev/docs/forwarder#record) before it adds the machine and policy revision: `time`, `sandbox`, `class`, `action` (`Allowed` or `Denied`), `destination`, then `process`, `rule`, and `reason` when the runtime logged them. A reset is a denied record whose `reason` says the policy changed. `--deny` keeps denies only, without resets. `--follow` prints one object per line as each decision arrives, and nothing for other log lines. `--requests` adds records of class `Config` with `action` `Requested` or `Approved`, the request's `chunk` id, the `destination` as the runtime wrote it and the `process`. A denial has no such record: the runtime does not log one. | | `diff` | `sandbox`, `folder`, `agent`, `files` (one per change: `path`, `kind` as `new`, `edited` or `deleted`, `added`, `removed`, `binary`, `large`, `host_run` with the reason the file runs on this machine once applied, and `hunks`, each with `old_start`, `new_start` and `ops` of `kind` , `-` or `+` and `text`; left out with `--stat`), the totals `added`, `removed` and `host_run`, `landed` (`branch`, `name`, `commits`, `merged`) when the commits are a branch, and `apply`, what `fenzi apply` would do. An empty `files` list when the agent left the folder as it was; nothing staged stays an error. | | `key list` | A list, one per agent: `name`, `display`, `key_env`, `stored`, `available`, `sign_in`. Never a key. | | `mcp list` | A list, one per server: `name`, `url` or `command`, `allow`, `deny`, `token`, `token_stored` (missing when the runtime did not answer), `source`, and for a local server `hosts` and `secrets`, one per variable: `variable`, `stored`. Never a token or a secret. | | `mcp import` | `sources`, the files read; `added`, one per server: `name`, `url` or `command`, `allow`, `token`, `secrets`, `hosts`; `skipped`, one per server left out: `name`, `reason`; `tokens`, the servers whose `Authorization` header was not copied; and `secrets`, one per variable whose value was not copied: `variable`, `servers`, `hosts`. The same with `--dry-run`, which writes nothing. Never a token or a secret. | | `rm` | `removed`, one per sandbox forgotten: `name`, `staged_changes`, `saved_log`; and `refused`, one per sandbox still running: `name`, `reason`. Exits `1` when anything was refused, as without the flag. | | `status` | `signed_in`, `email`, `role`, `team`, `machine`, `server`, `console_url`, `policy_revision`, `notes`. Signed out, `signed_in` is false and the rest is empty. | | `policy check` | `passed`, `result` (the prover's word, such as `within_boundary`), `checked`, `agent`, `example`, `reason`, `not_checked`. Exits `2` unless it passed, as without the flag. | | `update` | `current`, `latest`, `available`, and `installed` with the path written after an install. `--check` only reports. | `log --raw` and `policy compile` do not take it. `--raw` is the runtime's own lines, and `compile` already prints YAML. Each says so and exits `1`. ## Exit codes | Code | Meaning | | --- | --- | | `0` | Success. | | `1` | Error. The message says what failed. | | `2` | The policy check did not return `within_boundary`. Nothing started or loaded. | | `3` | OpenShell is missing, outside the pinned range, or not connected. | `run` and `connect` return the agent's own exit code after the agent has started. Ctrl-C at a question returns `130`. `run --headless` returns its own status once the agent has started: `0` the agent finished, `4` the agent exited with an error, `5` the time limit came first, `6` a request had no answer. A time limit that passes before the agent starts is `5` too. ## Files | Path | Holds | | --- | --- | | `./fenzi.yaml` | The project policy. | | `~/.config/fenzi/enrollment.json` | This machine's sign-in and the cached signed policy. | | `~/.config/fenzi/forward.json` | Where the forwarder stopped reading each sandbox's stream, and which finished sandboxes' saved logs it has sent. | | `~/.config/fenzi/spool.jsonl` | Decision records waiting to upload. Team only. Removed when empty. | | `~/.cache/fenzi/forward.log` | The forwarder service's log. Team only, when the service is installed. | | `~/.cache/fenzi/staging/` | Changes copied out of sandboxes, waiting for `apply`. | | `~/.cache/fenzi/runs//` | One folder per run: the compiled policy, the boundary, the policy the sandbox actually got, `resolved.yaml`, the policy document it started with, and `sandbox.log`, the log saved when the agent exited. | Model keys are not in any of these. They are in the gateway's provider store.