# Architecture

_How cmux-next fits together, and where each part lives in the code._

cmux-next has three layers: a Swift app for macOS, a Rust core, and web views. The Rust core runs as daemons, so terminals and agents keep running when the app quits, updates, or crashes. Each section below links to the code and to the longer docs next to it.

## The app

The macOS app is a Swift package with one module per feature: terminal, browser, Home, Settings, and so on. It draws windows, panes, and tabs, and draws terminals with libghostty from the ghostty-next fork. Rust code that runs inside the app is linked in as one static library.

| Where | What |
| --- | --- |
| [`Packages/macOS/CmuxNext`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/Packages/macOS/CmuxNext) | The app, one module per feature |
| [`Packages/macOS/CmuxNext/Sources/CmuxNextTerminal`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/Packages/macOS/CmuxNext/Sources/CmuxNextTerminal) | Terminal views on libghostty |
| [`cmux-tui/crates/cmux-app-ffi`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/cmux-tui/crates/cmux-app-ffi) | The Rust library inside the app |
| [`ghostty-next`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/ghostty-next) | The Ghostty fork that renders terminals |
| [`skills/cmux-architecture/SKILL.md`](https://github.com/manaflow-ai/cmux/blob/feat-cmux-next/skills/cmux-architecture/SKILL.md) | Layering and package rules for Swift code |

## The core: cmux-tui

cmux-tui is the Rust core and the cmux command. Its daemon keeps the tree of machines, workspaces, panes, tabs, terminals, and browsers, and owns every shell. The app, the CLI, the terminal UI, and remote clients all talk to it over the same socket protocol. A new app build takes over the running daemon, which is why an update keeps your shells and scrollback.

| Where | What |
| --- | --- |
| [`cmux-tui`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/cmux-tui) | The Rust workspace: core, CLI, and daemons |
| [`cmux-tui/crates/cmux-tui`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/cmux-tui/crates/cmux-tui) | The cmux command and its daemon |
| [`cmux-tui/crates/cmux-tui-core`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/cmux-tui/crates/cmux-tui-core) | The workspace tree and the resources in it |
| [`cmux-tui/spec/resource-api-v2.md`](https://github.com/manaflow-ai/cmux/blob/feat-cmux-next/cmux-tui/spec/resource-api-v2.md) | The socket protocol (cmux.protocol/2) |
| [`cmux-tui/docs`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/cmux-tui/docs) | cmux-tui docs: concepts, remote, protocol |

## Agents: acpmux

acpmux is a daemon that keeps coding agents alive as named sessions: Claude Code, Codex, OpenCode, Pi, and any agent that speaks the Agent Client Protocol (ACP). It records every message, so any number of clients can attach to a session, and it adds up what each turn cost. A chat tab in the app is one of those clients.

| Where | What |
| --- | --- |
| [`cmux-tui/crates/acpmux`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/cmux-tui/crates/acpmux) | The agent daemon and its CLI |
| [`webviews/src/agent-session/acpmux`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/webviews/src/agent-session/acpmux) | The chat pane, a client of acpmux |

## Web views

Chat, diffs, Markdown, Settings, Home, and the other pages are React, built from one source tree. The app serves each page from its own cmux-page:// origin, and the page talks to the app only over a small bridge. A dev server can feed them to a running app with hot reload.

| Where | What |
| --- | --- |
| [`webviews`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/webviews) | The React source and its dev server |
| [`webviews/src/pages`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/webviews/src/pages) | Pages the app hosts: Settings, Home, history, and more |

## One catalog for every action

Every action is declared once in a Rust catalog: its title, shortcut, arguments, and where it shows up. The command palette, the menus, the cmux command, and the MCP tools are all built from it, and so are the CLI, palette, and keyboard shortcut pages of these docs. Settings work the same way, from one schema.

| Where | What |
| --- | --- |
| [`cmux-tui/crates/cmux-action-catalog`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/cmux-tui/crates/cmux-action-catalog) | The action catalog |
| [`plans/cmux-next/action-surfaces.json`](https://github.com/manaflow-ai/cmux/blob/feat-cmux-next/plans/cmux-next/action-surfaces.json) | The catalog exported as JSON |
| [`schemas/settings/settings-schema.json`](https://github.com/manaflow-ai/cmux/blob/feat-cmux-next/schemas/settings/settings-schema.json) | The settings schema |
| [`cmux-tui/crates/cmux-tui/src/cli/mcp`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/cmux-tui/crates/cmux-tui/src/cli/mcp) | The MCP server (cmux mcp serve) |

## Other machines

A remote machine runs the same cmux-tui and acpmux, so its workspaces and agents work like local ones. Cloud machines are remote machines that cmux sets up for you.

| Where | What |
| --- | --- |
| [`cmux-tui/crates/cmux-remote`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/cmux-tui/crates/cmux-remote) | The remote runtime: daemon, client, and connection |
| [`cmux-tui/docs/remote.md`](https://github.com/manaflow-ai/cmux/blob/feat-cmux-next/cmux-tui/docs/remote.md) | How the remote daemon and clients connect |

## Design docs

Longer docs live next to the code. Design notes for each feature are in plans/cmux-next, and how-to guides for running and building cmux-next are in docs/cmux-next.

| Where | What |
| --- | --- |
| [`plans/cmux-next`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/plans/cmux-next) | Design notes, one per feature |
| [`docs/cmux-next`](https://github.com/manaflow-ai/cmux/tree/feat-cmux-next/docs/cmux-next) | Guides: install, dev builds, hot reload, dotfiles |
| [`plans/cmux-next/docs-DESIGN.md`](https://github.com/manaflow-ai/cmux/blob/feat-cmux-next/plans/cmux-next/docs-DESIGN.md) | How these docs are built |

-   [CLI and MCP reference](https://cmux.com/docs/nightly/next/cli)
-   [MCP server](https://cmux.com/docs/nightly/next/mcp)
-   [Settings reference](https://cmux.com/docs/nightly/next/settings)

Canonical: https://cmux.com/docs/nightly/next/architecture

Documentation index: https://cmux.com/llms.txt
