I run my agents in Rex, the terminal multiplexer from Superlogical, the company led by Mitchell Hashimoto, who created Ghostty and co-founded HashiCorp. Their homepage states the plan in three lines: build an incredible multiplexer, make everything in it composable, make it safe and operable in production. Above the plan sits a sentence I keep coming back to. They want "a durable session around the work itself" that can "be driven by software while remaining visible and controllable by people."

That sentence is the agent problem in one line. The agent drives. I need to see what it's doing, and step in.

A lot of software right now is generated faster than anyone reads it. Rex reads like the opposite. Each primitive is small, has clear edges, and comes with docs that say what it refuses to do. This post walks through the primitives one at a time, with the commands that drive them, then shows the patterns they add up to. Everything here comes from the Rex docs and from running the commands myself on Rex 0.1.0-preview.20. Rex is in beta, so details will move.

1. The server holds the work

The server holds the workA pencil box labelled the Rex server holding three sessions. A laptop, a desktop, and a phone connect to it with thin lines. Underneath: apps come and go, the work stays on the server.the Rex serversession: blogsession: agentssession: opslaptopdesktopphoneapps come and go; the work stays on the server
Clients are windows onto the server. Close one and nothing stops.

Rex splits the terminal in two. A server owns every session, every pane, every running program and its scrollback. The apps on my Macs are clients. They draw what the server holds and send it my keys.

Close an app and nothing stops. Open one on another machine and you're looking at the same panes.

rex server status    # version, uptime, Tailscale state
rex ls               # the sessions on this server

The care shows at the edges. The app and the server don't have to run the same version, and when a client needs a newer server, the error names the feature that needs it. rex server stop --if-idle stops only when nothing is using the server, and it checks and stops in one step, so no client can slip in between.

The methods that change the server itself, such as reloading its config, stopping it or turning Tailscale on, answer only over its local socket. A client across the network can watch and type. It can't reconfigure the machine it's looking at.

2. Four nouns, and names that don't move

Four nounsA pencil diagram of a session box holding two tabs, called windows, and a layout of three blocks labelled claude, tests, and server, one with a long ID. Outside, an eye labelled client, an app looking in. A note: IDs never change, never get reused.session · a projectwindow: Codewindow: Logsblock: claudeblock:01a1…f9e5block: testsblock: serverclientan app looking inIDs never change,never get reused
Session, window, block, client. Everything in Rex is one of these four.

Everything in Rex is one of four things. A session is a project. A window is a tab. A block is a pane, usually a terminal. A client is an app or a script connected to the server. Each has an ID that never changes and is never reused, plus an optional label you choose. Labels are easy for people to type. IDs are what a script should hold on to.

When you name something, Rex looks for it in a fixed order: full ID, then label, then window position, then the end of an ID. It stops at the first step that matches anything. If that step matches two things, it refuses:

$ rex capture -b build
Error: block target "build" is ambiguous
  build  …086b2b  window 2
  build  …c4751a  window 3
$ echo $?
3

Exit code 3 means "not found or ambiguous", and nothing changed. That one refusal is what makes it safe to let an agent use labels. A tool that guessed would one day type into the wrong pane.

The exit codes are a small contract, so a script can tell what went wrong without reading the error text:

Code Meaning
0 It worked
1 It failed
2 The command line was wrong
3 The target wasn't found, or matched more than one thing
4 The server couldn't be reached
130 You interrupted it

3. Every terminal knows where it is

Every terminal Rex starts gets three variables: REX_SERVER, REX_SESSION and REX_BLOCK. Commands use them as defaults. Type rex split in a pane and it splits that pane. An agent running in a pane can act on its own pane, or the one beside it, without first asking where it is.

Rex finds a caller by its block, not its session, and the reason is a quiet detail. When a window moves to another session, programs already running in it keep the REX_SESSION they started with, which is now out of date. So when Rex works out where a caller is, it looks at the block first, because the block travels with its window. Someone thought that case through.

4. Hands and eyes

Hands and eyesTwo pencil panes. An arrow from your agent to block tests is labelled send, send-key. An arrow back is labelled capture. A small clock between them is labelled wait, returns the exit status.your agentblock: testssend, send-keycapturewait: returns the exit status
Type into any pane, read any pane, wait on any pane, by its address.

Five commands let one program drive another pane the way a person would:

rex run --split=below --ratio 30 --label tests --focus=false -- npm test
rex send -b tests 'npm test'     # types the text, doesn't press Return
rex send-key -b tests enter      # presses Return
rex capture -b tests --trim      # prints the screen and scrollback
rex wait --for 10m tests         # exits with the program's own status

