---
title: "Shells and agent sessions"
seo:
  description: "Run commands, coding agents, and disposable sessions."
---

Run commands, coding agents, and disposable sessions.

## `shell`

Open an interactive shell in the VM, or run a single command non-interactively.

```
iso shell [NAME] [FLAGS] [-- COMMAND...]
```

| Flag | Description |
|------|-------------|
| `NAME` | Instance name (required if multiple instances exist) |
| `-- COMMAND...` | Command to run non-interactively (no PTY allocated) |

Without a trailing command, `shell` drops you into an interactive shell at `/workspace`. With a trailing command, it executes the command and returns its exit code.

```
iso shell
iso shell my-project
iso shell my-project -- cat /etc/os-release
```

## `claude`

Launch Claude Code inside the VM. The guest's `~/.claude/settings.json` (written during VM startup) sets `defaultMode: bypassPermissions` and `skipDangerousModePermissionPrompt: true`, so Claude Code runs without permission prompts — the VM itself is the isolation boundary. Use `--ask` to override the guest default for that session (isolate passes `--permission-mode default`).

```
iso claude [NAME] [FLAGS] [ARGS...]
```

| Flag | Description |
|------|-------------|
| `NAME` | Instance name (required if multiple instances exist) |
| `--ask` | Prompt for permissions instead of skipping them |
| `ARGS...` | Extra arguments passed through to `claude` |

```
iso claude
iso claude my-project --ask
iso claude my-project -- --model sonnet
```

## `claude-agents`

Open the Claude Code agent view (`claude agents`) inside the VM. Claude Code's background agents are managed by its own daemon, so closing the terminal does not stop in-flight sessions; reconnect with `iso claude-agents` to see them again.

If the remote TUI stops responding, type Enter, then `~.` to disconnect the SSH session. isolate forces OpenSSH's interactive escape character to `~`, so this works even if your user SSH config disables or changes `EscapeChar`. If the terminal remains in a broken raw/no-echo state afterward, run `stty sane`.

```
iso claude-agents [NAME] [FLAGS] [ARGS...]
iso ca [NAME] [FLAGS] [ARGS...]
```

| Flag | Description |
|------|-------------|
| `NAME` | Instance name (required if multiple instances exist) |
| `ARGS...` | Extra arguments passed through to `claude agents` |

Alias: `ca`.

```
iso claude-agents
iso ca my-project
iso ca my-project -- --cwd /workspace
```

## `codex`

Launch Codex inside the VM. By default isolate passes `--dangerously-bypass-approvals-and-sandbox`, so Codex runs without its sandbox or approval prompts — parity with `iso claude`. The VM is the isolation boundary, and Codex's own Linux sandbox does not work in the guest (no functioning bubblewrap), so leaving it enabled makes every shell command Codex runs fail. Use `--ask` to keep Codex's sandbox and approval prompts for that session. With `"codex": { "auth": "chatgpt" }`, `iso codex` launches through the guest keyring wrapper. The `login` and `logout` subcommands are always launched without the bypass flag: they never start an agent session, so there is nothing to sandbox.

```
iso codex [NAME] [FLAGS] [ARGS...]
```

| Flag | Description |
|------|-------------|
| `NAME` | Instance name (required if multiple instances exist) |
| `--ask` | Keep Codex's sandbox and approval prompts instead of bypassing them |
| `ARGS...` | Extra arguments passed through to `codex` |

```
iso codex
iso codex my-project --ask
iso codex my-project -- --model gpt-5
iso codex my-project -- login --device-auth
```

## `exec`

Run a command in the VM and print its output. No PTY is allocated and stdin is not forwarded (`shell NAME -- COMMAND` forwards it); use `shell` for interactive work. `exec` exits with the command's status.

The command and its arguments must follow `--` so they are not mistaken for the instance name.

```
iso exec [NAME] -- COMMAND...
```

| Flag | Description |
|------|-------------|
| `NAME` | Instance name (required if multiple instances exist) |
| `COMMAND...` | Command and arguments to run after `--` (required) |

```
iso exec -- uname -a
iso exec my-project -- docker ps
```

## `run`

Ensure a project environment is running, then launch an agent. This reuses
`up`'s project affinity. A running match is not pushed, rebuilt, or
bootstrapped again, and guest output is not copied back.

```
iso run <agent> [--workspace DIR] [--name NAME]
        [--image NAME | --profile LIST]
        [--egress MODE] [--allow-host HOST]...
        [--prepare] [--rm] [--ask] [--dry-run] [--json]
        [-- AGENT_ARGS...]
```

