# CLI-Referenz

cmux bietet sowohl ein CLI-Werkzeug als auch einen Unix-Socket für programmatische Steuerung. Jeder Befehl ist über beide Schnittstellen verfügbar.

## Socket

| Build | Pfad |
| --- | --- |
| Release | `/tmp/cmux.sock` |
| Debug | `/tmp/cmux-debug.sock` |
| Getaggter Debug-Build | `/tmp/cmux-debug-<tag>.sock` |

Überschreiben mit der Umgebungsvariable CMUX\_SOCKET\_PATH. Senden Sie eine JSON-Anfrage pro Aufruf, mit Zeilenumbruch am Ende:

```
{"id":"req-1","method":"workspace.list","params":{}}
// Response:
{"id":"req-1","ok":true,"result":{"workspaces":[...]}}
```

JSON-Socket-Anfragen müssen method und params verwenden. Legacy-v1-JSON-Payloads wie `{"command":"..."}` werden nicht unterstützt.

## Zugriffsmodi

| Modus | Beschreibung | Aktivierung |
| --- | --- | --- |
| **Off** | Socket deaktiviert | Einstellungs-UI oder CMUX\_SOCKET\_MODE=off |
| **cmux processes only** | Nur Prozesse, die in cmux-Terminals gestartet wurden, können sich verbinden. | Standardmodus in der Einstellungs-UI |
| **allowAll** | Jeden lokalen Prozess verbinden lassen (keine Herkunftsprüfung). | Nur per Umgebungsvariable: CMUX\_SOCKET\_MODE=allowAll |

Auf gemeinsam genutzten Rechnern verwenden Sie Aus oder Nur cmux-Prozesse.

## CLI-Optionen

| Flag | Beschreibung |
| --- | --- |
| `--socket PATH` | Benutzerdefinierter Socket-Pfad |
| `--json` | Ausgabe im JSON-Format |
| `--window ID` | Ein bestimmtes Fenster ansprechen |
| `--workspace ID` | Einen bestimmten Workspace ansprechen |
| `--surface ID` | Eine bestimmte Oberfläche ansprechen |
| `--id-format refs|uuids|both` | ID-Format in der JSON-Ausgabe steuern |

## Workspace-Befehle

#### list-workspaces

Alle geöffneten Workspaces auflisten.

CLI

```
cmux list-workspaces
cmux list-workspaces --json
```

Socket

```
{"id":"ws-list","method":"workspace.list","params":{}}
```

#### new-workspace

Einen neuen Workspace erstellen.

CLI

```
cmux new-workspace
```

Socket

```
{"id":"ws-new","method":"workspace.create","params":{}}
```

#### select-workspace

Zu einem bestimmten Workspace wechseln.

CLI

```
cmux select-workspace --workspace <id>
```

Socket

```
{"id":"ws-select","method":"workspace.select","params":{"workspace_id":"<id>"}}
```

#### current-workspace

Den aktuell aktiven Workspace abrufen.

CLI

```
cmux current-workspace
cmux current-workspace --json
```

Socket

```
{"id":"ws-current","method":"workspace.current","params":{}}
```

#### close-workspace

Einen Workspace schließen.

CLI

```
cmux close-workspace --workspace <id>
```

Socket

```
{"id":"ws-close","method":"workspace.close","params":{"workspace_id":"<id>"}}
```

## Split-Befehle

#### new-split

Einen neuen geteilten Bereich erstellen. Richtungen: left, right, up, down.

CLI

```
cmux new-split right
cmux new-split down
cmux new-split down --command "npm run dev"
```

Socket

```
{"id":"split-new","method":"surface.split","params":{"direction":"right"}}
{"id":"split-cmd","method":"surface.split","params":{"direction":"down","initial_input":"npm run dev\r"}}
```

#### list-panels

Alle Oberflächen im aktuellen Workspace auflisten.

CLI

```
cmux list-panels
cmux list-panels --json
```

Socket

```
{"id":"surface-list","method":"surface.list","params":{}}
```

#### list-pane-surfaces

Oberflächen im fokussierten Bereich auflisten.

CLI

```
cmux list-pane-surfaces
cmux list-pane-surfaces --json
```

Socket

```
{"id":"pane-surfaces","method":"pane.surfaces","params":{}}
```

#### focus-panel

Eine bestimmte Oberfläche fokussieren.

CLI

```
cmux focus-panel --panel <id>
```

Socket