Each is cut narrower than you'd expect, and each cut is on purpose. send types but doesn't submit, because typing and submitting are different acts. --focus=false lets an agent open a pane without taking your cursor. wait exits with the program's status, so rex wait tests && ./deploy reads like plain shell. It works on panes kept open after their program ends, and it folds statuses above 255 the way a shell does.

The docs are frank about the limits. send-key assumes a US keyboard layout, so use send when exact text matters. capture keeps about 64 MiB of scrollback, but a full-screen program draws on the alternate screen, which has no scrollback at all. If your agent needs a full-screen program's output, have it read the files that program writes, not its screen.

5. Programs say how they are

How Rex for Mac shows program statusA tab strip. agent-1 shows three working dots. build shows a progress pie at 60 percent. agent-2 is blocked and tests reported an error; each shows a dot with the program's own message. A Dock icon carries a badge of 2 for tabs that need you.each program says how it is; Rex decides how to show itagent-1workingno need to lookbuildworking, 60%progress as a pieagent-2blockeda dot and its messagetestserrora dot and its messageRex2Dock badgetabs that need you
Programs report their own state. Rex for Mac decides how to show it.

Rex implements the Program Status Protocol, OSC 7501. A program writes a short escape sequence to its own terminal to say how it is. The states are idle, working, blocked (on a permission, a question or a sign-in), done and error, with an optional message and progress. The docs give a shell function:

status() {
  printf '\e]7501;state=%s:msg=%s\e\\' "$1" "$(printf '%s' "$2" | base64 | tr -d '\n')"
}
status working "Syncing photos"

Claude Code already reports. While writing this, I asked the pane my agent runs in:

$ rex block call -b "$REX_BLOCK" program_status
{"records":[{"state":"working","app":"claude-code",
  "msg":"Verifying rex commands against local CLI", …}]}

The protocol works in any terminal, not just Rex, and reads like a standard, with hard limits and a security section. It shares state and leaves the drawing to the terminal. There's no heartbeat.

A done or error record outlives the program, so a result waits for you. A working record goes away when its process exits. I checked: the record was gone a moment after my test script ended.

Rex for Mac draws status at the edge of your attention. Tabs show working dots, a progress pie, or a dot with the program's own message when it needs you. The Dock badge counts tabs with a program that's blocked, failed or finished and that you haven't looked at. When Rex is in the background, a macOS notification takes you straight to the tab. Each state has its own switches, so you can keep working silent and let blocked make a sound.

6. Programs say how to come back

What comes back after a restartBefore a restart, three panes run claude, ssh devbox and vim. After the server restarts, claude comes back with --resume and its id because it reported how to resume and a rule trusts it; ssh devbox comes back because a detect rule names it; the vim pane comes back as a plain shell in the same directory.beforeclaude --model opusssh devboxvim notes.mdafterclaude --resume ‹id› --model opusit reported, and a rule trusts itssh devboxa detect rule names itzsh, same directorynothing trusted: a plain shellserver restartsupdate, crash, reboot
After a restart, a program comes back only if it said how and a rule trusts it.

Servers restart for updates, crashes and reboots. Rex saves every session and brings back the layout with its history. Bringing back the programs is harder, and this is where the design is most careful.

A second protocol, the Program Resume Protocol (OSC 7577), lets a program report the command that would bring it back, such as claude --resume <id>. The risk is plain: the terminal will later run that command as you, without asking.

So each pane gets its own random token. A report must carry a SHA-256 hash of its contents plus that token, and a timestamp within about a minute of the terminal's clock. Text you cat, a log you tail, or output from an ssh session can't plant a command. Each argument stays one argument, so $(reboot) is text and never shell code. Environment variables are never sent, because they go stale and may hold secrets. A resume that fails isn't tried again.

Rex adds its own trust rules on top. It ships rules for Claude Code, Codex and other agents, and you can narrow them:

-- ~/.config/rex/init.lua
rex.set("resume.trust.claude.dir", "~/code")
rex.set("resume.trust.claude.flags.--dangerously-skip-permissions", "drop")

The first line resumes Claude Code only under ~/code. The second is my favorite line in the docs. It brings Claude Code back without that flag, "so the resumed session has its permission checks again." Programs that never report, like ssh, can come back through a detect rule. Anything else returns as a plain shell in the same directory. rex config check lists every rule in force and the line that changed it, and a typo comes back as unknown action "keeep" (did you mean "keep"?).

The docs also say plainly that a saved command can hold a secret, in plain text, and that they plan to encrypt these files. I trust a tool more when it tells me that.

7. Events, actions and questions

One question on every deviceAn action calls rex.ui.pick to ask which branch. The question opens on a laptop, a desktop and a phone at once. It is answered on the laptop and the action carries on; the prompt closes on the other two.an action asks: rex.ui.pick"Which branch?"answered herethe action carries onprompt closesnothing to doprompt closesnothing to do
One question goes to every app. The first answer wins, and the rest close.