| Flag | Description |
|------|-------------|
| `<agent>` | `claude`, `codex`, or an installed definition id |
| `--workspace <dir>` | Project directory (default: current directory) |
| `--name <name>` | Instance name. Must match the recorded workspace when both are set |
| `--image <name>` | Image for a new instance. Mutually exclusive with `--profile` |
| `--profile <list>` | Profile set for a new instance, repeatable or comma-separated. Replaces a definition's environment selector |
| `--egress <mode>` | Egress mode when creating an instance: `open`, `none`, or `filtered` |
| `--allow-host <host>` | Exact host to approve for a filtered boot, repeatable. Does not change `none` or `open` to `filtered` |
| `--prepare` | Authorize image preparation. Preparation uses the host network and receives neither the workspace nor provider credentials |
| `--rm` | Create a new disposable instance and destroy it after the agent exits. Never attaches cleanup to an existing VM |
| `--ask` | Use the adapter's permission prompts instead of its default bypass |
| `--dry-run` | Print the prospective launch. Does not start a VM, build an image, resolve a credential, or check for updates |
| `--json` | With `--dry-run`, emit a versioned preview on stdout |
| `-- AGENT_ARGS` | Arguments forwarded to the agent, unchanged: every token after the first `--` (including `--ask` or another `--`) belongs to the agent. They are not interpreted by a host shell |

Filtered egress has partial local VM evidence, not full qualification (see [testing](/docs/contributing/testing#local-filtered-vm-evidence-partial)). Definition network hints are shown and are not grants. `iso claude` and `iso codex` keep their existing behavior. A disposable instance is not adopted by a later `iso up`.

```
iso run claude
iso run codex --name payments
iso run claude --rm --workspace ./scratch
iso run codex --workspace ./service --dry-run --json
```

## `run-cleanup`

Reconcile an abandoned disposable run. Deletes an instance only when the session record, owner, marker, and sandbox id agree. A pending staged pull is retained.

```
iso run-cleanup --dry-run
iso run-cleanup --session <ID>
```

## `model`

Show or switch a VM's model backend between cloud (Anthropic / OpenAI) and a
host-side local model server. The selection is per-instance and persists across
restarts. Switching rewrites the guest agent config of a running VM; it never
rebuilds or restarts the VM. On a running brokered VM, a switch that adds or
removes a local-model service changes the boot's network policy, which is fixed
per boot: the selection is saved, the guest is left as it is, and the command
prints the `iso stop NAME && iso start NAME` that applies it.

```
iso model show [NAME]
iso model set local|remote [NAME]
```

| Argument | Description |
|----------|-------------|
| `NAME` | Instance name (required if multiple instances exist) |
| `local` | Route this VM's agents at a host-side local model server |
| `remote` | Restore cloud defaults (Anthropic / OpenAI) |

`model show` (or bare `iso model`) prints the current mode and the endpoint each
tool (Claude, Codex) resolves to:

```
$ iso model show my-project
Instance: my-project
Mode:     local
Claude   local — qwen2.5-coder:32b @ http://localhost:11434
Codex    cloud (no local endpoint configured)
```

`iso model set local NAME` switches the VM to local mode. Each tool routes locally
only if it resolves an endpoint — from `claude.local_model` /
`codex.local_model` in the configuration, or from one saved earlier. For any tool
that has neither, and only in an interactive terminal, isolate prompts for a host
URL, model name, and optional auth token, then saves that endpoint for the
instance. (A non-interactive run declines the prompt.) If no tool ends up with
an endpoint, the command fails. Claude and Codex are independent: you can put
one on a local model and leave the other on cloud.

`iso model set remote NAME` switches back to cloud defaults for both tools. Saved
endpoints are kept, so a later `local` does not re-prompt.

Switching never requires a VM restart — isolate rewrites the guest config live over
SSH when the VM is running, or saves it to apply on the next start. An
already-running `claude`/`codex` reads its config at launch, so relaunch the
agent (for example `iso claude NAME`) to pick up the change.

```
iso model
iso model show my-project
iso model set local my-project
iso model set remote my-project
```

The older form `iso model [NAME] [local|remote]` still works and prints a
deprecation note on stderr. Because `show` and `set` were valid instance names
under that form, `iso model show`, `iso model show local|remote` and
`iso model set local|remote` (no NAME) are refused as ambiguous when an
instance named `show` or `set` exists; name the instance explicitly
(`iso model show show`, `iso model set local set`).

See the [`local_model`](/docs/configuration/agents#local-model-routing) configuration
reference and the local-model sections of
[docs/claude-integration.md](/docs/claude-integration) and
[docs/codex-integration.md](/docs/codex-integration) for the resolution and
materialization details.