```
{"id":"surface-focus","method":"surface.focus","params":{"surface_id":"<id>"}}
```

## Eingabebefehle

#### send

Texteingabe an das fokussierte Terminal senden.

CLI

```
cmux send "echo hello"
cmux send "ls -la\n"
```

Socket

```
{"id":"send-text","method":"surface.send_text","params":{"text":"echo hello\n"}}
```

#### send-key

Einen Tastendruck senden. Tasten: enter, tab, escape, backspace, delete, up, down, left, right.

CLI

```
cmux send-key enter
```

Socket

```
{"id":"send-key","method":"surface.send_key","params":{"key":"enter"}}
```

#### send --surface

Text an eine bestimmte Oberfläche senden.

CLI

```
cmux send --surface <id> "command"
```

Socket

```
{"id":"send-surface","method":"surface.send_text","params":{"surface_id":"<id>","text":"command"}}
```

#### send-key --surface

Einen Tastendruck an eine bestimmte Oberfläche senden.

CLI

```
cmux send-key --surface <id> enter
```

Socket

```
{"id":"send-key-surface","method":"surface.send_key","params":{"surface_id":"<id>","key":"enter"}}
```

## Benachrichtigungsbefehle

#### notify

Eine Benachrichtigung senden.

CLI

```
cmux notify --title "Title" --body "Body"
cmux notify --title "T" --subtitle "S" --body "B"
```

Socket

```
{"id":"notify","method":"notification.create","params":{"title":"Title","subtitle":"S","body":"Body"}}
```

#### list-notifications

Alle Benachrichtigungen auflisten.

CLI

```
cmux list-notifications
cmux list-notifications --json
```

Socket

```
{"id":"notif-list","method":"notification.list","params":{}}
```

#### clear-notifications

Alle Benachrichtigungen löschen.

CLI

```
cmux clear-notifications
```

Socket

```
{"id":"notif-clear","method":"notification.clear","params":{}}
```

## Seitenleisten-Metadaten-Befehle

Setzen Sie Status-Pills, Fortschrittsbalken und Log-Einträge in der Seitenleiste für jeden Workspace. Nützlich für Build-Skripte, CI-Integrationen und KI-Coding-Agenten, die den Status auf einen Blick anzeigen möchten.

#### set-status

Eine Seitenleisten-Status-Pill setzen. Verwenden Sie einen eindeutigen Schlüssel, damit verschiedene Werkzeuge ihre eigenen Einträge verwalten können.

CLI

```
cmux set-status build "compiling" --icon hammer --color "#ff9500" --priority 80
cmux set-status deploy "v1.2.3" --workspace workspace:2
```

Socket

```
set_status build compiling --icon=hammer --color=#ff9500 --priority=80 --tab=<workspace-uuid>
```

#### clear-status

Einen Seitenleisten-Status-Eintrag per Schlüssel entfernen.

CLI

```
cmux clear-status build
```

Socket

```
clear_status build --tab=<workspace-uuid>
```

#### list-status

Alle Seitenleisten-Status-Einträge für einen Workspace auflisten.

CLI

```
cmux list-status
```

Socket

```
list_status --tab=<workspace-uuid>
```

#### set-progress

Einen Fortschrittsbalken in der Seitenleiste setzen (0.0 bis 1.0).

CLI

```
cmux set-progress 0.5 --label "Building..."
cmux set-progress 1.0 --label "Done"
```

Socket

```
set_progress 0.5 --label=Building... --tab=<workspace-uuid>
```

#### clear-progress

Den Seitenleisten-Fortschrittsbalken löschen.

CLI

```
cmux clear-progress
```

Socket

```
clear_progress --tab=<workspace-uuid>
```

#### log

Einen Log-Eintrag zur Seitenleiste hinzufügen. Stufen: info, progress, success, warning, error.

CLI

```
cmux log "Build started"
cmux log --level error --source build "Compilation failed"
cmux log --level success -- "All 42 tests passed"
```

Socket

```
log --level=error --source=build --tab=<workspace-uuid> -- Compilation failed
```

#### clear-log

Alle Seitenleisten-Log-Einträge löschen.

CLI

```
cmux clear-log
```

Socket

```
clear_log --tab=<workspace-uuid>
```

#### list-log

Seitenleisten-Log-Einträge auflisten.

CLI

```
cmux list-log
cmux list-log --limit 5
```

Socket

```
list_log --limit=5 --tab=<workspace-uuid>
```

