# Muxy CLI

The `muxy` command talks to the [server](server.md) from a shell. It manages
projects, terminal sessions, worktrees, server settings, and phone access. No
desktop app is needed, so it works on Linux and over SSH too.

Commands work with what the server owns: projects and sessions. Tabs, panes, and
workspaces belong to each app, so there are no commands for them. Browser tabs
are the exception: they live in the desktop app, and `muxy browser` talks to
the app on this computer. The [terminal UI](terminal-ui.md) is an app of its
own, with its own layout.

## Install

- **With the desktop app:** choose **Install Command Line Tool…** from the app
  menu. It links `~/.local/bin/muxy` to the copy inside the app.
- **On its own:** see [Getting started](../user-guide/getting-started.md#cli-and-server-only).

Make sure `~/.local/bin` is on your `PATH`.

## Basics

```bash
muxy                 # open the terminal UI
muxy .               # open this folder in the desktop app or the terminal UI
muxy project list    # list projects
muxy ls              # list live terminal sessions
muxy --help          # grouped command overview
muxy help session send  # help for one subcommand
```

- Commands start the server they use if it isn't running, including a remote
  one with `--host`. `muxy server status` and `muxy server stop` never start
  it.
- Management commands take `--json` for machine-readable output, except
  `muxy mobile`. Existing JSON shapes are unchanged.
- On a terminal, lists have headers and aligned columns, or labeled records
  when the terminal is too narrow. Empty lists explain what is missing.
  Piped output keeps the original formats: TSV lists, JSON server/settings
  output, and bare IDs from creation commands. Terminal captures and program
  output remain unformatted. `NO_COLOR=1` disables help and table colors.
- `project list`, `session list`, and `worktree list` accept `--quiet` (`-q`)
  for one ID per line. Worktree lists omit unregistered worktrees in this mode.
  `--quiet` cannot be combined with `--json`.
- Ending or discarding a session and deleting a project or worktree need
  `--yes`.
- A project can be named by its ID, its name if unique, or its folder.
- `--host <destination>` runs the command against the server on another
  computer. It must come first: `muxy --host devbox project list`. See
  [Remote servers](remote-servers.md).

## Commands

| Command | What it does |
| --- | --- |
| `muxy` | Opens the [terminal UI](terminal-ui.md). |
| `muxy <folder>` | Opens a new terminal in the folder's project in the desktop app, adding the project if needed. Over SSH, or without the desktop app, opens it in the terminal UI. |
| `muxy server start\|status\|stop` | Starts, inspects, or stops the server. `stop` refuses while terminals run; add `--force` to end them. |
| `muxy project list\|inspect\|add\|rename\|set-color\|set-icon\|delete` | Manages projects. Deleting ends its terminals but keeps files on disk. |
| `muxy session list\|inspect\|rename\|create\|send\|send-keys\|read-screen\|history\|search\|wait\|end\|discard\|show\|link` | Creates and names terminals, inspects live or saved sessions, sends input, reads output, waits for text or exit, shows a terminal in the desktop app, and prints a [link](#session-links) that opens it. |
| `muxy worktree list\|create\|checkout-pr\|register\|remove` | Manages Git worktree projects, including checking out pull requests. |
| `muxy settings get\|set` | Reads or changes [server settings](server.md#settings). |
| `muxy config list\|get\|set\|unset\|reload` | Reads or changes the desktop app's settings on this computer and applies them to the running app. See [App settings](#app-settings). |
| `muxy activity list\|ack` | Reads or clears [AI agent](ai-agents.md) activity. |
| `muxy browser open\|list\|read\|click\|…` | Drives browser tabs in the desktop app on this computer. See [Browser control](#browser-control). |
| `muxy extension list\|status\|logs\|load\|enable\|disable\|reload\|unload\|validate\|publish\|dev\|pages\|open\|run\|emit\|page` | Manages, develops, and tests extensions in the desktop app on this computer. See [Extension commands](#extension-commands). |
| `muxy status <state> [--app APP] [--msg TEXT]` | Tells the terminal what a script is doing (OSC 7501): `idle`, `working`, `done`, `blocked`, `error`, or `clear`. Needs no server. |
| `muxy exec <project> -- <program> [args]` | Runs a program in the project folder, without a shell. |
| `muxy git`, `muxy files` | Run raw server Git and file actions as JSON. Advanced; the JSON shape follows the protocol and may change. |
| `muxy mobile` | Turns on phone access, pairs phones, and turns push notifications on or off with `muxy mobile push on\|off` (off on a new computer until you turn them on), and resets one phone's with `muxy mobile push reset <id>`. See [Mobile](mobile.md). |
| `muxy install-skills` | Installs the Muxy CLI skill for the AI agents found in your home folder. `--dir <path>` adds another skills folder. |
| `muxy stdio` | Joins stdin and stdout to the server. Used by `--host` over SSH; you don't run it yourself. |

## Short commands and shell completion

These aliases accept exactly the same arguments as their longer forms:

| Alias | Full command |
| --- | --- |
| `muxy ls` | `muxy session list` |
| `muxy new` | `muxy session create` |
| `muxy send` | `muxy session send` |
| `muxy send-key` | `muxy session send-keys` |
| `muxy capture` | `muxy session read-screen` |
| `muxy wait` | `muxy session wait` |

`muxy help session create` and `muxy session create --help` show the same
command-specific usage. Running a management group without a subcommand
shows its help. Help, version and completions never connect to a server.
Use `./ls`, for example, to open a folder named like an alias.

Generate completions for command names, nested subcommands and options:

```bash
eval "$(muxy completion bash)"  # Bash
source <(muxy completion zsh)   # Zsh, after autoload -Uz compinit; compinit
muxy completion fish > ~/.config/fish/completions/muxy.fish
```

Add the appropriate eval or source line to your shell startup file. Completions use
this installed CLI's command catalog, not a running server, and do not fetch
live project or session IDs.

## Extension commands

These talk to the desktop app on this computer and start it if needed, so they
don't take `--host`. [Agents building extensions](../extensions/agents.md) use
them too.

| Command | What it does |
| --- | --- |
| `muxy extension list [--json]` | Lists extensions with their version, state, source, and folder, then any load errors. |
| `muxy extension status <name> [--json]` | Shows one extension, its load errors, and recent log lines. |
| `muxy extension logs <name> [--lines N]` | Prints recent log lines. The default is 100. |
| `muxy extension load <folder>` | Loads an unpacked folder, disabled. Loading a folder that is already loaded reloads it. |
| `muxy extension enable <name>`, `disable <name>` | Turns an extension on or off. |
| `muxy extension reload <name>` | Restarts one extension from its folder. If the folder no longer loads, or its package name changed, it prints why and the running copy stays. |
| `muxy extension unload <name>` | Forgets an unpacked folder and keeps its files. It doesn't work on marketplace extensions. |
| `muxy extension validate <name\|folder> [--json]` | Checks what publishing needs, including the GitHub CLI, and exits nonzero if something is missing. |
| `muxy extension publish <name> [--json]` | Opens a [pull request to the store](../extensions/contributing.md#publish-from-muxy), after you approve it in the app. |

### Developing and testing

| Command | What it does |
| --- | --- |
| `muxy extension dev <folder> [--once]` | Loads and turns on an unpacked folder, then builds it (`npm run build`, or the package manager its lock file names) and reloads it whenever its files change. Each round prints `ready` or `failed` with the log lines it added. `--once` does one round and exits nonzero if it failed. |
| `muxy extension pages <name> [--json]` | Lists the extension's open pages: page ID, kind, ID, panel instance, whether it loaded, whether it shows, and its title. |
| `muxy extension open <name> panel:<id>\|tab:<type>\|modal:<entry> [--data JSON]` | Opens a panel, tab, or modal page, waits for it to load, and prints its page ID. |
| `muxy extension run <name> <command>` | Runs one of the extension's commands, as the command palette does. |
| `muxy extension emit <name> <event> [payload]` | Sends the extension an event its manifest lists, with a JSON object payload, to test how it reacts. |
| `muxy extension page <action> <page-id> …` | Drives a page with the [browser](#browser-control) page actions: `read`, `screenshot [--out FILE]`, `eval`, `click`, `type`, `fill`, `press`, `select`, `hover`, `scroll-into-view`, `check`, `uncheck`, `is`, `wait`, `wait-for`, `get-text`, `get-html`, `get-value`, `get-attribute`, `get-count`, `find`, `snapshot`, and `storage get\|set\|clear`. |

```bash
muxy extension dev extensions/hello --once
page=$(muxy extension open hello panel:hello)
muxy extension page snapshot "$page"
muxy extension page click "$page" "#hi"
muxy extension page wait "$page" --text "Sent"
muxy extension page screenshot "$page" --out hello.png
```

A call that needs the user to answer a [runtime prompt](../extensions/permissions.md#runtime-prompts)
waits for them: the extension's log says so, and `status` counts the prompts
still waiting. Nothing here answers them or changes what an extension may do.

## App settings

```bash
muxy config list                          # every setting, defaults included
muxy config get terminal                  # one table, as TOML
muxy config set appearance.dark_theme "Builtin Dark"
muxy config set terminal.font_size 14
muxy config set 'keymap."settings.focus_navbar"' cmd-l
muxy config unset terminal.font_size
muxy config reload                        # apply hand edits
```

- Keys are dotted paths in `settings.toml`, or in `terminal.toml` after
  `terminal.`. Quote a part that holds a dot. New settings get keys
  automatically, from the files' own format. Optional settings appear in
  `list` once they are set.
- Values are TOML, such as `true`, `14`, or `["Menlo", "Monaco"]`. Anything else
  is text, so names need no quotes of their own.
- A change is saved only if the app can still start with it, and the file is
  left as it was otherwise. `set` and `unset` then have a running desktop app
  apply it. They never start the app, which reads the files when it starts.
- Remote servers are read-only here; manage them in **Settings → Devices**.
  Server settings use `muxy settings`.
- `config` works on this computer's profile and doesn't take `--host`. Every
  command takes `--json` for machine-readable output.

## Sessions from a script

```bash
id=$(muxy session create my-app)
muxy session send "$id" "npm test"
muxy session send-keys "$id" Enter
muxy session read-screen "$id" --lines 20
muxy session end "$id" --yes
```

- `send` types text without pressing Return. `send --stdin` reads piped or
  redirected input verbatim, including newlines; it accepts up to 1 MiB and
  sends nothing if input exceeds that limit. It cannot also take a text argument.
- `send-keys` sends one or more keys in order: `Enter`, `Tab`, `Escape`,
  `Backspace`, `Ctrl+C`, `Ctrl+D`, or `Ctrl+Z`. All keys are validated before
  any input is sent.
- `read-screen` returns the last visible rows. `history` and `search` page
  through scrollback as JSON.
- `--saved` reads a session's last saved screen, even after it ended.
- `end` stops the program and keeps its saved output. `discard` also deletes
  the output.
- Sessions created here outlive the command and appear in every app under
  **Existing Terminals**.
- `show` opens a session in a new tab of its project in the desktop app on
  this computer, starting it if needed. When a tab already shows the session,
  `show` selects that tab instead. It never brings a running app to the front.
  With `--background`, `show` adds the tab without switching to it.
- Inside a Muxy terminal, session commands default to that terminal, and
  `create` to its project.
- `create` can take a `--directory` and a command to run after `--`.
- `wait --text <text>` waits for text on the screen, and `wait --exit` for the
  shell to exit. Both give up after 30 seconds by default.

### Inspect and name sessions

```bash
muxy project inspect my-app
muxy session inspect "$id" --json
muxy session rename "$id" dev-server
muxy ls --project my-app --quiet
printf 'npm test\n' | muxy send "$id" --stdin
muxy send-key "$id" Ctrl+C Enter
```

Inspection includes a session's name, status, project, directory and owner,
including saved sessions. Renaming uses the server's shared name, so every
connected app sees it. Names must be nonempty, trimmed, at most 256 bytes and
contain no control characters. Existing session commands continue to target
numeric IDs; renaming does not change the ID. Older servers without session
naming report that the operation is unsupported.

## Session links

`muxy session link` prints a link that opens a terminal in the desktop app. Inside
a Muxy terminal it defaults to that terminal, so an agent can hand its own
terminal to a dashboard or another app.

```bash
muxy session link                   # muxy://session/42?server=…
muxy session link 42 --split right  # muxy://session/42?server=…&split=right
```

Opening the link raises the desktop app on this computer, starting it if needed,
and selects the project, worktree, and tab that show the terminal. If no tab
shows it, Muxy opens it in a new tab of its project. With `--split right` or
`--split down`, it splits the selected pane of that project instead.

- The link is `muxy://session/<id>`, with `server=<MUXY_SERVER_ID>` and
  `split=right|down` as options. Without `server`, it means this computer's
  server.
- Muxy Beta links start with `muxy-beta://`, so each link opens the app whose
  server owns the terminal.
- A terminal on a [remote server](remote-servers.md) opens too, once the app has
  connected to that server before. `--host` prints links for that server.
- A link to an ended terminal, or to a server the app doesn't know, shows an
  error and changes nothing.

## Browser control

```bash
tab=$(muxy browser open localhost:3000)
muxy browser wait-for-navigation "$tab"
muxy browser fill "$tab" "#email" "me@example.com"
muxy browser click "$tab" "button[type=submit]"
muxy browser wait "$tab" --text "Welcome"
muxy browser read "$tab"
muxy browser screenshot "$tab" --out page.png
muxy browser close "$tab"
```

- Browser commands need the desktop app and don't take `--host`. `open` starts
  the app if it isn't running.
- `open` prints the new tab's ID. Pass it to the other commands.
- `snapshot` lists a page's interactive elements, each with a selector for
  `click`, `fill`, or `type`.
- `muxy browser --help` lists every command.

## Exit codes

`0` on success. On any error, `muxy` prints `muxy: <message>` to stderr and exits
with `1`, including when a program run with `muxy exec` fails.

## Profiles

`MUXY_DIR` points the CLI, and the server it starts, at another profile folder.
Use it to run a separate, throwaway server. See [Server](server.md#files).
