# A deep dive into Rex

> Rex from Superlogical: client-server architecture, libghostty, CLI automation, Lua scripting, OSC 7501 and OSC 7577 protocols, agent skills, iOS, and remote servers.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2026-11-30 | Updated: 2026-11-30 | Topics: [AI](https://flaviocopes.com/tags/ai/) | Canonical: https://flaviocopes.com/rex/

<video controls playsinline preload="metadata" poster="/images/rex/intro-poster.jpg" width="1920" height="1080" style="width: 100%; height: auto;">
  <source src="https://images.flaviocopes.com/rex/intro.mp4" type="video/mp4" />
</video>

[Rex](https://www.superlogical.com/) is a terminal application and built-in multiplexer from Superlogical, the new company founded by Mitchell Hashimoto.

If you know Hashimoto, you know [Ghostty](https://flaviocopes.com/ghostty/), Terraform, Vagrant, Vault.

With Superlogical, he teamed up with Jack Pearkes (HashiCorp's first employee, and former VP of Engineering), Alasdair Monk (former Head of Experience at Poolside, and VP of Design at Vercel), and Hector Simpson (formerly at Poolside, Vercel, and HashiCorp).

They have a very ambitious goal. They describe Rex as "the multiplexer for all work", a single persistent session layer that bridges your laptop, remote Linux or FreeBSD servers, Windows machines, your iPhone, background jobs, and AI coding agents.

Rex is currently in invite-only public testing. I installed the macOS preview (`0.1.0-preview.37`, bundled with server and CLI `0.1.0-preview.25`) on my MacBook Pro, enabled its built-in Tailscale server, paired Rex for iOS (`0.1.1`) on my iPhone over QR code, and ran real sessions, CLI commands, Lua configs, and custom terminal status sequences across both devices.

Here is everything Rex does today, how its architecture works under the hood, and where it fits alongside [Ghostty](https://flaviocopes.com/ghostty/), [tmux](https://flaviocopes.com/tmux/) and [T3 Code](https://flaviocopes.com/t3-code/).

## What is Rex, and how is it different from Ghostty and tmux?

Rex is a GPU-accelerated terminal emulator and a persistent multiplexer, all in one.

With a traditional setup, you open a terminal emulator like [Ghostty](https://flaviocopes.com/ghostty/), and then you run [tmux](https://flaviocopes.com/tmux/) inside it to have persistent sessions.

It works, but you have 2 layers on top of each other fighting for scrollback, text selection, mouse events, key bindings, and more.

Rex removes that middle layer by putting a background **Rex Server** in charge of your shells, processes, tabs, and layouts. The Rex desktop and mobile apps are native clients that attach to that server.

Close the macOS app and your programs keep running. Open Rex on your iPhone over [Tailscale](https://flaviocopes.com/tailscale/) and you see the same live session.

One common point of confusion is how Rex relates to Ghostty, because they are separate products.

Ghostty is an independent, open-source terminal emulator, maintained as a nonprofit project.

Rex is a commercial product from Superlogical, and it uses `libghostty`, the MIT-licensed rendering and terminal emulation core extracted from Ghostty.

If you already like Ghostty's text rendering and speed, Rex will feel familiar.

The difference is all the stuff that surrounds the terminal grid: persistent servers, cross-device sync, a scriptable JSON CLI, Lua automation, and protocols built for coding agents.

Rex also does not ship a built-in AI chat sidebar or model provider.

Instead, it gives external coding agents like [Claude Code](https://flaviocopes.com/claude-code-guide/), [Codex](https://flaviocopes.com/codex/), [OpenCode](https://flaviocopes.com/opencode/), [Pi](https://flaviocopes.com/pi/) and others first-class tools to drive the terminal and report their live status.

| Tool | Core role | Persistent server | Native mobile client | Built-in AI UI | Scripting & config |
| --- | --- | --- | --- | --- | --- |
| **Rex** | Terminal + multiplexer | Yes (macOS, Linux, FreeBSD, Windows) | Yes (iOS/iPadOS beta) | No (agent skill + OSC 7501/7577) | Lua 5.1, JSON CLI, control API |
| **[Ghostty](https://flaviocopes.com/ghostty/)** | Standalone terminal emulator | No | No | No | Key-value config |
| **[tmux](https://flaviocopes.com/tmux/)** | Terminal multiplexer (inside a terminal) | Yes (Unix) | No (via SSH apps) | No | tmux config + CLI |
| **[Zellij](https://flaviocopes.com/herdr-vs-tmux-zellij/)** | Terminal multiplexer (inside a terminal) | Yes (Unix) | No (via SSH apps) | No | KDL layouts + Wasm plugins |
| **[cmux](https://flaviocopes.com/cmux/)** | Native macOS agent terminal | Local app state | No | Browser + agent notifications | CLI + app shortcuts |
| **[T3 Code](https://flaviocopes.com/t3-code/)** | Agent control plane | Yes (local/remote server) | Web / mobile UI | Yes (chat, diffs, PR guides) | Providers, workflows, MCP |

Superlogical lays out a three-step roadmap on its homepage:

1. Build an incredible multiplexer.
2. Make everything in it composable.
3. Make it safe and operable in production.

Right now Rex is in the middle of step 1, and we can already see the foundations of step 2 in the blocks system and the control API.

## How the client-server architecture works

Every piece of state in Rex lives on a **Rex Server**, not in the app window.

When you open Rex on macOS, the app launches and manages a local server automatically, communicating over a Unix domain socket (`~/Library/Application Support/rex/server.sock`).

When you connect to a Linux VPS or a Mac mini at home, the same client attaches to a remote Rex Server over SSH or Tailscale.

Because the server owns the state, closing the Rex window or quitting the Mac app completely does not interrupt anything.

When I quit Rex during testing and reopened it a moment later, all 3 tabs, all 5 split panes and the processes running inside them reattached, with their scrollback intact.

### Rex vocabulary compared to tmux

If you used [tmux](https://flaviocopes.com/tmux/), the mental model maps cleanly, although Rex uses its own names across the UI and the CLI.

| Rex term | ID prefix | What it is | Closest tmux equivalent |
| --- | --- | --- | --- |
| **Server** | (host / socket) | Background process that owns all sessions and processes | tmux server |
| **Session** | `session:<uuid>` | A project or group of related work | tmux session |
| **Window** | `window:<uuid>` | A tab inside a session holding a layout | tmux window |
| **Block** | `block:<uuid>` | One running unit inside a window (a terminal today, plus internal file and tunnel blocks) | tmux pane |
| **Client** | `client:<uuid>` | Any connected app or CLI invocation (`Rex.app`, iOS app, `rex`) | Attached client |

Every resource has an immutable UUIDv7 identifier that's never reused, and a mutable human-readable label.

A Rex **block** is different from a Warp terminal block. In Warp, a block wraps a single command and its output.

In Rex, a block is a pluggable component owned by a **block creator**.

Today the server ships 4 built-in creators, which you can inspect live with `rex api call block_creator.list`:

```text
com.superlogical.fs         Files       com.superlogical.fs.fs
com.superlogical.onboarding Onboarding  com.superlogical.onboarding.onboarding
com.superlogical.terminal   Terminal    com.superlogical.terminal.shell
com.superlogical.tunnel     Tunnel      com.superlogical.tunnel.dial, com.superlogical.tunnel.listen
```

This design explains why Superlogical calls them blocks, instead of panes. Terminals are just one creator (`com.superlogical.terminal`). File transfers (`rex cp` and drag-and-drop) run through `com.superlogical.fs`, and TCP port forwarding (`rex forward`) runs through `com.superlogical.tunnel`.

In the future, other non-terminal surfaces can plug into the same session and layout engine.

![Rex workspace with three split panes and live status indicators in the tab bar](https://images.flaviocopes.com/rex/workspace-splits.webp)

In the screenshot above you can see a single `work` session with 3 tabs (`api`, `deploy` and `tests`) and 3 split terminal blocks in the active tab (`rex-cli`, `agent-worker` and `status-probe`).

Notice the tab headers at the top: `deploy` has a Terraform icon and a live blocked message, `api` has a Claude Code active indicator and `tests` has a blue completion dot.

## Platforms, beta availability, and terminfo setup

Superlogical opened public testing on October 5, 2026 with a macOS-only build.

Since then, platform coverage has grown quickly:

| Platform | App (Client) | Rex Server & CLI | Beta availability |
| --- | --- | --- | --- |
| **macOS** (15.0+) | Yes (native, self-hosts server) | Bundled inside `Rex.app` | All beta testers |
| **iOS / iPadOS** | Yes (native, client only) | No | Enrolled testers (via Discord) |
| **Windows** (10 1809+, x64/ARM64) | Yes (beta) | Yes (Personal mode, WinGet/MSI/Zip) | Server for all testers; app for enrolled testers |
| **Linux** (x64/ARM64, glibc/musl) | In development (not in testing yet) | Yes (Personal, Shared, Login modes) | Server for all testers |
| **FreeBSD** (14.0+, x64/ARM64) | No | Yes (Personal, Shared, Login modes) | Server for all testers |

Public testing still requires signing up on the waitlist in Superlogical's [public testing announcement](https://www.superlogical.com/updates/public-testing-beginning) and authenticating with Discord in the [installation docs](https://www.superlogical.com/rex/docs/installation).

Superlogical says that once Rex reaches a stable public release, you'll be able to download it without sharing any contact information.

### Setting up `xterm-rex` terminfo and the SSH guard

One small setup step worth running right after installing Rex is `rex terminfo setup`.

Rex ships its own terminal type, `xterm-rex`, so modern terminal programs know every capability Rex supports. Before you install it, Rex falls back to `xterm-256color`.

Running `rex terminfo status` shows what is missing:

```bash
rex terminfo status
```

```text
term: xterm-256color (the xterm-rex entry is not installed on this host)
entry: xterm-rex is not installed here
ssh: /usr/bin/ssh (OpenSSH_9.9p2, LibreSSL 3.3.6)
guard: /Users/admin/.config/rex/ssh_config is missing
include: missing from /Users/admin/.ssh/config

Not ready: the xterm-rex entry is not installed for this account.
Fix it with: rex terminfo setup
```

When you run `rex terminfo setup`, Rex does 2 smart things at once:

```bash
rex terminfo setup
```

```text
installed xterm-rex in /Users/admin/.terminfo
wrote the ssh guard /Users/admin/.config/rex/ssh_config
added the Include line to /Users/admin/.ssh/config
verified: ssh sends TERM=xterm-256color to hosts without the entry
```

If you ever SSH'd into a Linux box from [Ghostty](https://flaviocopes.com/ghostty/) or Kitty, you know how annoying custom terminfo entries can be. `clear` or `vim` will complain about an unknown `TERM`.

Rex avoids this trap by writing an SSH guard file (`~/.config/rex/ssh_config`) and including it at the top of `~/.ssh/config`, so SSH will automatically downgrade `TERM` to `xterm-256color` for hosts that don't have `xterm-rex`.

When you want `xterm-rex` on a specific remote host, you run `rex terminfo host install user@host` and Rex installs the entry there, and remembers the host.

One caveat from the docs: the SSH guard uses OpenSSH's `SetEnv`, which requires OpenSSH 7.8 or newer (8.7+ for full fallback) and will break older clients like Ubuntu 18.04 or Amazon Linux 2.

## The macOS app experience

On macOS, Rex feels like a native app, not a web wrapper or a port.

The tab bar is at the top by default, like a browser, but you can move it to the left or right sidebar. You can choose between Apple's Liquid Glass chrome and a Classic style, pick from ~40 built-in dark and light themes, and import your existing Ghostty and iTerm2 color schemes.

Here is Rex on my MacBook Pro using the light theme with the left sidebar layout inside my `flaviocopes.com` repository:

![Rex on macOS in light mode with the left sidebar layout running fish inside the flaviocopes.com repo](https://images.flaviocopes.com/rex/mac-fish-sidebar.webp)

It also brings many quality-of-life features that solve many terminal multiplexer pain points:

- **Native scrolling and selection.** Scrollback (~64 MiB per terminal, roughly 100,000 lines at 80 columns), trackpad momentum scrolling, and text selection work natively without fighting a multiplexer inside the PTY.
- **Vim-style Copy Mode.** Press `Cmd+Shift+C` to enter keyboard copy mode with `h/j/k/l`, word motions (`w/b/e`), visual character/line/block selection (`v`, `V`, `Ctrl+V`), search (`/`, `?`), character find (`f`, `t`), numeric counts, and yank (`y`).
- **Floating panes and corner taskbar.** Press `Opt+Cmd+Enter` to pop any split pane out into a floating layer above your layout, or minimize floating panes into compact taskbar capsules (`Opt+Cmd+M`).
- **Browser-style focus history and Undo Close.** Jump backward and forward across panes, tabs, and sessions with `Opt+Cmd+[` and `Opt+Cmd+]`, or reopen an accidentally closed pane, tab, or session within one minute using `Cmd+Shift+T`.
- **Fast navigation and previews.** Use Command Palette (`Cmd+Shift+P`), Go to Anything (`Cmd+P`), Go to Directory (`Cmd+Shift+G`), Insert Path (`Ctrl+Cmd+I`), Quick Look (`Cmd+Y` on file paths or URLs on screen), and an experimental Quake-style global Quick Terminal.
- **File and photo insertion.** Drop or insert local photos and files directly into a remote terminal, and Rex uploads them through its filesystem block and types their remote path for you.
- **GPU polish.** Display P3 colorspace, font ligatures, variable font weights, smooth client-side reflow on resize, and optional cursor shaders (Warp, Sweep, Comet, Blaze, Tapered, Rainbow, Gradient, Frozen).

![Rex Command Palette with keyboard shortcuts and live rebinding](https://images.flaviocopes.com/rex/command-palette.webp)

Notice the footer at the bottom of the Command Palette in the screenshot above: you can press `Cmd+Return` on any command to rebind its keyboard shortcut right from the palette, without opening a config file.

![Rex Settings showing server status, update channel, Remote Control, and app icons](https://images.flaviocopes.com/rex/settings.webp)

Settings (`Cmd+,`) gives you a clean sidebar covering the local Server status, General (update channel, client label, Remote Control toggle, and 6 alternate app icons), Remote Hosts, Interface, Themes, Terminal, Shortcuts, Integrations, Notifications, and Developer.

## The Rex iOS app: driving sessions from your phone

One of the biggest reasons I'm getting excited about Rex is the native iOS and iPadOS client.

[Josh Pigford shared on X](https://x.com/Shpigford/status/2127154362166509833) after asking for the best way to reach his Mac mini from his phone over Tailscale: "okay so it's Rex (@superlogical) and i've now got it running on my MBP, Mac mini and iPhone and it's magical".

Unlike generic SSH apps where you manage fragile terminal sessions by hand, Rex on iOS attaches to your running Rex Servers on macOS, Linux, FreeBSD, or Windows.

You get the same tabs, split panes, floating panes, Activity panel, Command Palette, Ghostty/iTerm themes, and smooth terminal reflow.

Pairing my iPhone to my MacBook Pro took under two minutes. In Rex **Settings → Server**, I clicked **Sign in to Tailscale** and picked `macbook-pro-rex` as the preferred hostname:

![Rex Settings Sign in to Tailscale modal with preferred hostname macbook-pro-rex, optional tags, and custom control server field](https://images.flaviocopes.com/rex/mac-tailscale-setup.webp)

Even with the regular macOS Tailscale menu-bar app stopped on my Mac, Rex brought up its own embedded `tsnet` node, provisioned an HTTPS certificate on my tailnet, and locked access to my `flaviocopes@github` Tailscale account:

![Rex Server Settings showing Serve over Tailscale enabled for flaviocopes@github with the Pair QR button](https://images.flaviocopes.com/rex/mac-tailscale-server.webp)

Clicking **Pair** shows a QR code containing the tailnet address. Scanning it in Rex for iOS (`0.1.1`) prompted me to switch on Tailscale on the phone, then connected straight to `MacBook Pro`:

<div style="display: flex; flex-wrap: wrap; gap: 1rem">
<img src="https://images.flaviocopes.com/rex/ios-tailscale-pair.webp" alt="Rex for iOS Pair via QR Code screen prompting to connect to the same Tailscale network" width="260" height="543" />
<img src="https://images.flaviocopes.com/rex/ios-connected-host.webp" alt="Rex for iOS Connected to Host sheet naming the paired MacBook Pro server" width="260" height="543" />
</div>

Once paired, my live `fish ~/www/flaviocopes.com` terminal from the MacBook Pro appeared right on my iPhone in dark mode, complete with the customizable Key Bar, Virtual Arrow Joystick, and the Compose Input drawer (`Message rex-cli`) with a `+` button for uploading photos or files:

<div style="display: flex; flex-wrap: wrap; gap: 1rem">
<img src="https://images.flaviocopes.com/rex/ios-flaviocopes-live.webp" alt="Rex for iOS showing the live fish shell in ~/www/flaviocopes.com mirrored over Tailscale with the Key Bar and Virtual Arrow Joystick" width="260" height="543" />
<img src="https://images.flaviocopes.com/rex/ios-compose-input.webp" alt="Rex for iOS Compose Input sheet open over a live terminal with attachment and send buttons" width="260" height="543" />
</div>

The iOS client also adds features designed for touch screens and agent workflows:

- **Compose Input (`client.composer.open`).** A dedicated input sheet built for writing longer prompts to tools like Claude Code or Codex, complete with attaching photos from your library or files from the iOS Files app so Rex uploads them and inserts their paths into the remote session.
- **Customizable Key Bar and Shortcut Groups.** Reorder or hide keys like `Esc`, `Tab`, `Ctrl`, `Opt`, `Shift`, `Home`, `End`, `PgUp`, `PgDn`, and arrows. Add custom shortcut groups for `Ctrl` combos, function keys, or slash commands, plus a dedicated row for shell characters (`~`, `|`, `/`) and haptic feedback.
- **Virtual Arrow Joystick.** A touch joystick for navigating shell history, menus, and cursors, with separate repeat intervals for vertical (up/down) and horizontal (left/right) movement.
- **External keyboard tuning.** Full control over hardware key repeat, delay, and repeating held letters instead of popping up the iOS accent picker.
- **Built-in SSH keys and Secure Enclave.** Generate or import `ed25519` or `ecdsa` SSH keys inside Settings > Remote Hosts, including hardware-backed Secure Enclave keys, along with trusted host fingerprints and port forwarding.
- **One-scan Tailscale pairing.** Run `rex server tailscale pair` on your Mac or Linux server (or open Pair Device in Rex for Mac) to display a QR code containing your tailnet address, then scan it from iOS.
- **Remote control and diagnostics.** You can target your iPhone or iPad from the `rex` CLI by its client label, and Developer Mode includes a floating Network Diagnostics overlay showing Wi-Fi/cellular handoffs and reconnect state.

There are some differences between the iOS and macOS apps.

The iOS app is strictly a client: it does not run a local Rex Server, and it does not serve over Tailscale.

As of the current beta, it also does not have Copy Mode, Key Modes, Find, Quick Look, and focus history navigation.

## The `rex` CLI and self-documenting Server API

Everything you can click in Rex can be driven from the `rex` command line, and nearly every command accepts `--json`.

Inside any Rex terminal, Rex prepends `$REX_BIN_DIR` to your `PATH` and sets `REX_BLOCK` and `REX_SERVER` automatically.

If you want to check which server, socket, and identity you are connected to, run `rex whoami`:

```bash
rex whoami
```

```text
you: uid 501 over unix, acting as admin
endpoint: unix:///Users/admin/Library/Application%20Support/rex/server.sock
listener: unix:///Users/admin/Library/Application%20Support/rex/server.sock (unix, peer_credentials, primary)
pid: 91398
version: 0.1.0-preview.25
api: revision 24 (supports 0 to 24)
exit-empty: false
sessions: 1
tailscale: disabled
```

See how creating a session, renaming tabs, splitting panes, sending commands, and reading back screen contents all take one line each.

Here is the exact workflow I ran to build the 3-pane workspace I showed above:

```bash
# Create a session and get its JSON metadata
rex new work --json

# Rename the first tab and open two more tabs
rex window rename -s work 1 "api"
rex window new -s work "deploy"
rex window new -s work "tests"

# Split the first pane to the right, then split that pane below
rex split -s work --split=right --json
rex split -s work --split=below --json

# List sessions as structured JSON
rex ls --json
```

```json
{
  "sessions": [
    {
      "session_id": "session:01a22b80-4043-7130-8d34-b107fc669b60",
      "label": "work"
    }
  ]
}
```

You can send text and keystrokes to any pane, wait for a command to exit, capture the screen and scrollback in plain text, HTML or raw VT escape sequences:

```bash
# Type a command (rex send does not press Enter automatically)
rex send -s work -b rex-cli "rex version && rex window ls"
rex send-key -s work -b rex-cli enter

# Read back the pane contents
rex capture -s work -b rex-cli --trim
```

```text
rex 0.1.0-preview.25
commit: b070aae645f5cbfac65d65d031a8b712b2ebca36
built: 2026-11-25T21:59:11Z
api: revision 24 (supports 0 to 24)

#  LABEL   ID      BLOCKS  ACTIVE
1  api     380a81  3       *
2  deploy  50e848  1
3  tests   936dfc  1
```

Two details save a lot of scripting headaches.

First, target resolution follows a predictable order of 4 steps: full ID (`block:...`), case-insensitive label (`rex-cli`), 1-based tab index (`-w 2`, windows only), or a hex suffix of at least 4 characters (`98e116`).

Even better, passing a full `block:` ID where a session is expected (e.g. `-s "$REX_BLOCK"`) resolves to the session that holds that block, even if its tab was moved to another session.

Second, exit codes are consistent across the CLI: `0` for success, `1` for command failure or timeout, `2` for invalid flags, `3` for target not found or ambiguous, `4` for server unreachable, `130` for `Ctrl+C`.

And `rex wait` (plus `rex run --wait`) returns the child process's actual exit status.

### Built-in file copy, port forwarding, and remote links

Rex has native filesystem and tunnel blocks, and this means the CLI provides some networking utilities that you would normally have to wire through separate SSH sessions:

- **`rex cp [-r] SOURCE... DEST`**: Copies files or directories to or from a remote server (`:` for the current server, `host:` for a named host) as an atomic tar stream over `com.superlogical.fs`.
- **`rex forward new -L 8080:127.0.0.1:3000`** (or `-R` for reverse): Forwards TCP ports like `ssh -L` and `ssh -R`, automatically reconnecting on drops. Even nicer, `rex forward open <block>` inspects a terminal block's listening port and opens it in your local browser.
- **`rex open URL|FILE`** (Snapshot channel): Opens links or files on your connected client machine and automatically forwards `localhost` URLs, so you can set `BROWSER="rex open"` on a remote Linux server and OAuth callbacks open straight on your laptop.

### The self-documenting Server API

Underneath the CLI there's a full RPC control API (`api: revision 24` in the preview I tested).

You can inspect every method, its JSON input/output schemas, and examples, right from the terminal:

```bash
rex api list
rex api describe session.new_split
rex api call server.version
```

The server also serves the complete schema at `GET /api/help` and a Markdown version at `/llms.txt`.

Data streams (like live terminal bytes or `rex cp` tar transfers) open via a one-time expiring ticket from `data.connect` upgraded to a WebSocket at `/api/data`.

For security, sensitive server methods (`server.config_reload`, `server.stop`, `server.tailscale.*`, and macOS privacy methods) are strictly local-only and return HTTP `403` over TCP or Tailscale.

If you want a refresher on shell basics, pipes, and scripting before building CLI workflows around Rex, check the free [CLI Handbook](https://flaviocopes.com/ebooks/cli-commands-handbook/).

## Built for AI coding agents

Rex does not try to replace your coding agent.

Instead, it makes the whole terminal environment legible and controllable by agents.

### Built-in agent skill and startup hooks

Run `rex skill setup` (or trigger **Install Rex for Agents** from the Command Palette) and Rex installs 2 things into your supported coding agents:

1. A **skill** that teaches the agent how to use the `rex` CLI. Instead of shipping static instructions that go stale, the skill calls `rex skill show` dynamically, so upgrading Rex automatically updates what your agents know.
2. A **startup hook** (where supported) that injects your current `$REX_BLOCK` and session context at the start of each conversation, so the agent knows which pane it lives in without spending tokens guessing.

| Agent | `--agent` flag | Skill location | Startup hook location |
| --- | --- | --- | --- |
| **[Claude Code](https://flaviocopes.com/claude-code-guide/)** | `claude` | `~/.claude/skills/rex` | `~/.claude/settings.json` |
| **[Codex](https://flaviocopes.com/codex/)** | `codex` | `~/.agents/skills/rex` | `~/.codex/hooks.json` (approve via `/hooks`) |
| **[OpenCode](https://flaviocopes.com/opencode/)** | `opencode` | `~/.agents/skills/rex` | Not supported |
| **[Pi](https://flaviocopes.com/pi/)** | `pi` | `~/.agents/skills/rex` | Not supported |

You can pass `--project` to install into the current repository instead of your user account, `--dry-run` to preview changes, and `--session-naming` if you want agents to automatically rename the Rex session after the task they are working on.

If you want an agent to also drive the macOS or iOS interface itself (opening tabs in a specific window, toggling the sidebar, switching views) turn on **Remote Control** in Rex Settings, so `rex -C <client> do` can invoke client actions.

If you are building your own skills for coding agents, the [Agent Skills Handbook](https://flaviocopes.com/ebooks/agent-skills-handbook/) covers how skills and progressive disclosure work across tools.

### Machine-readable docs and Community MCP

Superlogical built their documentation site to be agent-friendly from day one:

- Append `.md` to any docs URL (or send `Accept: text/markdown`) for clean Markdown.
- Query `https://www.superlogical.com/rex/docs/search.json?q=...` for the top 10 matching sections as JSON.
- Fetch `https://www.superlogical.com/rex/docs/llms-full.txt` for the entire documentation in one file.
- Beta testers can connect to the read-only **Community MCP** server at `https://www.superlogical.com/rex/community-mcp` (authenticated via Discord OAuth 2.1), which exposes the docs, full `#changelog` history, and beta Discord discussions. Superlogical recommends naming that MCP server `superlogical` rather than `rex` so it does not collide with the `rex` CLI and skill.

If you want to learn more about MCP servers and OAuth in coding agents, check out the [MCP Server Handbook](https://flaviocopes.com/ebooks/mcp-handbook/).

## Two open terminal protocols: OSC 7501 and OSC 7577

This is my favorite technical part of Rex.

Instead of building proprietary plugins for every tool, and scraping screen text with regexes, Superlogical built 2 open, vendor-neutral terminal escape sequence protocols.

### Program Status Protocol (OSC 7501)

When you run 4 coding agents, a test watcher, and a deploy script in parallel, the hard part is knowing which pane is still working, which one finished, and which one is blocked waiting for you to approve a command.

**OSC 7501** lets any program report its live state to the terminal:

```text
ESC ] 7501 ; state=blocked:kind=permission:app=terraform:msg=<base64> ESC \
```

The protocol supports six `state` values:

| `state` | Meaning | Lifetime |
| --- | --- | --- |
| `idle` | At rest, waiting for the next instruction | Until replaced or cleared |
| `working` | Actively running (optional `progress=0..100`) | Drops on process exit or next shell prompt (OSC 133 `A`) |
| `blocked` | Needs user input (`kind=permission\|question\|auth`) | Drops on process exit or next shell prompt |
| `done` | Finished work, unread by the user | **Survives** process exit and shell prompt until seen |
| `error` | Failed and stopped | **Survives** process exit and shell prompt until seen |
| `clear` | Removes the addressed record (and its children) | Immediate |

A few details show how carefully this was thought through:

- **No heartbeats.** State lifetime ties to events the terminal already observes (process exit and OSC 133 `A` shell prompts). Programs do not have to spam keep-alives.
- **Hierarchical IDs.** Optional `id` paths like `build/test` let a parent program stay `idle` at its prompt while a child worker reports `blocked`, and clearing `build` clears all descendants.
- **Strict safety caps.** Total sequence max is 4,096 bytes, up to 256 records per terminal, `msg` and `title` are base64 UTF-8 with all control characters rejected, and there is no readback API so an untrusted program cannot snoop other records.
- **Feature detection.** Programs can send `OSC 7501 ; ? ST` paired with `CSI c` to discover supported states and kinds without waiting for a timeout.

I tested this live in Rex, emitting 3 OSC 7501 sequences in 3 different panes: one with a `working` Claude Code job at 65%, one with a `blocked` Terraform permission prompt, and one with a `done` Vitest run that exited immediately.

```bash
MSG=$(printf "Apply 3 to add, 1 to change, 0 to destroy?" | base64)
printf '\033]7501;state=blocked:kind=permission:app=terraform:msg=%s\033\\' "$MSG"
```

Then I queried that block back through the Rex CLI:

```bash
rex block call -s work -b deploy-job program_status
```

```json
{
  "records": [
    {
      "state": "blocked",
      "kind": "permission",
      "app": "terraform",
      "effective_app": "terraform",
      "msg": "Apply 3 to add, 1 to change, 0 to destroy?",
      "updated_at": "2026-11-30T08:12:06.790892Z",
      "owner": {
        "pid": 91990,
        "name": "zsh"
      }
    }
  ]
}
```

And here is what appeared immediately inside Rex's Activity popover (`Cmd+.`), grouped by priority (**Blocked**, **Working**, and **Done**) with recognized app icons for Terraform and Claude Code:

![Rex Activity popover grouping live OSC 7501 blocked, working, and done tasks](https://images.flaviocopes.com/rex/activity-panel.webp)

You can also subscribe to `terminal.program_status_changed` in Lua scripts, trigger macOS notifications, bounce tab indicators, show Dock badges, play activity sounds per status type, and more.

### Session Restore and Program Resume Protocol (OSC 7577)

A classic weakness of terminal multiplexers is what happens when the server restarts or your machine reboots: your tabs disappear, and your running agents are gone.

Rex handles restarts in layers, starting with its snapshot file (`servers/<id>/snapshot`, saved with `0600` permissions) that restores every session, tab, split layout, label, and working directory when the Rex Server restarts.

For programs running inside panes, Rex goes further with **OSC 7577**, the Program Resume Protocol.

Letting a terminal automatically execute a command from an escape sequence would normally be a huge security hole (imagine running `cat untrusted.log` and planting a malicious command to run on next reboot). OSC 7577 solves this with per-PTY cryptographic signing:

1. When Rex starts a terminal, it generates a random `OSC7577_TOKEN` (22–64 characters) and puts it only in that PTY's environment.
2. When a program wants to register a resume command, it sends `pid`, a Unix `time` (verified against a 60-second monotonic window), base64 `argv`, optional `cwd`, and a trailing `mac=<64-hex>` computed as `SHA256("<body_before_:mac=>:<OSC7577_TOKEN>")`.
3. Superlogical deliberately chose plain SHA-256 with the token appended at the end rather than HMAC, so shell scripts can compute the MAC via a shell builtin `printf` piped into `shasum -a 256` without leaking the token into `ps` command-line arguments.
4. Even with a valid MAC, Rex never blindly runs the command. It cross-checks the program against your `resume.trust.*` rules in `init.lua`, verifies the process matches the command, refuses processes wrapped inside sandboxes or `sudo`, and filters every CLI flag.

Here is the current built-in resume support documented by Rex:

| Program | Resumes automatically today | How it works |
| --- | --- | --- |
| **Claude Code** | Yes | Rex's hook (`rex skill setup`) reports `claude --resume <uuid>` and keeps safe flags |
| **Pi** | Yes (after 1.6.1) | Pi emits OSC 7577 natively for its session |
| **Codex, OpenCode, Gemini CLI, Copilot CLI, Crush** | Rule shipped, waiting on reporters | Rex ships trust rules; programs do not emit OSC 7577 yet |
| **Neovim** | Optional (<20 lines of Lua) | `SessionWritePost` autocmd emits OSC 7577 + `resume.trust.nvim` rule |
| **`ssh`, `htop`, dev servers** | Optional (`detect = true` rule) | Matches foreground process name without protocol support |

Rex also has some safety stops in place: it will not resume the program if it's running as `root` or Windows `SYSTEM`. It will never try to resume the same saved program twice (to avoid crash loops). You can inspect every record using `rex block call -b "$REX_BLOCK" program_resume_records`.

One important security detail mentioned in the docs: Rex currently stores the saved resume command (including any kept flags, like a system prompt) in plain text in its `0600` snapshot file. Superlogical plans to encrypt snapshots where a system key store is available.

You can discard the saved state at any time using `rex server stop --discard`, or skip the restore using `rex server run --restore=false`.

## Customizing and scripting Rex with Lua

Rex is configured with a single optional **Lua 5.1** file at `~/.config/rex/init.lua` (or `%AppData%\rex\init.lua` on Windows, which can be overridden by setting the `REX_CONFIG` environment variable).

It exposes the full Lua standard library (`io`, `os`, `require` so you can split your config into multiple files), except `io.popen` and `os.execute` are disabled in favor of Rex's non-blocking `rex.exec` and `rex.exec.start`.

Rex does not watch `init.lua` for edits. After changing it, you validate with `rex config check` and apply with `rex config reload` (which pushes updated bindings and actions to every connected client immediately, and keeps your last working config if there is a syntax error).

Here is a real `init.lua` I wrote and loaded in Rex combining tmux-style key sequences, an exclusive resize mode, tightened Claude Code resume rules, and a custom action with an interactive picker:

```lua
-- Tmux-style prefix sequences
rex.bind("ctrl+b>c", "client.tab.new")
rex.bind("ctrl+b>shift+5", "pane.split", { direction = "right" })
rex.bind("ctrl+b>shift+'", "pane.split", { direction = "down" })
rex.bind("ctrl+b>ctrl+b", "pane.send_key", { key = "ctrl+b" })

-- Exclusive key mode for resizing panes (Escape exits)
rex.mode("resize", { exclusive = true })
rex.bind("ctrl+b>r", "client.mode.enter", { name = "resize" })
rex.bind("resize/left", "pane.resize", { direction = "left", amount = 5 })
rex.bind("resize/right", "pane.resize", { direction = "right", amount = 5 })
rex.bind("resize/up", "pane.resize", { direction = "up", amount = 5 })
rex.bind("resize/down", "pane.resize", { direction = "down", amount = 5 })

-- Restrict Claude Code auto-resume to ~/code and strip skip-permissions
rex.set("resume.trust.claude.dir", "~/code")
rex.set("resume.trust.claude.flags.--dangerously-skip-permissions", "drop")

-- Custom action with an interactive picker inside the Command Palette
rex.action({
  name = "open_workspace",
  title = "Open Project Workspace",
  description = "Pick a project and open a 2-pane dev layout",
  category = "Workflows",
  run = function(ctx)
    local choice = rex.ui.pick({
      title = "Open project",
      placeholder = "Filter projects...",
      items = {
        { id = "flaviocopes", title = "flaviocopes.com", subtitle = "~/www/flaviocopes.com", icon = "globe" },
        { id = "shipyard", title = "Shipyard", subtitle = "~/dev/apps/shipyard", icon = "terminal" },
        { id = "note-repo", title = "Note Repo", subtitle = "~/dev/apps/note-repo", icon = "document" },
      },
    })
    if not choice then return end
    return { opened = choice }
  end,
})
```

Running `rex config check` will validate every binding, mode, action and resume rule, and will tell you the line number of any override:

```bash
rex config check && rex config reload
```

```text
path: /Users/admin/.config/rex/init.lua
exists: yes
bindings: 9
removals: 0
modes: 1
actions: 1
settings: 0
resume rules: 3
  claude (built in)
    command: claude --resume <uuid>
    dir: ~/code (init.lua:16)
    flags: 43 kept, 13 dropped
      --dangerously-skip-permissions dropped (init.lua:17)
  codex (built in)
    command: codex resume <uuid>
  opencode (built in)
    command: opencode --session <id>
generation: 3
```

### Custom UI inside the Command Palette

Look at `rex.ui.pick` (and its text sibling `rex.ui.input`) in the action above.

Custom Lua actions can pause mid-run and show native searchable pickers or text prompts right inside Rex's Command Palette, with up to 2,000 items, multi-select, free-text fallback (`allow_other`) and 16 built-in icons.

![Custom Lua picker rendered inside Rex's Command Palette with rex.ui.pick](https://images.flaviocopes.com/rex/custom-ui-picker.webp)

Even better, when an action calls `rex.ui.pick` or `rex.ui.input`, Rex will broadcast the prompt to every Rex app connected, on every device.

The first device that answers wins, and the prompt is dismissed everywhere else.

The time spent waiting for the user does not count towards the 30 seconds timeout of the action.

### Event-driven Lua scripts (`rex do`)

While `init.lua` is where you declare bindings, modes, actions, hosts, and resume rules at load time, you can also run standalone event-driven Lua scripts against a live server with `rex do ./watch.lua` or `rex do -e '...'`.

Scripts have access to `rex.on`, `rex.wait`, `rex.after`, `rex.every` (up to 1,024 concurrent timers), `rex.servers()`, `rex.server(label)` (to orchestrate multiple hosts) and 31 documented events across sessions, terminals and the server (`terminal.program_status_changed`, `terminal.pwd_changed`, `terminal.child_exited`, `terminal.bell`, `terminal.process_changed`, `session_created` and more).

Here is a short example that listens for any blocked program in a session, and logs its message:

```lua
rex.on("terminal.program_status_changed", function(ctx, ev)
  if ev.record and ev.record.state == "blocked" then
    rex.log("info", "Blocked in " .. ctx.block_id .. ": " .. (ev.record.msg or "needs attention"))
  end
end)
```

Run it across all sessions with `rex do ./watch-blocked.lua --all`.

## Running Rex servers on Linux, FreeBSD, and Windows

Most terminal apps stop at your laptop. Rex treats remote servers as first-class citizens.

Linux is supported through `.deb` and `.rpm` packages, and also on Arch, Alpine, NixOS/home-manager, or using `rex server install ssh://user@host`.

FreeBSD 14+ is supported through `.pkg` and `rc.d`.

Windows 10/11 is supported through WinGet, MSI, or Zip, shipping `OpenConsole.exe`.

```mermaid
flowchart TD
  accTitle: Choosing a Rex server mode and remote transport
  accDescr: Decision flow from machine type to Personal, Shared, or Login server mode, and from SSH or Tailscale to the right listener.
  A[Where is Rex Server running?] --> B[Single developer machine]
  A --> C[Multi-user Linux or FreeBSD host]
  B --> D[Personal server]
  C --> E{Separate OS accounts needed?}
  E -->|Yes| F[Login server with PAM and accounts.jsonc]
  E -->|No, shared team account| G[Shared server as rex user]
  D --> H[Connect via SSH or built-in Tailscale]
  F --> I[Connect via Tailscale Serve or tailnet address]
  G --> I
```

### Three server modes

Linux and FreeBSD support 3 server modes, while Windows supports Personal mode only.

| Mode | Runs as | Socket / Pipe | Sessions survive upgrade? | Best for |
| --- | --- | --- | --- | --- |
| **Personal** | Your OS user (reduced non-admin token on Windows) | `$XDG_RUNTIME_DIR/rex` or `\\.\pipe\rex-<SID>` | Yes (picks up new version on stop) | Laptop, Mac mini, single-user VPS |
| **Shared** | Locked `rex` system user (`rex` group) | `/run/rex/server.sock` (`0660`) | Ended and restored via snapshot | Shared lab box or pairing host |
| **Login** | `root` proxy spawning per-user servers via PAM | `/run/rex/login-server.sock` | Yes (per-account servers keep running) | Multi-user team servers |

The **Login Server** (`rex-login-server`) is surprisingly thoughtful for an early beta.

It reads a HuJSON policy file at `/etc/rex/accounts.jsonc` (hot-reloaded via `SIGHUP` without dropping active connections), and maps Tailscale identities or local UIDs to OS accounts.

It checks PAM (rejecting locked accounts, `/etc/nologin`, or `false` shells) and never allows `anonymous` callers to reach `root`.

### Remote access and authentication

Rex Server does not have its own password or SSH-key login system.

Instead, it authenticates callers by **how they connect**, so picking the right transport is important:

| Transport | Syntax / Listener | Identifies callers? | Notes |
| --- | --- | --- | --- |
| **SSH** (default recommendation) | `ssh://user@host` | Yes (OS SSH login) | Uses your local SSH keys and config; enable `loginctl enable-linger` on Linux so logout does not kill sessions |
| **Built-in Tailscale (`tsnet`)** | `--tailscale` | Yes (Tailscale user/tag) | No `tailscaled` needed; supports Headscale (`--tailscale-control-url`); owner-only by default |
| **Tailscale Serve** | `--extra-listen tailnet-serve://...` | Yes (Tailscale user, not tagged devices) | Great for Shared/Login servers behind HTTPS on port 443 |
| **Tailnet address** | `--extra-listen tailnet://:7297` | Yes (Tailscale user & tags) | Plain HTTP inside WireGuard-encrypted tailnet; works on Windows too |
| **Plain HTTP / custom VPN** | `--extra-listen http://10.0.0.5:7297 --allow-anonymous` | No (`anonymous`) | Bind a private VPN IP only, never `:7297` |

On Windows, both the Windows Service (`rex server install`) and background `rex server start` will automatically drop to a reduced non-admin token, even if installed by an Administrator account, unless you explicitly pass `--elevated`.

I talk more about setting up remote hosts and private mesh networking in my [SSH for developers](https://flaviocopes.com/ssh-for-developers/) guide, my [Tailscale tutorial](https://flaviocopes.com/tailscale/) and the [Linux Server Handbook](https://flaviocopes.com/ebooks/linux-server-handbook/).

## Privacy, telemetry, and pricing

Superlogical takes a clear position on this in their [public testing announcement](https://www.superlogical.com/updates/public-testing-beginning) and their [privacy reference](https://www.superlogical.com/rex/docs/reference/privacy):

- **Pricing:** "Rex is and will always be free." You do not need an account, you can self-host every server, and Superlogical says Rex clients and servers will not be directly monetized (their broader commercialization plan will be announced before the stable release).
- **Telemetry:** Rex collects zero usage analytics and has no crash reporting of its own.
- **Outbound network traffic:** By default, Rex Server makes zero outbound connections. On macOS, `Rex.app` checks Superlogical's signed Sparkle update feed at launch and once a day (sending only IP address and User-Agent like `Rex Beta/0.1.0 Sparkle/2.9.6`). On iOS, crash reports go through Apple or TestFlight only if enabled. Tailscale connects only if you turn it on.

Even the WinGet package source on Windows explicitly marks product codes and publishers unsupported so `winget list` does not leak your other installed Windows apps to Superlogical's servers.

## How I am using Rex, and where it is a poor fit

I now have Rex running on my MacBook Pro with `rex terminfo setup` and `rex skill setup` wired into Claude Code, Codex, OpenCode, and Pi, paired to my iPhone over its built-in Tailscale server. Next, I would add Rex Server to my Linux VPS so every machine shows up inside the same client.

That setup solves 3 things I run into all the time while maintaining `flaviocopes.com` and my macOS apps:

1. **Checking on long-running agents away from my desk.** With `rex skill setup` installed and OSC 7501 surfacing blocked permissions or finished runs in the Activity panel, I can start Claude Code or Codex on a Mac and approve a blocked step or inspect output from my iPhone using Compose Input.
2. **Surviving app updates and restarts.** Closing the terminal app never kills an active build or agent session, and `resume.trust.claude` rules let me safely auto-resume Claude Code inside my code directories while dropping `--dangerously-skip-permissions`.
3. **Scriptable project layouts.** One Lua action with `rex.ui.pick` can spin up a three-pane layout for a site build, log watcher, and agent shell without maintaining fragile shell scripts around tmux.

At the same time, Rex is not the right answer for everything today:

- **It does not replace a full agent control plane.** If you want inline Git diff reviews, PR review guides, embedded browser previews, and multi-provider chat threads in one window, [T3 Code](https://flaviocopes.com/t3-code/) still covers ground that a terminal multiplexer intentionally leaves out. I use Rex for terminal-native work and remote shells, and T3 Code when I want rich visual reviews.
- **It is still an invite-only preview beta.** Commands, flags, and API revisions move fast (several features like `rex open` and `--env` are Snapshot-only right now), and there is no Linux desktop client in testing yet.
- **No built-in user authentication yet.** If you cannot put your remote host behind SSH or Tailscale, Rex Server does not yet offer its own password or key-based auth.
- **No tmux config migration and closed source for now.** Your `.tmux.conf` does not import automatically, resume snapshots currently sit in plain text on disk, and while `libghostty` is MIT-licensed, Rex itself is not open source.
- **Overkill for single-shell work.** If you mostly open one local terminal window and never touch remote hosts or parallel agents, [Ghostty](https://flaviocopes.com/ghostty/) stays lighter, open source, and already stable.

If you spend your days juggling coding agents across a laptop, remote servers, and your phone, joining the waitlist is well worth it.
