Run one-off agent tasks and durable workflows from the command line
The CLI is designed for automation and scripting (CI/CD pipelines, batch processing,
programmatic control). For interactive terminal experiences, consider tools like Claude
Code or similar TUIs.
Mux provides a CLI for running one-off agent tasks without the desktop app. Unlike the interactive desktop experience, mux run normally executes a single request to completion and exits. The --goal option is an explicit exception: it starts a CLI Goal Run that may perform automatic continuations until the goal is complete or a limit is reached.
# Basic usage - run in current directorynpx mux run "Fix the failing tests"# Specify a directorymux run --dir /path/to/project "Add authentication"# Use SSH runtimemux run --runtime "ssh user@myserver" "Deploy changes"# Pipe instructions via stdinecho "Add logging to all API endpoints" | mux run# JSON output for scriptsmux run --json "List all TypeScript files" | jq '.type'
Use --goal when a task should keep going across automatic continuations until the agent marks the persisted goal complete:
# Goal text is also used as the initial message when no message/stdin is providedmux run --goal "Fix the failing tests and verify the suite passes"# Provide separate kickoff instructions while keeping the objective activemux run --goal "Ship the migration safely" "Start by inspecting the schema and propose a plan"# Bound automatic continuations with a goal-specific budget and turn capmux run --goal "Complete the refactor" --goal-budget 5.00 --goal-turns 10
A CLI Goal Run is intentionally not a strict alias for interactive /goal. It is ephemeral to the mux run process, does not apply interactive goal defaults, bypasses the interactive continuation cooldown, and exits successfully only when the persisted goal status is complete. If neither --goal-budget nor --goal-turns is provided, Mux warns that the goal is uncapped.--budget remains the hard session spending limit in USD. --goal-budget is goal accounting, accepts forms like $5, 5.00, and 500c, and may allow a final budget-limit wrap-up turn. If the session --budget is exceeded, the run stops immediately.Exit codes for CLI Goal Runs:
Code
Meaning
0
Goal completed (unless the agent set a nonzero exit code)
1
Operational, model, or tool error
2
Session --budget exceeded
3
Goal stopped incomplete, including goal budget/turn limits
# Goal run with automatic continuationsmux run --goal "Update dependencies, fix resulting tests, and verify the suite passes"# Quick fix in current directorymux run "Fix the TypeScript errors"# Use a specific model with extended thinkingmux run -m anthropic:claude-sonnet-4-5 -t high "Optimize database queries"# Run on remote servermux run -r "ssh dev@staging.example.com" -d /app "Update dependencies"# Scripted usage with JSON outputmux run --json "Generate API documentation" > output.jsonl# Limit spending to $2.00mux run --budget 2.00 "Refactor the authentication module"
Run durable workflow definitions from the command line without opening the desktop app. Workflows are JavaScript files discovered from built-in definitions, global mux workflow directories, and trusted project .mux/workflows directories.
mux workflow is currently gated by the dynamic-workflows experiment. Pass -e dynamic-workflows on each command, or enable the experiment in settings. The initial CLI runner
supports the local runtime only; worktree, SSH, Docker, and devcontainer workflow execution
are blocked until their workflow/action isolation and cleanup semantics are implemented.
# List discovered workflowsmux workflow list -e dynamic-workflows# Inspect a workflow and include its sourcemux workflow show deep-review-workflow --source -e dynamic-workflows# Run with positional text, mapped to { "input": "research workflow runners" }mux workflow run deep-research "research workflow runners" -e dynamic-workflows# Run with structured JSON args and machine-readable outputmux workflow run deep-review-workflow --args-json '{"base":"main"}' --json -e dynamic-workflows
Project-local workflows are executable only after the project is trusted. If a matching .mux/workflows/<name>.js exists in an untrusted project, mux workflow run fails before executing repo-controlled workflow code.
Start the HTTP/WebSocket server for remote access (for example, from a phone or another machine):
mux server --host 0.0.0.0 --port 3000
Options:
--host <host> - Host/interface to bind to (default: localhost)
--port <port> - Port to bind to (default: 3000)
--auth-token <token> - Bearer token for HTTP/WS auth
--no-auth - Disable authentication entirely
--print-auth-token - Always print the auth token on startup
--allow-http-origin - Accept HTTPS browser origins when a TLS-terminating proxy forwards X-Forwarded-Proto=http
--ssh-host <host> - SSH hostname/alias used for editor deep links in browser mode
--add-project <path> - Add and open project at the specified path
Use --allow-http-origin only when HTTPS is terminated by an upstream reverse proxy and mux receives rewritten X-Forwarded-Proto=http headers. This compatibility mode is disabled by default. For non-CLI server starts (for example desktop/browser mode), set MUX_SERVER_ALLOW_HTTP_ORIGIN=1 to opt in.Auth token precedence:
--no-auth
--auth-token
MUX_SERVER_AUTH_TOKEN
Auto-generated token
GitHub owner login for browser sessions is configured separately via MUX_SERVER_AUTH_GITHUB_OWNER or serverAuthGithubOwner in ~/.mux/config.json. See Server Access.
These environment variables help diagnose issues with LLM requests and responses.
Variable
Purpose
MUX_DEBUG_LLM_REQUEST
Set to 1 to log the complete LLM request (system prompt, messages, tools, provider options) as formatted JSON to the debug logs. Useful for diagnosing prompt issues.
Example usage:
MUX_DEBUG_LLM_REQUEST=1 mux run "Hello world"
The output includes:
systemMessage: The full system prompt sent to the model
messages: All conversation messages in the request
tools: Tool definitions with descriptions and input schemas