|
| 1 | +# Command Line Interface |
| 2 | + |
| 3 | +Mux provides a CLI for running one-off agent tasks without the desktop app. Unlike the interactive desktop experience, `mux run` executes a single request to completion and exits. |
| 4 | + |
| 5 | +## `mux run` |
| 6 | + |
| 7 | +Execute a one-off agent task: |
| 8 | + |
| 9 | +```bash |
| 10 | +# Basic usage - run in current directory |
| 11 | +mux run "Fix the failing tests" |
| 12 | + |
| 13 | +# Specify a directory |
| 14 | +mux run --dir /path/to/project "Add authentication" |
| 15 | + |
| 16 | +# Use SSH runtime |
| 17 | +mux run --runtime "ssh user@myserver" "Deploy changes" |
| 18 | + |
| 19 | +# Pipe instructions via stdin |
| 20 | +echo "Add logging to all API endpoints" | mux run |
| 21 | + |
| 22 | +# JSON output for scripts |
| 23 | +mux run --json "List all TypeScript files" | jq '.type' |
| 24 | +``` |
| 25 | + |
| 26 | +### Options |
| 27 | + |
| 28 | +| Option | Short | Description | Default | |
| 29 | +| ---------------------- | ----- | -------------------------------------------------- | ----------------- | |
| 30 | +| `--dir <path>` | `-d` | Project directory | Current directory | |
| 31 | +| `--model <model>` | `-m` | Model to use (e.g., `anthropic:claude-sonnet-4-5`) | Default model | |
| 32 | +| `--runtime <runtime>` | `-r` | Runtime: `local`, `worktree`, or `ssh <host>` | `local` | |
| 33 | +| `--mode <mode>` | | Agent mode: `plan` or `exec` | `exec` | |
| 34 | +| `--thinking <level>` | `-t` | Thinking level: `off`, `low`, `medium`, `high` | `medium` | |
| 35 | +| `--timeout <duration>` | | Timeout (e.g., `5m`, `300s`, `300000`) | No timeout | |
| 36 | +| `--json` | | Output NDJSON for programmatic use | Off | |
| 37 | +| `--quiet` | `-q` | Only output final result | Off | |
| 38 | +| `--workspace-id <id>` | | Explicit workspace ID | Auto-generated | |
| 39 | +| `--config-root <path>` | | Mux config directory | `~/.mux` | |
| 40 | + |
| 41 | +### Runtimes |
| 42 | + |
| 43 | +- **`local`** (default): Runs directly in the specified directory. Best for one-off tasks. |
| 44 | +- **`worktree`**: Creates an isolated git worktree under `~/.mux/src`. Useful for parallel work. |
| 45 | +- **`ssh <host>`**: Runs on a remote machine via SSH. Example: `--runtime "ssh user@myserver.com"` |
| 46 | + |
| 47 | +### Output Modes |
| 48 | + |
| 49 | +- **Default (TTY)**: Human-readable streaming with tool call formatting |
| 50 | +- **`--json`**: NDJSON streaming - each line is a JSON object with event data |
| 51 | +- **`--quiet`**: Suppresses streaming output, only shows final assistant response |
| 52 | + |
| 53 | +### Examples |
| 54 | + |
| 55 | +```bash |
| 56 | +# Quick fix in current directory |
| 57 | +mux run "Fix the TypeScript errors" |
| 58 | + |
| 59 | +# Use a specific model with extended thinking |
| 60 | +mux run -m anthropic:claude-sonnet-4-5 -t high "Optimize database queries" |
| 61 | + |
| 62 | +# Run on remote server |
| 63 | +mux run -r "ssh dev@staging.example.com" -d /app "Update dependencies" |
| 64 | + |
| 65 | +# Scripted usage with timeout |
| 66 | +mux run --json --timeout 5m "Generate API documentation" > output.jsonl |
| 67 | +``` |
| 68 | + |
| 69 | +## `mux server` |
| 70 | + |
| 71 | +Start the HTTP/WebSocket server for remote access (e.g., from mobile devices): |
| 72 | + |
| 73 | +```bash |
| 74 | +mux server --port 3000 --host 0.0.0.0 |
| 75 | +``` |
| 76 | + |
| 77 | +Options: |
| 78 | + |
| 79 | +- `--host <host>` - Host to bind to (default: `localhost`) |
| 80 | +- `--port <port>` - Port to bind to (default: `3000`) |
| 81 | +- `--auth-token <token>` - Optional bearer token for authentication |
| 82 | +- `--add-project <path>` - Add and open project at the specified path |
| 83 | + |
| 84 | +## `mux desktop` |
| 85 | + |
| 86 | +Launch the desktop app. This is automatically invoked when running the packaged app or via `electron .`: |
| 87 | + |
| 88 | +```bash |
| 89 | +mux desktop |
| 90 | +``` |
| 91 | + |
| 92 | +Note: Requires Electron. When running `mux` with no arguments under Electron, the desktop app launches automatically. |
| 93 | + |
| 94 | +## `mux --version` |
| 95 | + |
| 96 | +Print the version and git commit: |
| 97 | + |
| 98 | +```bash |
| 99 | +mux --version |
| 100 | +# v0.8.4 (abc123) |
| 101 | +``` |
0 commit comments