Everything that happens in Rex is an event: a pane opens, a directory changes, a program exits, a status changes. You can stream them with rex events -s work --json, or handle them in Lua. This script from the docs turns a bell in any terminal, in any session, into a macOS notification that names the session:

-- notify.lua
local function notify(title, text)
  rex.exec{
    "osascript", "-e",
    string.format("display notification %q with title %q", text, title),
  }
end

rex.on("terminal.bell", function(ctx, ev)
  local view = rex.session.view{}
  notify("Rex", "Bell in " .. view.label)
end)

Run it with rex do notify.lua --all, and every bell becomes a notification.

Actions are named commands you define in init.lua with rex.action. They appear in the command palette, take keys, and run from the CLI with rex do. An action can stop partway and ask a question with rex.ui.input or rex.ui.pick. The question opens in every connected app at once. The first answer wins and the prompt closes everywhere else, and a cancel on any device cancels it on all of them.

Under all of this sits an API that describes itself. rex api list shows every method the server offers, 96 on mine, and rex api describe gives each one's schema. The CLI and Lua are built on the same methods. Events carry sequence numbers with no gaps. If a listener falls more than 8 MiB behind, the server closes its connection rather than quietly drop events.

Agents get their own on-ramp. rex skill setup installs a skill and a session hook into Claude Code, Codex, OpenCode and Pi. Each agent then starts knowing which pane it's in and how to drive the rest.

8. Reach

My setupInside my tailnet, the main MacBook Pro runs the Rex server with built-in Tailscale, and the agents run there. A second MacBook Pro and a Mac Studio connect to it as clients with my Tailscale login.my tailnetmain MacBook ProRex server and built-in Tailscale; agents run hereMacBook Proa clientMac Studioa clientmy Tailscale loginmy Tailscale loginonly the login that signed the server in can connect
The agents run on one machine. Every other machine is a window onto it.

Other machines can reach a server over SSH, which the docs recommend first, or over Tailscale. With built-in Tailscale, the server joins your tailnet as a device of its own, even on a machine without Tailscale installed:

rex server start --tailscale   # in the Mac app: Settings › Server › Tailscale
rex server status              # shows the sign-in link the first time
rex client ls                  # the PRINCIPAL column shows who each client is

It's off until you turn it on. By default, only the Tailscale user who signed the server in can connect. There's deliberately no way to pass an auth key on the command line, where it would show in the process list. Rex refuses a plain HTTP listener unless you add --allow-anonymous. The docs call that "super dangerous." The privacy page lists every connection Rex makes, and there's no telemetry.

My setup: a window onto long-running agents

The server runs on my main MacBook Pro with built-in Tailscale on. A second MacBook Pro and a Mac Studio connect to it as clients over my tailnet. The agents run in sessions on the main machine, five of them as I write this, some for hours.

What changed is that I stopped going to my agents. They stay put, and every machine I sit at is a window onto them.

From the Studio I see the same panes, the same scrollback and the same status dots I'd see on the laptop. When an agent blocks, its tab shows its own message, and I answer from whichever keyboard is closest. The agent never knows I moved. If the server restarts, Claude Code comes back in the same conversation.

What the primitives add up to

Pattern What it feels like Built from
Glance, don't babysit You see which agent needs you without opening it Status protocol, tab dots, Dock badge, sounds
Walk away, come back anywhere The work keeps going, and any machine picks it up Server, clients, Tailscale
Answer from where you are A question reaches every device, and the first answer counts rex.ui.pick, status messages
The agent sets up the desk Panes open beside you without taking your cursor run, split, --focus=false, labels
Survive the restart Programs come back, with the checks you chose OSC 7577, trust rules
Script your habits One key builds a layout or routes an alert Actions, events, rex do
Take back a close A closed pane comes back, still running Undo Close, ⇧⌘T

Undo Close is the smallest pattern, and my favorite. Close a pane by mistake and Rex keeps its program running, out of sight, for about a minute. ⇧⌘T puts it back.

Why it doesn't feel vibe-coded

You can't see how software was made. You can see what its makers paid attention to. In Rex, it shows in a few places.

  • It refuses to guess. An ambiguous target fails with exit code 3 and lists the candidates.
  • Failures are a contract. Six documented exit codes, the same across the CLI.
  • The protocols are written for everyone. Both read like standards, with threat models, hard limits and no Superlogical-specific terms.
  • Mistakes point at the line. Config errors name the line and suggest the fix.
  • The docs admit what's missing. rex resize isn't implemented yet. Saved commands aren't encrypted yet. The login server for Linux has no passwords yet, and the docs say to use Tailscale until it does.

The agent drives. I can see everything it does and step in from any machine I'm at. That's the sentence from their homepage, built one small piece at a time.