#### sidebar-state

Alle Seitenleisten-Metadaten ausgeben (cwd, Git-Branch, Ports, Status, Fortschritt, Logs).

CLI

```
cmux sidebar-state
cmux sidebar-state --workspace workspace:2
```

Socket

```
sidebar_state --tab=<workspace-uuid>
```

## Hilfsbefehle

#### ping

Prüfen, ob cmux läuft und reagiert.

CLI

```
cmux ping
```

Socket

```
{"id":"ping","method":"system.ping","params":{}}
// Response: {"id":"ping","ok":true,"result":{"pong":true}}
```

#### capabilities

Verfügbare Socket-Methoden und aktuellen Zugriffsmodus auflisten.

CLI

```
cmux capabilities
cmux capabilities --json
```

Socket

```
{"id":"caps","method":"system.capabilities","params":{}}
```

#### identify

Fokussierten Fenster-/Workspace-/Bereichs-/Oberflächen-Kontext anzeigen.

CLI

```
cmux identify
cmux identify --json
```

Socket

```
{"id":"identify","method":"system.identify","params":{}}
```

## Umgebungsvariablen

| Variable | Beschreibung |
| --- | --- |
| `CMUX_SOCKET_PATH` | Den von CLI und Integrationen verwendeten Socket-Pfad überschreiben |
| `CMUX_SOCKET_ENABLE` | Socket aktivieren/deaktivieren erzwingen (1/0, true/false, on/off) |
| `CMUX_SOCKET_MODE` | Zugriffsmodus überschreiben (cmuxOnly, allowAll, off). Akzeptiert auch cmux-only/cmux\_only und allow-all/allow\_all |
| `CMUX_WORKSPACE_ID` | Automatisch gesetzt: Aktuelle Workspace-ID |
| `CMUX_SURFACE_ID` | Automatisch gesetzt: Aktuelle Oberflächen-ID |
| `TERM_PROGRAM` | Gesetzt auf ghostty |
| `TERM` | Gesetzt auf xterm-ghostty |

Legacy-Werte für CMUX\_SOCKET\_MODE full und notifications werden aus Kompatibilitätsgründen weiterhin akzeptiert.

## cmux erkennen

bash

```
# Prefer explicit socket path if set
SOCK="${CMUX_SOCKET_PATH:-/tmp/cmux.sock}"
[ -S "$SOCK" ] && echo "Socket available"

# Check for the CLI
command -v cmux &>/dev/null && echo "cmux available"

# In cmux-managed terminals these are auto-set
[ -n "${CMUX_WORKSPACE_ID:-}" ] && [ -n "${CMUX_SURFACE_ID:-}" ] && echo "Inside cmux surface"

# Distinguish from regular Ghostty
[ "$TERM_PROGRAM" = "ghostty" ] && [ -n "${CMUX_WORKSPACE_ID:-}" ] && echo "In cmux"
```

## Beispiele

### Python-Client

python

```
import json
import os
import socket

SOCKET_PATH = os.environ.get("CMUX_SOCKET_PATH", "/tmp/cmux.sock")

def rpc(method, params=None, req_id=1):
    payload = {"id": req_id, "method": method, "params": params or {}}
    with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
        sock.connect(SOCKET_PATH)
        sock.sendall(json.dumps(payload).encode("utf-8") + b"\n")
        return json.loads(sock.recv(65536).decode("utf-8"))

# List workspaces
print(rpc("workspace.list", req_id="ws"))

# Send notification
print(rpc(
    "notification.create",
    {"title": "Hello", "body": "From Python!"},
    req_id="notify"
))
```

### Shell-Skript

bash

```
#!/bin/bash
SOCK="${CMUX_SOCKET_PATH:-/tmp/cmux.sock}"

cmux_cmd() {
    printf "%s\n" "$1" | nc -U "$SOCK"
}

cmux_cmd '{"id":"ws","method":"workspace.list","params":{}}'
cmux_cmd '{"id":"notify","method":"notification.create","params":{"title":"Done","body":"Task complete"}}'
```

### Build-Skript mit Benachrichtigung

bash

```
#!/bin/bash
npm run build
if [ $? -eq 0 ]; then
    cmux notify --title "✓ Build Success" --body "Ready to deploy"
else
    cmux notify --title "✗ Build Failed" --body "Check the logs"
fi
```

Canonical: https://cmux.com/de/docs/api

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