Drive the Rex terminal multiplexer: tabs, panes, splits, and hosts. Load this when opening a file or web page alongside the user, starting a dev server or log tail the user should watch, reading another terminal's output, running a command on a saved host, or asking what else is running. Tab, pane, split, and host are Rex's terms. In a session Rex hosts, a request that uses one is a Rex request even when it never says Rex. New PR-bound work goes to `dispatch:dispatch`.
$npx -y skills add bendrucker/claude --skill rex --agent claude-code
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Rex?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/bendrucker-rex)
---
name: rex
description: >-
Drive the Rex terminal multiplexer: tabs, panes, splits, and hosts. Load this when opening a file or web page alongside the user, starting a dev server or log tail the user should watch, reading another terminal's output, running a command on a saved host, or asking what else is running. Tab, pane, split, and host are Rex's terms. In a session Rex hosts, a request that uses one is a Rex request even when it never says Rex. New PR-bound work goes to `dispatch:dispatch`.
argument-hint: "[orient | view <file> | read <block>]"
allowed-tools:
- 'Bash(bun "${CLAUDE_SKILL_DIR}/scripts/orient.ts")'
- Bash(rex session inspect:*)
- Bash(rex window ls:*)
- Bash(rex block ls:*)
- Bash(rex capture:*)
- Bash(rex hosts list:*)
- Bash(rex api call -s * session.float_block:*)
- Bash(rex api call -s * session.set_layer_state:*)
- Bash(rex --help:*)
- Bash(rex split --help:*)
- Bash(rex window new --help:*)
- Bash(rex wait --help:*)
- Bash(rex send --help:*)
- Bash(rex capture --help:*)
---
# Rex
Rex hosts this session's tabs and panes. A tab is a window and a pane is a block. For general mechanics (IDs, flags, client actions), run `rex __internal skill`.
## Current Session
!`bun "${CLAUDE_SKILL_DIR}/scripts/orient.ts"`
One line per tab, then one per block: ID, label, foreground cwd, and program. `*this*` marks the block running this session. If it prints a failure instead of a listing, stop here and use ordinary tools.
## Splits
Default to a sibling split of this pane that leaves focus where it is:
```bash
rex split --split=right --focus=false -c <cwd> --json
```
Rex scopes every command to this session and anchors splits on this pane from `REX_BLOCK`, which names this pane's block. Rex no longer sets `REX_SESSION` in new terminals, so take this session's ID from the listing above or `rex whoami --json`. Write each argument literally: `<cwd>` is the absolute working directory, and `<block>` is a block ID. A worktree session refuses a `rex` command that contains a shell variable. Add `-s <session>` only to target another session.
Split `right` on a wide pane and `below` on a tall one, alternating direction across successive splits. A new tab, session, or host needs the user to ask for it. Take the new block from `.block_ids[0]`.
Close a block with `rex block close <block>`, and only blocks you opened. A pane you split for the user to read counts as theirs.
## Collaborative File Viewing
Open the file beside this pane so the user watches it change. Use `mdd` for markdown and `$EDITOR` for everything else:
```bash
rex split --split=right --ratio 40 --focus=false -c <cwd> --json -- mdd path/to/file.md
```
Confirm the viewer started before telling the user to look at it:
```bash
rex capture -b <block> --trim --unwrap
```
`mdd` draws the body as images, which a capture cannot show. A running viewer shows only its status line, such as `file.md ? help / find t toc e edit 0%`.
## Web Pages
Show a web page, a local dev server, or rendered HTML beside this pane with `terminal-browser`:
```bash
terminal-browser open <url|port|file.html> --split right
```
It splits this pane from `REX_BLOCK`, or opens a new tab when a browser pane already sits beside it. To drive the page, load the `terminal-browser` skill.
## Long-Running Processes
Put a dev server, log tail, build, or REPL the user should watch in a sibling split instead of `run_in_background`:
```bash
rex split --split=below --ratio 30 --focus=false -c <cwd> --json -- bun run dev
```
Reserve `run_in_background` for work the user has no reason to see. `rex wait <block> --for 120s` blocks until the process exits and returns its status. To wait for a line of output, run a `Monitor` until-loop over `rex capture`.
## Reading Another Pane
Read with `rex capture -b <block> --trim --unwrap`. A block ID lasts only as long as its pane, so take IDs from the listing above or a fresh `rex block ls`.
Inside a Rex pane, `-b` resolves only within this pane's session, even for a full block ID. Add `-s <session>` to `capture`, `send`, or `send-key` for a block in another session.
The `❯` line at the bottom of a Claude pane shows Claude Code's own prompt suggestion, ghost text the harness wrote rather than input the user typed. Take a pane's content from above that line and leave the line out of what you report.
## Sessions
Move a tab to another session with `rex window move <window> --to <session>`. Its panes keep running with their scrollback. Move a tab you opened, or one the user asks you to move. A pane moves with its tab.
To give one pane a tab of its own, open a placeholder tab, move the pane beside the placeholder's block, then close that block:
```bash
rex window new -s <session> <label> --focus=false --json
rex block move -s <session> <block> right <placeholder-block>
rex block close -s <session> <placeholder-block>
```
Keep at most 4 tiled panes visible in a tab. Float an extra pane, then minimize its layer:
```bash
rex api call -s <session> session.float_block '{"block_id":"<block>","bounds":[0.2,0.15,0.6,0.7]}'
rex api call -s <session> session.set_layer_state '{"layer_id":"<layer_id>","state":"minimized"}'
```
Take `<layer_id>` from the first call's `layer_id`.
## Machines
Put `-S <label>` on every command that touches a saved host. Commands run on that machine, so paths and programs must exist there. When a command fails to connect, report "host `<label>` is unreachable".
Run a one-off command on a saved host through Rex rather than `ssh`, then read its output and close the block:
```bash
rex -S <label> run --wait --keep-open --focus=false -c <cwd> --json -- <command>
rex -S <label> capture -b <block> --trim --unwrap
```
After starting a server on another host, open it on this machine with `rex -S <label> forward open <block>`. Rex forwards a local port to the port the server's terminal listens on and opens the URL.
When more than one Rex app is connected, client actions such as `rex do` need `-C <client>`, a label from `rex client ls`.
## Peers
Talk to Claude sessions with `SendMessage` and `ListAgents`. Reserve `rex send` and `rex send-key` for non-Claude programs, keys the user asked for, and Claude sessions on another host. Read another session's approval dialog and hand it to the user, who answers it.
`SendMessage` reaches only Claude sessions on this machine. To message one on another host, type into its pane, then submit:
```bash
rex -S <label> send -b <block> '<text>'
rex -S <label> send-key -b <block> enter
```
A sandboxed `rex -S` call needs the host's endpoint from `rex hosts` in `allowed_domains` on both `:443` and `:7297`. Rex dials both, and which one answers depends on how the host serves.
## Worktrees
`worktrunk:wt-switch-create` re-roots this session. New PR-bound work goes to `dispatch:dispatch`, which defaults to Rex when run inside Rex.