Receber por email
← Voltar para o catálogo

cmux

Built-in CLI help output

185estrelas
Atualizado há 4 meses

Ver no GitHub ↗ Licença: MIT

Como adicionar

/plugin marketplace add AbsolutelySkilled/AbsolutelySkilled

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Para o autor da skill

Cole no README do seu repo

Mostra que sua skill está catalogada na Skillteca, gera backlink e tráfego rastreável.

[![Skillteca](https://www.skillteca.com.br/api/badge/cmux/svg)](https://www.skillteca.com.br/skills/cmux)

Alerta por categoria

Receba novas skills de Design e Frontend toda segunda

1 email curto, só com as skills novas de Design e Frontend. 4 minutos de leitura, sem spam, cancela com 1 clique.

Você confirma o email no primeiro envio. Sem spam. Cancela com 1 clique.

Ler descrição completa

When this skill is activated, always start your first response with the 🧢 emoji.

cmux

cmux is a terminal multiplexer controlled via a Unix socket CLI. It manages windows, workspaces, panes, and surfaces. AI agents use it to spawn isolated terminal panes for parallel tasks, send commands, read output, and clean up when done.

All commands use cmux [--json] <command> [options]. Always pass --json when parsing output programmatically. References use short refs like pane:5, surface:12, workspace:3 - or UUIDs.

When to use this skill

Trigger this skill when the user or agent needs to:

  • Spawn split panes for sub-agent tasks or parallel work
  • Send commands or keystrokes to a specific terminal surface
  • Read screen content from a pane/surface
  • Create, list, close, or manage workspaces
  • Open browser surfaces alongside terminal panes
  • Orchestrate multi-pane layouts for subagent-driven development
  • Rename, reorder, or move surfaces/panes between workspaces

Do NOT trigger this skill for:

  • General shell scripting unrelated to cmux
  • tmux or screen commands (cmux has its own protocol)

Environment variables

cmux auto-sets these in every terminal it creates:

| Variable | Purpose | |---|---| | CMUX_WORKSPACE_ID | Default --workspace for all commands | | CMUX_SURFACE_ID | Default --surface for commands | | CMUX_TAB_ID | Default --tab for tab-action/rename-tab | | CMUX_SOCKET_PATH | Override socket path (default: /tmp/cmux.sock) |

These mean most commands work without explicit IDs when run inside cmux.

Core concepts

Window - a top-level OS window. Most users have one. List with cmux list-windows.

Workspace - a tab within a window. Each workspace has its own pane layout. Create with cmux new-workspace, select with cmux select-workspace.

Pane - a rectangular split region within a workspace. A pane contains one or more surfaces (tabs). Create with cmux new-pane --direction <dir>.

Surface - the actual terminal (or browser) instance inside a pane. Each surface has a ref like surface:42. This is what you send commands to and read output from.

Ref format - short refs like pane:5, surface:12, workspace:3. Pass --id-format uuids for UUID output, --id-format both for both.

Common tasks

Identify current context

cmux --json identify

Returns caller's surface_ref, pane_ref, workspace_ref, window_ref. Use this to know where you are before creating splits.

Create a split pane (most common for subagents)

# Split right (vertical split, new pane on right)
cmux --json new-pane --direction right

# Split down (horizontal split, new pane below)
cmux --json new-pane --direction down

# Split in a specific workspace
cmux --json new-pane --direction right --workspace workspace:3

Returns the new pane's ref and its surface ref. Save the surface ref to send commands to it later.

Send a command to a surface

# Send text (does NOT press Enter)
cmux send --surface surface:42 "npm test"

# Send text + Enter (press Enter after)
cmux send --surface surface:42 "npm test"
cmux send-key --surface surface:42 Enter

# Or combine in one shell call
cmux send --surface surface:42 "npm test" && cmux send-key --surface surface:42 Enter

Read screen output from a surface

# Current visible screen
cmux read-screen --surface surface:42

# Include scrollback buffer
cmux read-screen --surface surface:42 --scrollback

# Last N lines
cmux read-screen --surface surface:42 --lines 50

Close a surface (clean up after subagent)

cmux close-surface --surface surface:42

List panes in current workspace

cmux --json list-panes

List surfaces in a pane

cmux --json list-pane-surfaces --pane pane:5

Focus a specific pane

cmux focus-pane --pane pane:5

Subagent workflow pattern

The primary use case for AI agents. Spawn panes, run tasks, read results, clean up.

# 1. Identify where we are
CALLER=$(cmux --json identify)

# 2. Create a split pane for the subagent task
RESULT=$(cmux --json new-pane --direction right)
# Parse the surface ref from RESULT

# 3. Send command to the new surface
cmux send --surface <new-surface-ref> "cd /path/to/project && npm test"
cmux send-key --surface <new-surface-ref> Enter

# 4. Wait, then read the output
cmux read-screen --surface <new-surface-ref> --scrollback --lines 100

# 5. Clean up when done
cmux close-surface --surface <new-surface-ref>

For parallel subagents, repeat steps 2-5 for each task, using different directions (right, down) to create a grid layout.

Workspace management

# List all workspaces
cmux --json list-workspaces

# Create a new workspace
cmux --json new-workspace

# Create workspace with a startup command
cmux new-workspace --command "cd ~/project && code ."

# Select/switch to a workspace
cmux select-workspace --workspace workspace:3

# Rename a workspace
cmux rename-workspace --workspace workspace:3 "My Task"

# Close a workspace
cmux close-workspace --workspace workspace:3

# Get current workspace
cmux --json current-workspace

Sending keystrokes

# Common keys
cmux send-key --surface surface:42 Enter
cmux send-key --surface surface:42 Escape
cmux send-key --surface surface:42 Tab
cmux send-key --surface surface:42 "ctrl+c"
cmux send-key --surface surface:42 "ctrl+d"
cmux send-key --surface surface:42 Up
cmux send-key --surface surface:42 Down

Notifications

cmux notify --title "Task Complete" --body "All tests passed"
cmux notify --title "Error" --subtitle "Build failed" --body "See surface:42"

Error handling

| Error | Cause | Resolution | |---|---|---| | Socket not found | cmux app not running or socket path wrong | Start cmux app or check CMUX_SOCKET_PATH | | Surface not found | Surface was closed or ref is stale | Re-list surfaces with cmux --json list-panes | | Workspace not found | Workspace was closed | Re-list with cmux --json list-workspaces | | Auth failed | Socket password mismatch | Set CMUX_SOCKET_PASSWORD or use --password |

Gotchas

  1. Stale surface refs after workspace close - If a workspace is closed (by the user or another agent), all surface refs from that workspace become invalid. Subsequent commands using those refs return "Surface not found". Always re-list with cmux --json list-panes before sending commands to a surface that was created more than a few minutes ago.
  1. send does not press Enter - cmux send --surface <ref> "command" types the text but does not execute it. You must follow with cmux send-key --surface <ref> Enter. Missing this step leaves commands typed but not run, causing read-screen to show input but no output.
  1. read-screen without --scrollback misses completed output - Once a long-running command finishes and its output scrolls off the visible terminal area, read-screen without --scrollback returns only what's currently visible - potentially just a shell prompt. Always use --scrollback when reading the result of a command that may have produced more output than one screen.
  1. Socket path mismatch in nested environments - When running cmux commands from inside a cmux-spawned terminal, the CMUX_SOCKET_PATH env var is set automatically. But if you spawn a subshell or use sudo, the variable may not propagate. Always pass --socket-path explicitly or verify the env var is inherited when running cmux from non-standard shell contexts.
  1. Closing the wrong surface - cmux close-surface closes the surface (terminal tab), not the pane. To remove a pane from the layout entirely, close all surfaces in it first, then the pane collapses. Calling close-surface on the wrong ref silently removes a still-needed terminal - always verify the ref with cmux --json list-pane-surfaces before closing.

References

Fo

Compartilhar X LinkedIn