Skip to main content

CLI Reference (amux)

Specification v1.0 | @a5c-ai/agent-mux-cli

SCOPE EXTENSION: hermes-agent (@NousResearch/hermes-agent) is included as a 10th supported agent per explicit project requirements from the project owner. It extends the original scope document's 9 built-in agents. All hermes-specific content in this spec is marked with this same scope extension note.


1. Overview

The amux binary is the CLI surface of the @a5c-ai/agent-mux project. It exposes every capability of the SDK -- running agents, inspecting adapters, managing sessions, configuring agents, handling authentication, working with plugins, and tracking costs -- through a single command-line interface.

The CLI and SDK are co-equal surfaces that share the same core layer and behave identically. Every CLI command maps to a specific SDK method. This specification defines the CLI completely and precisely: a developer should be able to implement the binary from this document alone.

1.1 Package Coordinates

FieldValue
npm package@a5c-ai/agent-mux-cli
Binary nameamux
LanguageTypeScript, strict mode
RuntimeNode.js 20.9.0 or later
LicenseMIT

The binary is installed as part of @a5c-ai/agent-mux (the convenience meta-package) or standalone via @a5c-ai/agent-mux-cli. It depends on @a5c-ai/agent-mux-core and @a5c-ai/agent-mux-adapters.

# Via meta-package
npm install -g @a5c-ai/agent-mux

# Standalone CLI
npm install -g @a5c-ai/agent-mux-cli

# Zero-install
npx @a5c-ai/agent-mux
npx @a5c-ai/agent-mux run claude "hello"

1.2 Cross-References

ConceptSpecSection
AgentName, BuiltInAgentName01-core-types-and-client.md1.4
ErrorCode, AgentMuxError01-core-types-and-client.md3.1
CapabilityError01-core-types-and-client.md3.2
ValidationError01-core-types-and-client.md3.3
Storage layout01-core-types-and-client.md4
createClient(), ClientOptions01-core-types-and-client.md5
RunOptions02-run-options-and-profiles.md2
ProfileManager02-run-options-and-profiles.md10
RunHandle, RunResult03-run-handle-and-interaction.md2, 3
AgentEvent union04-agent-events.md2
AgentAdapter, BaseAgentAdapter05-adapter-system.md2
AgentCapabilities, ModelCapabilities06-capabilities-and-models.md2
SessionManager07-session-manager.md2
ConfigManager, AuthManager08-config-and-auth.md2, 8
PluginManager09-plugin-manager.md2
CLI commands (scope)agent-mux-scope.md21
Process lifecycle (scope)agent-mux-scope.md22
Package structure (scope)agent-mux-scope.md24

2. Invocation Syntax

amux [command] [subcommand] [positional-args...] [flags...]

When invoked without a command, amux prints a help summary and exits with code 0.

When invoked with an unrecognized command, amux prints an error message with suggestions and exits with code 2.


3. Global Flags

Global flags are accepted by every command. They are parsed before command-specific flags and override corresponding environment variables and config file values.

FlagShortTypeDefaultDescription
--agent-aAgentNameConfig defaultTarget agent name. Accepted values: claude, codex, gemini, copilot, cursor, opencode, pi, omp, openclaw, hermes, or any plugin-registered adapter name.
--model-mstringAgent defaultModel ID for the target agent. Must be a model ID recognized by the agent's adapter.
--json--booleanfalseOutput as machine-readable JSON or JSONL. See Section 5 for output mode details.
--debug--booleanfalseEnable debug output. Includes raw event data in JSONL output and verbose logging to stderr.
--config-dir--string~/.agent-mux/Override the global configuration directory. Equivalent to createClient({ configDir }).
--project-dir--string.agent-mux/Override the project-local configuration directory. Equivalent to createClient({ projectConfigDir }).
--no-color--booleanfalseDisable colored output. Also activated when the NO_COLOR environment variable is set to any non-empty value, or when stdout is not a TTY.
--version-Vboolean--Print the @a5c-ai/agent-mux-cli version and exit.
--help-hboolean--Print help for the current command and exit. Available on every command and subcommand.
--completions--string--Generate shell completion script: bash, zsh, fish, powershell. See Section 22.

3.1 Flag Parsing Rules

  • Long flags use --kebab-case (e.g., --thinking-effort, --config-dir).
  • Short flags are single-character prefixed with - (e.g., -a, -m, -i, -q, -y).
  • Boolean flags do not take a value (--json enables JSON mode; --no-stream disables streaming).
  • Repeatable flags accept multiple values by specifying the flag multiple times (e.g., --tag build --tag test).
  • --env flags use KEY=VALUE syntax (e.g., --env ANTHROPIC_API_KEY=sk-...).
  • -- terminates flag parsing; all subsequent arguments are treated as positional.

4. Exit Codes

The amux binary uses the following exit codes. These are the only exit codes produced by the CLI itself. When amux run is used, the agent subprocess exit code is available in the JSONL output but does not propagate as the amux process exit code unless the agent crashed.

CodeNameDescriptionCorresponding ErrorCode
0SuccessCommand completed successfully.--
1General errorAn error occurred during execution.Varies (see error event)
2Usage errorInvalid command syntax, unknown flag, or missing required argument.VALIDATION_ERROR
3Agent not foundThe specified agent has no registered adapter.AGENT_NOT_FOUND
4Agent not installedThe agent adapter exists but the CLI binary is not on $PATH.AGENT_NOT_INSTALLED
5Auth errorAuthentication is required but not configured or expired.AUTH_ERROR
6Capability errorThe requested operation requires a capability the agent does not support.CAPABILITY_ERROR
7Config errorConfiguration file could not be read, parsed, or written.CONFIG_ERROR
8Session not foundThe specified session does not exist.SESSION_NOT_FOUND
9Profile not foundThe specified profile does not exist.PROFILE_NOT_FOUND
10Plugin errorPlugin operation failed (install, uninstall, search, etc.).PLUGIN_ERROR
11TimeoutThe run exceeded its timeout or inactivity timeout.TIMEOUT or INACTIVITY_TIMEOUT
12Agent crashedThe agent subprocess terminated unexpectedly.AGENT_CRASH
13AbortedThe run was aborted by the user (e.g., via SIGINT).ABORTED
14Rate limitedThe agent reported a rate limit.RATE_LIMITED
15Context exceededThe agent's context window was exceeded.CONTEXT_EXCEEDED

4.1 Exit Code Mapping

The CLI maps ErrorCode values from the SDK to exit codes as shown above. When multiple errors occur, the exit code reflects the first fatal error. Non-fatal errors (e.g., RATE_LIMITED with a successful retry) do not affect the exit code.

The following ErrorCode values map to exit code 1 (General error) as they have no dedicated exit code:

ErrorCodeRationale
SPAWN_ERRORAgent subprocess failed to spawn (bad path, permissions, missing binary). Distinct from AGENT_NOT_INSTALLED (binary not found on PATH) in that the binary was found but could not be executed.
INTERNALInternal agent-mux error (bug). Should not occur in normal operation.
PARSE_ERRORAn agent's output could not be parsed. Distinct from CONFIG_ERROR in that it relates to runtime output, not config files.

Note: CONFIG_LOCK_ERROR maps to exit code 7 (same as CONFIG_ERROR), not exit code 1, since it is a config-related error. It is not listed in the exit code 1 table above.


5. Output Modes

The CLI supports three output modes, selected by flags and context.

5.1 Human-Readable (Default)

When stdout is a TTY and --json is not set, the CLI produces formatted, colored output:

  • Tables: aligned columns with headers for list commands (adapters list, sessions list, models list, etc.).
  • Streaming text: for amux run, agent text output is printed to stdout as it arrives. Tool calls, thinking, and file operations are printed to stderr with visual indicators.
  • Progress indicators: spinners and status lines for long-running operations (install, plugin operations).
  • Color: ANSI color codes for emphasis, status indicators, and error highlighting. Disabled by --no-color, NO_COLOR env var, or non-TTY stdout.

5.2 JSON (--json)

When --json is set on non-streaming commands (e.g., adapters list --json, sessions list --json, models list --json), the CLI outputs a single JSON object or array to stdout:

{
"ok": true,
"data": [ ... ]
}

On error:

{
"ok": false,
"error": {
"code": "AGENT_NOT_FOUND",
"message": "No adapter registered for agent 'foo'",
"recoverable": false
}
}

5.3 JSONL Event Stream (amux run --json)

When --json is set on amux run, the CLI outputs one JSON object per line to stdout. Each line is a serialized AgentEvent object as defined in 04-agent-events.md. The final line is always a RunResult object with type: "run_result".

{"type":"session_start","runId":"01J...","agent":"claude","timestamp":1718000000000,"sessionId":"abc123","resumed":false}
{"type":"text_delta","runId":"01J...","agent":"claude","timestamp":1718000000100,"delta":"Hello","accumulated":"Hello"}
{"type":"message_stop","runId":"01J...","agent":"claude","timestamp":1718000000200,"text":"Hello, world!"}
{"type":"run_result","runId":"01J...","agent":"claude","model":"claude-sonnet-4-20250514","sessionId":"abc123","text":"Hello, world!","exitCode":0,"exitReason":"completed","durationMs":1200,"turnCount":1}

When --debug is combined with --json, each event includes the raw field containing the unparsed agent output line.

Human-readable progress (spinners, status) is suppressed in JSONL mode. Diagnostic messages go to stderr.


6. amux run -- Run an Agent

Invoke an agent with a prompt. This is the primary command.

6.1 Syntax

amux run [<agent>] [<prompt>] [flags...]

Both <agent> and <prompt> are optional positional arguments:

  • If <agent> is omitted, the default agent from config is used (GlobalConfig.defaultAgent or --agent global flag).
  • If --prompt / -p is provided, it supplies the initial prompt and takes precedence over positional prompt text.
  • If no explicit prompt is provided and stdin is not a TTY, the prompt is read from stdin (see Section 14).
  • If no explicit prompt is provided and stdin is a TTY and --interactive is not set, the CLI prints an error and exits with code 2.
  • If both are provided as positionals, the first argument is parsed as an agent name if it matches a registered adapter; otherwise, the entire positional is treated as the prompt and the default agent is used.

6.2 Flags

FlagShortTypeDefaultMaps to RunOptionsDescription
--model-mstringAgent defaultmodelModel ID.
--stream--booleantruestream: trueEnable streaming output.
--no-stream--boolean--stream: falseDisable streaming; buffer all output.
--thinking-effort--string--thinkingEffortThinking effort: low, medium, high, max.
--thinking-budget--number--thinkingBudgetTokensThinking budget in tokens. Minimum 1024.
--temperature--number--temperatureSampling temperature (0.0–2.0). Capability-gated.
--top-p--number--topPTop-p sampling (0.0–1.0). Capability-gated.
--top-k--number--topKTop-k sampling (>= 1). Capability-gated.
--thinking-override--string--thinkingOverrideNative thinking parameter override as a JSON string. Passed directly to the agent's API. Use for agent-specific thinking controls not covered by --thinking-effort or --thinking-budget. Example: --thinking-override '{"type":"enabled","budget_tokens":8192}'.
--max-tokens--number--maxTokensMaximum output tokens.
--max-output-tokens--number--maxOutputTokensAlias for --max-tokens. If both are set, --max-output-tokens wins.
--max-turns--number--maxTurnsMaximum agentic turns (tool-use loops).
--session--string--sessionIdResume session by native session ID.
--fork--string--forkSessionIdFork session by native session ID.
--no-session--booleanfalsenoSession: trueEphemeral run; do not persist session.
--system--string--systemPromptSystem prompt text.
--system-mode--stringprependsystemPromptModeSystem prompt mode: prepend, append, replace.
--cwd--stringprocess.cwd()cwdWorking directory for the agent subprocess. Must be an absolute path to an existing directory.
--env--string--envEnvironment variable in KEY=VALUE format. Repeatable.
--prompt-pstring----Initial prompt text. Equivalent to the positional <prompt>, but unambiguous in scripts.
--non-interactive--booleanfalsenonInteractive: trueForce headless one-shot harness mode. Harness prompt flags are only used when this is paired with --prompt.
--yolo--boolean--approvalMode: 'yolo'Auto-approve all tool calls and file operations.
--deny--boolean--approvalMode: 'deny'Auto-deny all actions requiring approval.
--timeout--number0timeoutRun timeout in milliseconds. 0 disables.
--inactivity-timeout--number0inactivityTimeoutInactivity timeout in milliseconds. 0 disables.
--output-format--stringtextoutputFormatAgent output format: text, json, jsonl.
--tag--string--tagsRun tag for cost roll-ups and session search. Repeatable.
--run-id--stringAuto ULIDrunIdCustom run ID (must be a valid ULID).
--attach--string--attachmentsFile path to attach. Repeatable. Supports images and text files. Capability-gated (supportsFileAttachments).
--skill--string--skillsSkill file or directory path. Repeatable. Capability-gated (supportsSkills).
--agents-doc--string--agentsDocPath to an agents.md document. Capability-gated (supportsAgentsMd).
--mcp-server--string--mcpServersMCP server name (must exist in config). Repeatable. Overrides the default MCP server set. Capability-gated (supportsMCP).
--project-id--string--projectIdProject identifier for cost tracking and session grouping. Stored in run-index.jsonl.
--profile--string--profileNamed profile to apply as the base.
--interactive-ibooleanfalse--Enter interactive REPL mode (see Section 13).
--json--booleanfalse--Emit JSONL event stream to stdout.
--quiet-qbooleanfalse--Suppress non-essential output (tool calls, thinking, file ops). Only print final text.

SDK-Only RunOptions (No CLI Flag)

The following RunOptions fields are intentionally not exposed as CLI flags:

RunOptions FieldReason
retryPolicyComplex RetryPolicy object with maxRetries, baseDelay, maxDelay, backoffMultiplier fields. Not suitable for a single CLI flag. Configure via profile or config file.
onInputRequiredCallback function. The CLI handles input_required events internally (prompts user or auto-denies in non-interactive mode).
onApprovalRequestCallback function. The CLI handles approval_request events via --yolo / --deny flags or interactive prompts.

6.3 Mutual Exclusion

The following flag combinations are invalid and produce exit code 2:

  • --session + --no-session
  • --session + --fork
  • --fork + --no-session
  • --yolo + --deny
  • --stream + --no-stream

6.4 Flag-to-RunOptions Mapping

The CLI constructs a RunOptions object from flags. Resolution order (highest precedence first):

  1. Explicit CLI flags.
  2. Profile values (if --profile is set).
  3. Project config values (.agent-mux/config.json).
  4. Global config values (~/.agent-mux/config.json).
  5. Adapter defaults.

This matches the resolution order defined in 02-run-options-and-profiles.md, Section 7.

6.5 Behavior

  1. The CLI calls createClient() with global flag overrides.
  2. Resolves the initial prompt from --prompt, positional args, or stdin.
  3. Constructs RunOptions from flags, profile, and config.
  4. Calls mux.run(options) to obtain a RunHandle.
  5. By default, the initial prompt is delivered to stdin-capable harnesses over stdin so the harness stays interactive. When --prompt and --non-interactive are both set, agent-mux instead uses the harness's one-shot prompt flag/path.
  6. Consumes events from the RunHandle:
    • Human mode: prints text deltas to stdout, tool calls and thinking to stderr.
    • JSONL mode (--json): writes each AgentEvent as one JSON line to stdout.
    • Quiet mode (-q): suppresses everything except the final message_stop text.
  7. On approval_request events (when approvalMode is 'prompt' and not --yolo/--deny):
    • Interactive terminal: prompts the user on stderr, reads response from stdin.
    • Non-interactive (pipe, no TTY): auto-denies with a warning to stderr.
  8. On input_required events:
    • Interactive terminal: prompts on stderr, reads from stdin.
    • Non-interactive: emits the event in JSONL mode; otherwise errors.
  9. Awaits RunResult. Prints cost summary to stderr (unless --quiet).
  10. Exits with the appropriate exit code (see Section 4).

6.6 API Mapping

CLISDK
amux run claude "hello"mux.run({ agent: 'claude', prompt: 'hello' })
amux run --profile fast "hello"mux.run({ profile: 'fast', prompt: 'hello' })
amux run -a gemini --yolo "fix tests"mux.run({ agent: 'gemini', prompt: 'fix tests', approvalMode: 'yolo' })

6.7 Examples

# Basic run
amux run claude "explain this codebase"

# Run with thinking and model override
amux run claude --model claude-sonnet-4-20250514 --thinking-effort high "refactor auth module"

# Ephemeral run with auto-approve
amux run codex --no-session --yolo "add unit tests for utils.ts"

# Resume session
amux run claude --session abc123 "continue from where we left off"

# Fork session
amux run claude --fork abc123 "try a different approach"

# JSONL output for piping
amux run gemini --json "list all TODO items" | jq 'select(.type == "text_delta") | .delta'

# With tags for cost tracking
amux run claude --tag feature/auth --tag sprint-42 "implement oauth flow"

# Using a profile
amux run --profile careful "review this PR"

# Quiet mode -- only final text
amux run claude -q "what is 2+2"

6b. amux launch -- Launch a Harness with Provider Flexibility

Start (or resume) an interactive or non-interactive coding agent session with full stdin/stdout passthrough. Unlike amux run, which normalizes output into the AgentEvent stream, amux launch is a transparent proxy — the user interacts directly with the harness as if they invoked it natively. Its key additional capability is unified provider resolution: you can point any supported harness at any LLM provider, with amux-proxy bridging the gap when the harness cannot speak the provider's native wire protocol.

See launcher for the archived launcher specification and provider & model configuration for the archived provider-configuration design.

Concernamux runamux launch
Output formatNormalized AgentEvent streamRaw harness output (bypass)
Input formatRunOptions / SDK APIRaw stdin passthrough
Provider configN/A (each harness's own)Unified provider/model resolution
Proxy orchestrationNoYes (--with-proxy-if-needed)
Use caseProgrammatic orchestration, multi-agentDirect harness usage with provider flexibility

6b.1 Syntax

amux launch <harness> [provider] [flags...]

Positional arguments:

ArgumentRequiredDescription
<harness>YesTarget harness name. Registered SubprocessAdapter.agent values: claude, codex, gemini, opencode, copilot, cursor, pi, omp, openclaw, hermes, droid, amp, qwen.
[provider]NoProvider/backend identifier. If omitted, the harness's default native provider is used. See §6b.3 for the full taxonomy.

6b.2 Flags

Provider Configuration

FlagShortTypeDescription
--model-mstringModel identifier (provider-specific format). Required for non-default providers.
--api-keystringAPI key for the target provider. Can also be set via provider-specific env vars.
--api-basestringCustom API base URL. Overrides provider defaults.
--regionstringCloud region (for Bedrock, Vertex).
--projectstringCloud project ID (for Vertex, Foundry).
--resource-groupstringResource group (for Azure/Foundry).
--endpoint-namestringNamed deployment/endpoint (Azure, Foundry, Bedrock).
--transport-tstringWire protocol the harness should speak. One of: anthropic, openai-chat, openai-responses, google. Default: auto-detected from harness and provider.
--profilestringNamed provider profile from ~/.amux/providers.json.
--auth-commandstringExternal command that emits a bearer token on stdout.

Proxy Control

FlagTypeDefaultDescription
--with-proxy-if-neededbooleanfalseLaunch amux-proxy automatically if the harness cannot speak the provider's native transport directly.
--with-proxybooleanfalseForce proxy launch even if the harness supports the provider natively. Useful for observability or logging.
--no-proxybooleanfalseExplicitly disable proxy. Errors if the harness cannot reach the provider without one.
--proxy-portnumber0 (auto)Port for the proxy server. 0 = OS-assigned ephemeral port.
--proxy-log-levelstringwarnLog level for the proxy process: debug, info, warn, error.

Session Control

FlagShortTypeDescription
--resume-rstringResume an existing session by ID or name. Passes the harness-specific resume flag through.
--session-id-sstringExplicit session ID for a new session.

Execution Mode

FlagShortTypeDescription
--prompt-pstringInitial prompt. When set, runs in non-interactive mode: sends the prompt, streams output, and exits when the harness exits. When omitted, runs in interactive mode with full stdin/stdout passthrough.
--max-turnsnumberTurn limit (non-interactive mode).
--max-budget-usdnumberCost limit (where the harness supports it).

Harness Passthrough

FlagTypeDescription
--harness-argsstring[]Raw arguments forwarded verbatim to the harness CLI after all amux-managed args. Use the -- separator: amux launch claude api -- --bare --verbose.

General

FlagShortTypeDefaultDescription
--jsonbooleanfalseOutput machine-readable JSON for launch status and proxy lifecycle events. Does not affect raw harness output.
--debug-dbooleanfalseDebug mode. Logs proxy and harness process details to stderr.
--dry-runbooleanfalsePrint the resolved command, env vars, and proxy config as JSON without executing.

6b.3 Supported Provider IDs

Provider IDDescriptionDefault TransportDefault Auth
anthropicAnthropic direct APIanthropicAPI key
openaiOpenAI direct APIopenai-responsesAPI key
googleGoogle AI StudiogoogleAPI key
bedrockAWS BedrockanthropicIAM / AWS profile
vertexGoogle Vertex AIgoogleADC / service account
azureAzure OpenAIopenai-chatAPI key / AD token
foundryAzure AI Foundryopenai-chatAPI key / AD token
ollamaLocal Ollama instanceopenai-chatNone
localGeneric local model serveropenai-chatNone
openrouterOpenRouteropenai-chatAPI key
groqGroqopenai-chatAPI key
fireworksFireworks AIopenai-chatAPI key
togetherTogether AIopenai-chatAPI key
deepseekDeepSeekopenai-chatAPI key
mistralMistral AIopenai-chatAPI key
cerebrasCerebrasopenai-chatAPI key
sambanovaSambaNovaopenai-chatAPI key
customUser-defined endpointRequires --transportAny (via flags)

6b.4 Supported Transport IDs

Transport IDEndpointWire FormatUsed By
anthropicPOST /v1/messagesAnthropic Messages API (SSE)Claude Code
openai-chatPOST /v1/chat/completionsOpenAI Chat CompletionsOpenCode, Codex (wire_api=chat)
openai-responsesPOST /v1/responsesOpenAI Responses APICodex (default)
googlePOST /v1beta/models/:model:generateContentGoogle GenerateContentGemini CLI

6b.5 Native Support Matrix

This matrix shows which harness+provider combinations work without a proxy. Use --with-proxy-if-needed for combinations marked with a cross.

anthropicbedrockvertexazurefoundrygoogleopenaiollama
claudeNativeNativeNativeNoNativeNoNoVia ANTHROPIC_BASE_URL
codexNoNoNoNoNoNoNativeNative (--oss)
geminiNoNoNative (ADC)NoNoNativeNoNo
opencodeNativeNative (SDK)Native (SDK)Native (SDK)NoNative (SDK)NativeOpenAI-compat
copilotNoNoNoNoNoNoNoNo
cursorNativeNoNoNoNoNoNoNo

Cells marked "No" require --with-proxy-if-needed. Cells marked "Via ANTHROPIC_BASE_URL" or "OpenAI-compat" work with an env var workaround but a proxy is recommended for reliability.

6b.6 Examples

# Interactive Claude Code with default provider (Anthropic direct)
amux launch claude

# Interactive Claude Code via Bedrock (native, no proxy needed)
amux launch claude bedrock --region us-east-1

# Interactive Claude Code via Vertex (native)
amux launch claude vertex --project my-gcp-project --region us-central1

# Interactive Codex via Bedrock (proxy required: codex speaks OpenAI, bedrock speaks Anthropic)
amux launch codex bedrock --region us-east-1 \
--model anthropic.claude-sonnet-4-20250514-v1:0 \
--with-proxy-if-needed

# Non-interactive (one-shot) run via Vertex
amux launch claude vertex --project my-project --region us-central1 \
-p "Explain the authentication flow in this codebase" \
--max-turns 3

# Interactive Codex via Ollama (local, no proxy needed with --oss flag)
amux launch codex ollama --model qwen3:32b

# Interactive Claude Code via Ollama (proxy bridges Ollama to Anthropic transport)
amux launch claude ollama --model qwen3:32b --with-proxy-if-needed

# Use a named provider profile from ~/.amux/providers.json
amux launch claude --profile work-bedrock

# Dry run: see what would be executed without running it
amux launch codex bedrock --region us-east-1 --model anthropic.claude-sonnet-4-20250514-v1:0 \
--with-proxy-if-needed --dry-run

# Passthrough raw harness args after --
amux launch claude api -- --bare --verbose

6b.7 Non-Interactive vs Interactive Mode

Interactive mode (default, no --prompt): stdin, stdout, and stderr are passed through directly to the harness. The user interacts with the harness TUI natively. amux only manages the proxy lifecycle and process signals.

Non-interactive mode (--prompt is set): the prompt is delivered to the harness via its native mechanism (e.g., --print for claude, exec for codex, --prompt for gemini). stdout and stderr are still passed through raw. The process exits when the harness completes its response. Suitable for scripting and CI/CD.

6b.8 Error Codes

CodeCondition
HARNESS_NOT_FOUNDUnknown harness name.
HARNESS_NOT_INSTALLEDHarness binary not found on $PATH.
PROVIDER_UNSUPPORTEDHarness+provider combo has no native support and proxy is not enabled.
PROXY_REQUIREDProxy required but --no-proxy is set.
PROXY_LAUNCH_FAILEDamux-proxy failed to start. Check that it is installed: pip install amux-proxy.
AUTH_MISSINGRequired provider auth not supplied.

7. amux install -- Install Agent CLIs

Install or display installation instructions for agent CLI binaries.

7.1 Syntax

amux install <agent> [flags...]

<agent> is required. Must be one of the ten built-in agent names: claude, codex, gemini, copilot, cursor, opencode, pi, omp, openclaw, hermes.

7.2 Flags

FlagShortTypeDefaultDescription
--dry-run--booleanfalsePrint the install commands without executing them.
--method--stringAuto-detectedForce a specific install method: npm, pip, brew, gh-extension, curl, winget, scoop, manual.
--yes-ybooleanfalseNon-interactive: execute install commands without confirmation prompts.

7.3 Behavior

  1. Resolves the adapter for <agent>.
  2. Reads AgentCapabilities.installMethods filtered by the current platform (process.platform).
  3. If --method is specified, selects only the matching install method. Exits with code 2 if no method matches.
  4. For each matching install method: a. Checks prerequisites (InstallMethod.prerequisiteCheck) if defined. Prints a warning if the prerequisite is not met. b. Prints the install command to stdout. c. Unless --dry-run: prompts for confirmation (unless --yes), then executes the command as a child process, streaming stdout/stderr to the terminal.
  5. After installation, runs mux.adapters.detect(agent) to verify the install succeeded and prints the detected version.

7.4 Install Methods per Agent

AgentMethodCommandPlatformNotes
claudenpmnpm install -g @anthropic-ai/claude-codeall--
claudebrewbrew install claude-codedarwin--
codexnpmnpm install -g @openai/codexall--
gemininpmnpm install -g @google/gemini-cliall--
copilotgh-extensiongh extension install github/gh-copilotallRequires GitHub CLI (gh). Prerequisite check: gh --version.
cursormanualOpens download pagedarwin, linuxNo headless-only install. Full app required.
cursorwingetwinget install Cursor.Cursorwin32--
opencodenpmnpm install -g opencodeall--
opencodebrewbrew install opencode/tap/opencodedarwin--
pinpmnpm install -g @mariozechner/pi-coding-agentall--
ompnpmnpm install -g @oh-my-pi/pi-coding-agentall--
openclawnpmnpm install -g openclawallRequires Node 22.16+, 16GB RAM minimum.
hermespippip install hermes-agentallRequires Python >= 3.11. Alternative: uv pip install hermes-agent.

7.5 API Mapping

CLISDK
amux install claudemux.adapters.installInstructions('claude', process.platform)
amux install --dry-run geminimux.adapters.installInstructions('gemini', process.platform) (display only)

7.6 Examples

# Install Claude Code
amux install claude

# See what would be installed without running
amux install --dry-run gemini

# Force npm method
amux install opencode --method npm

# Non-interactive install
amux install codex --yes

# Install hermes (Python agent)
amux install hermes

8. amux adapters -- Adapter Discovery

List and inspect registered adapters and their installation state.

8.1 Syntax

amux adapters list [flags...]
amux adapters detect <agent> [flags...]

8.2 amux adapters list

Lists all registered adapters with their installation status, version, and authentication state.

Flags:

FlagTypeDefaultDescription
--jsonbooleanfalseOutput as JSON array.

Output columns (human mode):

ColumnDescription
AgentAgent name.
Installedyes / no.
VersionDetected version string, or -- if not installed.
Authauthenticated, unauthenticated, expired, unknown, or --.
PathAbsolute path to CLI binary, or --.

API mapping: mux.adapters.list() combined with mux.adapters.installed() for the installed/version/auth columns.

8.3 amux adapters detect <agent>

Detect a single agent: checks installation, resolves the binary path, detects the version, and checks authentication state.

Flags:

FlagTypeDefaultDescription
--jsonbooleanfalseOutput as JSON object.

Output (human mode): Key-value pairs:

Agent: claude
Installed: yes
Path: /usr/local/bin/claude
Version: 1.2.3
Min version: 1.0.0
Meets min: yes
Auth: authenticated
Model: claude-sonnet-4-20250514

API mapping: mux.adapters.detect('claude') returns InstalledAgentInfo.

8.4 Error Behavior

  • Unknown agent name: exit code 3 (AGENT_NOT_FOUND).
  • Agent not installed (for detect): prints the detection result showing installed: false, exits with code 0 (detection succeeded; the result is "not installed").

9. amux capabilities -- Agent Capabilities

Display the capabilities manifest for an agent, optionally scoped to a specific model.

9.1 Syntax

amux capabilities <agent> [flags...]

9.2 Flags

FlagTypeDefaultDescription
--modelstring--Show model-level capabilities for a specific model ID.
--jsonbooleanfalseOutput as JSON object.

9.3 Behavior

  • Without --model: prints agent-level capabilities (AgentCapabilities) as defined in 06-capabilities-and-models.md, Section 2.
  • With --model: prints the union of agent-level and model-level capabilities (ModelCapabilities) for the specified model.

Output (human mode): Grouped key-value display organized by category (session, streaming, tool calling, thinking, output, skills, plugins, process, auth, install).

API mapping:

CLISDK
amux capabilities claudemux.adapters.capabilities('claude')
amux capabilities claude --model claude-sonnet-4-20250514mux.adapters.capabilities('claude') + mux.models.model('claude', 'claude-sonnet-4-20250514')

9.4 Error Behavior

  • Unknown agent: exit code 3 (AGENT_NOT_FOUND).
  • Unknown model (with --model): exit code 1, error message listing available models.

10. amux models -- Model Registry

List, inspect, and refresh model metadata for agents.

10.1 Syntax

amux models list <agent> [flags...]
amux models get <agent> <model-id> [flags...]
amux models refresh <agent> [flags...]
amux models current <agent> [flags...]
amux models set <agent> <model-id> [--provider <provider>] [flags...]

10.2 amux models list <agent>

List all models available for an agent.

Flags:

FlagTypeDefaultDescription
--jsonbooleanfalseOutput as JSON array.

Output columns (human mode):

ColumnDescription
Model IDThe model identifier string.
Display NameHuman-readable name.
ProviderNormalized provider family (anthropic, openai, configurable, etc.).
ProtocolNormalized request protocol (messages, responses, chat, custom).
DeployTypical deployment path (hosted, local, gateway, hybrid).
Context WindowMaximum context in tokens.
Sourcebundled or remote.
DefaultWhether this is the adapter's default model.

API mapping: mux.models.catalog('claude') returns the per-adapter model catalog with default-entry metadata.

10.3 amux models get <agent> <model-id>

Show detailed capabilities for a single model.

Flags:

FlagTypeDefaultDescription
--jsonbooleanfalseOutput as JSON object.

Output (human mode): Key-value display showing all ModelCapabilities fields.

API mapping: mux.models.model('claude', 'claude-sonnet-4-20250514') returns ModelCapabilities | null.

10.4 amux models refresh <agent>

Refresh the model list from the agent's remote source (where applicable).

API mapping: mux.models.refresh('claude').

10.5 amux models current <agent>

Show the configured model, adapter default, and effective model selection for an agent.

API mapping: mux.config.getModelSelection('claude') plus mux.models.model(...) for effective-model details.

10.6 amux models set <agent> <model-id>

Validate and persist the configured model for an agent. Optional --provider records the selected provider for configurable/local-provider adapters.

API mapping: mux.models.validate('claude', 'sonnet') followed by mux.config.setModelSelection('claude', { model, provider }).

10.7 Error Behavior

  • Unknown agent: exit code 3 (AGENT_NOT_FOUND).
  • Unknown model (for get): exit code 1, error message listing available models.

11. amux plugin -- Native Plugin Management

Unified interface for managing native agent plugins through CLI delegation. Commands delegate to each agent's native plugin system (e.g., claude plugins, copilot plugin, gemini extensions). All subcommands are capability-gated: invoking on an agent where native plugin CLI commands don't exist produces exit code 6 (CAPABILITY_ERROR).

11.1 Syntax

amux plugin list <agent> [flags...]
amux plugin install <agent> <plugin-id> [flags...]
amux plugin uninstall <agent> <plugin-id> [flags...]
amux plugin update <agent> <plugin-id> [flags...]
amux plugin marketplace <agent> [subcommand] [flags...]

11.2 amux plugin list <agent>

List installed plugins for an agent via native CLI.

Flags:

FlagTypeDefaultDescription
--jsonbooleanfalseOutput as JSON array.

API mapping: Delegates to agent's native command (e.g., claude plugins list).

11.3 amux plugin install <agent> <plugin-id>

Install a plugin via agent's native CLI.

Flags:

FlagShortTypeDefaultDescription
--yes-ybooleanfalseSkip confirmation prompt.

API mapping: Delegates to agent's native install command.

11.4 amux plugin uninstall <agent> <plugin-id>

Uninstall a plugin via agent's native CLI.

Flags:

FlagShortTypeDefaultDescription
--yes-ybooleanfalseSkip confirmation prompt.

API mapping: Delegates to agent's native uninstall command.

11.5 amux plugin update <agent> <plugin-id>

Update a plugin via agent's native CLI.

API mapping: Delegates to agent's native update command.

11.6 amux plugin marketplace <agent> [subcommand]

Access agent's native plugin marketplace commands.

API mapping: Delegates to agent's marketplace commands (e.g., claude plugins marketplace).

11.7 Plugin Support per Agent

AgentNative Plugin SupportCLI Command
Claude✅ Full marketplaceclaude plugins
Gemini✅ Extensionsgemini extensions
Codex✅ Plugin directorycodex plugins
Copilot✅ Plugin marketplacecopilot plugin
OpenCode✅ Three-tier systemopencode plugins
Cursor❌ Hook-only (see Section 12)N/A
All others❌ MCP-only (see Section 12)N/A

11.8 Examples

# List installed plugins via native CLI
amux plugin list claude
amux plugin list gemini

# Install plugins via native marketplace
amux plugin install claude @anthropic/frontend-design
amux plugin install copilot github/copilot-agent

# Access native marketplace
amux plugin marketplace claude
amux plugin marketplace copilot

12. amux mcp -- MCP Server Management

Unified interface for managing Model Context Protocol servers across all agents. MCP servers provide cross-agent capabilities and integrations. All agents support MCP servers.

12.1 Syntax

amux mcp list <agent> [flags...]
amux mcp install <agent> <mcp-server> [flags...]
amux mcp uninstall <agent> <mcp-server> [flags...]

12.2 amux mcp list <agent>

List installed MCP servers for an agent.

Flags:

FlagTypeDefaultDescription
--jsonbooleanfalseOutput as JSON array.
--projectbooleanfalseList project-specific MCP servers only.

Output columns (human mode):

ColumnDescription
Server NameMCP server identifier.
Statusenabled / disabled.
CommandExecutable command.
Scopeglobal / project.

12.3 amux mcp install <agent> <mcp-server>

Install an MCP server for an agent.

Flags:

FlagShortTypeDefaultDescription
--project-pbooleanfalseInstall to project scope (vs. global).
--yes-ybooleanfalseSkip confirmation prompt.

12.4 amux mcp uninstall <agent> <mcp-server>

Uninstall an MCP server from an agent.

Flags:

FlagShortTypeDefaultDescription
--yes-ybooleanfalseSkip confirmation prompt.

12.5 MCP Server Registry

All MCP servers are available from the official registry at https://modelcontextprotocol.io.

12.6 Examples

# List MCP servers for an agent
amux mcp list claude
amux mcp list cursor

# Install MCP server globally
amux mcp install claude filesystem
amux mcp install gemini postgres

# Install MCP server to project
amux mcp install claude web-browser --project

# Remove MCP server
amux mcp uninstall claude filesystem

13. amux sessions -- Session Management

Read-only access to agent session data. The CLI delegates to SessionManager (see 07-session-manager.md, Section 2). Session data is never modified by these commands.

12.1 Syntax

amux sessions list <agent> [flags...]
amux sessions show <agent> <session-id> [flags...]
amux sessions search <query> [flags...]
amux sessions export <agent> <session-id> [flags...]
amux sessions diff <agent>:<id> <agent>:<id> [flags...]
amux sessions resume <agent> <session-id> [flags...]
amux sessions fork <agent> <session-id> [flags...]

12.2 amux sessions list <agent>

List sessions for an agent.

Flags:

FlagTypeDefaultDescription
--sincestring--ISO 8601 date or relative (e.g., 2024-01-01, 7d, 1w). Include sessions after this time.
--untilstring--ISO 8601 date or relative. Include sessions before this time.
--modelstring--Filter by model ID.
--tagstring--Filter by run tag (from run-index.jsonl). Repeatable.
--limitnumber50Maximum number of sessions to return.
--sortstringdateSort order: date, cost, turns.
--jsonbooleanfalseOutput as JSON array.

Output columns (human mode):

ColumnDescription
Session IDNative session identifier.
ModelModel ID used.
TurnsNumber of conversation turns.
CostTotal cost in USD.
DateSession start date.
SummaryFirst line of the prompt (truncated).

API mapping: mux.sessions.list('claude', { since, until, model, tags, limit, sort }) returns SessionSummary[].

12.3 amux sessions show <agent> <session-id>

Display the full content of a session.

Flags:

FlagTypeDefaultDescription
--formatstringmarkdownOutput format: json, jsonl, markdown.

API mapping: mux.sessions.export('claude', 'abc123', 'markdown').

12.4 amux sessions tail <agent> [session-id]

This command is not part of the current public CLI surface.

@a5c-ai/agent-mux-core does not currently expose a truthful live session-watch API. Earlier drafts described mux.sessions.watch(), but that contract was removed rather than shipping synthetic AgentEvent payloads derived from arbitrary session-file changes.

12.5 amux sessions search <query>

Full-text search across sessions.

Flags:

FlagTypeDefaultDescription
--agentAgentNameAllRestrict search to a specific agent.
--sincestring--Search sessions after this time.
--untilstring--Search sessions before this time.
--jsonbooleanfalseOutput as JSON array.

API mapping: mux.sessions.search({ text: query, agent, since, until }) returns SessionSummary[].

12.6 amux sessions export <agent> <session-id>

Export a session to a file or stdout.

Flags:

FlagTypeDefaultDescription
--formatstringjsonExport format: json, jsonl, markdown.

Output: The exported session content is written to stdout. Redirect to a file as needed.

API mapping: mux.sessions.export('claude', 'abc123', 'json') returns string.

12.7 amux sessions diff <agent>:<id> <agent>:<id>

Compute a structural diff between two sessions. Sessions may belong to the same or different agents.

Syntax: Each argument uses the unified ID format <agent>:<native-session-id>.

amux sessions diff claude:abc123 claude:def456
amux sessions diff claude:abc123 gemini:xyz789

API mapping: mux.sessions.diff({ agent: 'claude', sessionId: 'abc123' }, { agent: 'gemini', sessionId: 'xyz789' }) returns SessionDiff.

12.8 amux sessions resume <agent> <session-id>

Resume a session by starting a new interactive run that continues from the specified session.

Behavior: Equivalent to amux run <agent> --session <session-id> --interactive. Enters REPL mode (see Section 13).

API mapping: mux.run({ agent, sessionId, ... }) with interactive REPL loop.

12.9 amux sessions fork <agent> <session-id>

Fork a session and enter an interactive run on the new branch.

Behavior: Equivalent to amux run <agent> --fork <session-id> --interactive. Enters REPL mode.

API mapping: mux.run({ agent, forkSessionId: sessionId, ... }) with interactive REPL loop.

12.10 Error Behavior

  • Unknown agent: exit code 3 (AGENT_NOT_FOUND).
  • Unknown session ID: exit code 8 (SESSION_NOT_FOUND).
  • Corrupt session file: exit code 1 (PARSE_ERROR), with diagnostic message to stderr.

13. Interactive REPL Mode (amux run -i)

When --interactive / -i is set on amux run, the CLI enters a Read-Eval-Print Loop for multi-turn conversation with the agent.

13.1 Entry Conditions

REPL mode is entered when:

  • amux run -i is invoked (with or without an initial prompt).
  • amux sessions resume is invoked.
  • amux sessions fork is invoked.

13.2 REPL Behavior

  1. If an initial prompt is provided, it is sent as the first turn.
  2. After the agent completes its response, the CLI prints a prompt indicator (for example, amux>) and waits for user input on stdin.
  3. User input is sent to the running agent via RunHandle.continue(prompt).
  4. Tool approval requests are handled inline: the CLI prints the request and prompts for [y]es / [n]o / [a]lways on stderr.
  5. The loop continues until:
    • The user types /exit or /quit.
    • The user presses Ctrl+D (EOF on stdin).
    • The user presses Ctrl+C twice within 1 second.
    • The agent terminates.

13.3 REPL Commands

The following slash commands are recognized within the REPL:

CommandDescription
/exit, /quitEnd the session and exit.
/abortAbort the current agent operation.
/interruptSend interrupt (SIGINT) to the agent.
/pausePause agent execution.
/resumeResume paused execution.
/statusPrint current run state, session ID, model, and cost.
/costPrint accumulated cost for this run.
/sessionPrint the current session ID.
/helpPrint REPL command reference.

SDK frontends built on the same live-run surface can also defer follow-up prompts with RunHandle.queue() and RunHandle.steer(). The bundled TUI maps /queue ..., /steer ..., and /steer-tool ... onto those APIs when a run is already active.

13.4 REPL + JSONL

When -i and --json are combined, the REPL reads prompts from stdin (one per line) and emits JSONL events to stdout. This enables programmatic multi-turn conversation. The REPL terminates on stdin EOF.


14. Pipe and Stdin Support

The CLI supports pipe-based workflows for composability with Unix tools.

14.1 Reading Prompt from Stdin

When amux run is invoked without a prompt argument and stdin is not a TTY, the entire stdin is read and used as the prompt:

echo "refactor this function" | amux run claude
cat prompt.txt | amux run gemini --json
git diff | amux run codex "review this diff"

When both a positional prompt and stdin are provided, the positional prompt takes precedence and stdin is ignored.

14.2 JSONL Output for Piping

JSONL output (--json) is designed for consumption by downstream tools:

# Extract only text deltas
amux run claude "explain X" --json | jq 'select(.type == "text_delta") | .delta'

# Monitor tool calls
amux run codex "fix tests" --json | jq 'select(.type | startswith("tool_"))'

# Extract final text
amux run gemini "summarize" --json | jq 'select(.type == "run_result") | .text'

14.3 TTY Detection

The CLI detects whether stdin and stdout are TTYs using process.stdin.isTTY and process.stdout.isTTY:

stdinstdoutBehavior
TTYTTYFull interactive mode: colors, spinners, approval prompts.
TTYPipeColors disabled, spinners disabled, approval prompts still on stderr.
PipeTTYPrompt read from stdin pipe. Approval prompts on stderr.
PipePipeFull non-interactive: --json implied if not set, approvals auto-denied.

15. amux cost -- Cost Reporting

Aggregate and display cost data across runs.

15.1 Syntax

amux cost report [flags...]

15.2 Flags

FlagTypeDefaultDescription
--agentAgentNameAllFilter by agent. Repeatable.
--sincestring--Include runs after this time. ISO 8601 or relative.
--untilstring--Include runs before this time.
--modelstring--Filter by model.
--tagstring--Filter by tag. Repeatable.
--group-bystringagentGroup results: agent, model, day, tag.
--jsonbooleanfalseOutput as JSON object.

15.3 Output (Human Mode)

A formatted table showing cost breakdowns per grouping:

Cost Report (last 30 days)
──────────────────────────────────────────
Agent Runs Input$ Output$ Total
claude 42 $1.23 $3.45 $4.68
codex 15 $0.50 $1.20 $1.70
gemini 8 $0.10 $0.30 $0.40
──────────────────────────────────────────
Total 65 $1.83 $4.95 $6.78

15.4 API Mapping

CLISDK
amux cost report --agent claude --since 30dmux.sessions.totalCost({ agent: 'claude', since: '30d' })
amux cost report --group-by modelmux.sessions.totalCost({ groupBy: 'model' })

16. amux config -- Configuration Management

Read, write, and validate agent configuration files through the unified ConfigManager interface. See 08-config-and-auth.md, Section 2 for the full ConfigManager specification.

16.1 Syntax

amux config get <agent> [field] [--scope global|project] [--json]
amux config set <agent> <field> <value> [--scope global|project]
amux config schema <agent> [--json]
amux config validate <agent> [--json]
amux config mcp list <agent> [--json]
amux config mcp add <agent> [--scope global|project]
amux config mcp remove <agent> <server-name> [--scope global|project]
amux config reload [agent]

Common Config Flags

FlagTypeDefaultDescription
--scopeglobal | projectmergedTarget a specific config file scope. global reads/writes only ~/.agent-mux/config.json (or the agent's global config). project reads/writes only .agent-mux/config.json (or the agent's project config). When omitted, read commands return the merged result (project overrides global); write commands target the global file.
--jsonflagoffOutput in JSON format (single object, not JSONL). Applies to all read/query subcommands.

16.2 amux config get <agent> [field]

Read configuration for an agent. If field is omitted, prints the full merged config. If field is provided (dot-notation), prints only that field's value.

API mapping:

CLISDK
amux config get claudemux.config.get('claude')
amux config get claude modelmux.config.getField('claude', 'model')
amux config get claude permissions.allowmux.config.getField('claude', 'permissions.allow')

16.3 amux config set <agent> <field> <value>

Write a single field to the agent's native config file.

<value> is parsed as JSON if it starts with {, [, ", or is a number/boolean literal. Otherwise it is treated as a plain string.

API mapping: mux.config.setField('claude', 'model', 'claude-sonnet-4-20250514').

Error behavior:

  • Unknown agent: exit code 3 (AGENT_NOT_FOUND).
  • Invalid field/value: exit code 2 (VALIDATION_ERROR).
  • File write failure: exit code 7 (CONFIG_ERROR).
  • Lock contention: exit code 7 (CONFIG_LOCK_ERROR), message indicates retry.

16.4 amux config schema <agent>

Print the configuration schema for an agent, showing all recognized fields, their types, defaults, and valid ranges.

API mapping: mux.config.schema('claude') returns AgentConfigSchema.

16.5 amux config validate <agent>

Validate the current config file(s) for an agent against the schema. Prints validation results: field-level errors and warnings.

API mapping: mux.config.validate('claude', mux.config.get('claude')) returns ValidationResult.

16.6 amux config mcp list <agent>

List MCP servers configured for an agent.

API mapping: mux.config.getMcpServers('claude') returns McpServerConfig[].

16.7 amux config mcp add <agent>

Add an MCP server to the agent's config. The CLI prompts for server name, command, args, and environment variables interactively. In non-interactive mode (piped stdin), reads a JSON McpServerConfig from stdin.

API mapping: mux.config.addMcpServer('claude', serverConfig).

Error behavior:

  • Agent does not support MCP: exit code 6 (CAPABILITY_ERROR).
  • Server name already exists: exit code 7 (CONFIG_ERROR).

16.8 amux config mcp remove <agent> <server-name>

Remove an MCP server from the agent's config by name.

API mapping: mux.config.removeMcpServer('claude', 'my-server').

16.9 amux config reload [agent]

Spec-level addition: This command is not in the scope document's CLI listing (scope §21) but is specified in 08-config-and-auth.md Section 2 and Section 15.1. It maps to the ConfigManager.reload() method added by that spec.

Invalidate the config cache and re-read from disk. If agent is omitted, reloads all agents.

This is useful when external processes (the agent's own CLI, manual editing) have modified config files since the last read.

API mapping: mux.config.reload('claude') or mux.config.reload().

16.10 Examples

# Read full config
amux config get claude

# Read single field
amux config get claude model

# Set a field
amux config set claude model claude-sonnet-4-20250514

# View schema
amux config schema codex

# Validate current config
amux config validate gemini

# List MCP servers
amux config mcp list claude

# Remove an MCP server
amux config mcp remove claude my-custom-server

# Reload after external edit
amux config reload claude

17. amux profiles -- Profile Management

Manage named RunOptions presets. Profiles are stored as JSON files in ~/.agent-mux/profiles/ (global) or .agent-mux/profiles/ (project). See 02-run-options-and-profiles.md, Section 10 for the full ProfileManager specification.

17.1 Syntax

amux profiles list [flags...]
amux profiles show <name>
amux profiles set <name> [run-flags...]
amux profiles delete <name> [flags...]
amux profiles apply <name>

17.2 amux profiles list

List all available profiles from both global and project directories.

Flags:

FlagTypeDefaultDescription
--scopestringAllFilter by scope: global, project.
--jsonbooleanfalseOutput as JSON array.

Output columns (human mode):

ColumnDescription
NameProfile name.
Scopeglobal or project.
AgentDefault agent in profile, or --.
ModelDefault model in profile, or --.

API mapping: mux.profiles.list({ scope }) returns ProfileEntry[].

17.3 amux profiles show <name>

Display the resolved contents of a profile (merged global + project).

API mapping: mux.profiles.show(name) returns ResolvedProfile.

17.4 amux profiles set <name> [run-flags...]

Create or update a profile. The profile data is derived from the provided run flags. Any flag accepted by amux run (except per-run ephemeral flags) can be used.

Per-run ephemeral flags that are rejected (per 02-run-options-and-profiles.md, Section 10.3):

--cwd, --env, --run-id, --attach, --fork, --no-session, --project-id, --interactive, --quiet.

Note: --system and --system-mode are NOT rejected — systemPrompt and systemPromptMode are valid profile fields (spec 02 §10.2).

These flags correspond to RunOptions fields that are per-run ephemeral and excluded from profile storage: cwd, env, runId, attachments, systemPrompt, systemPromptMode, forkSessionId, noSession, projectId, plus CLI-only flags --interactive and --quiet.

Flags:

FlagTypeDefaultDescription
--scopestringAutoTarget scope: global or project. Defaults to project if a project directory exists, otherwise global.

API mapping: mux.profiles.set(name, profileData, { scope }).

Examples:

# Create a "fast" profile
amux profiles set fast --agent claude --model claude-sonnet-4-20250514 --yolo --max-turns 5

# Create a "careful" profile
amux profiles set careful --agent claude --thinking-effort high --deny

# Create global profile
amux profiles set shared-fast --scope global --agent gemini --max-tokens 4096

17.5 amux profiles delete <name>

Delete a profile.

Flags:

FlagTypeDefaultDescription
--scopestringBothScope to delete from: global, project. If omitted, deletes from both.

API mapping: mux.profiles.delete(name, { scope }).

17.6 amux profiles apply <name>

Resolve a profile and print the resulting RunOptions values. Does not start a run. Useful for previewing what a profile produces.

API mapping: mux.profiles.apply(name) returns Partial<RunOptions>.

17.7 Error Behavior

  • Unknown profile: exit code 9 (PROFILE_NOT_FOUND).
  • Invalid profile data: exit code 2 (VALIDATION_ERROR).

18. amux auth -- Authentication

Check and guide authentication state for agents. The CLI never writes credentials or modifies auth state -- it only inspects and provides guidance.

18.1 Syntax

amux auth check [agent]
amux auth setup <agent>

18.2 amux auth check [agent]

Check authentication state. If agent is omitted, checks all agents.

Flags:

FlagTypeDefaultDescription
--jsonbooleanfalseOutput as JSON.

Output (human mode, single agent):

Agent: claude
Status: authenticated
Method: api-key
Identity: user@example.com
Checked: 2025-01-15T10:30:00Z

Output (human mode, all agents):

AgentStatusMethodIdentity
claudeauthenticatedapi-keyuser@...
codexunauthenticated----
geminiauthenticatedoauthuser@...
............

API mapping:

CLISDK
amux auth check claudemux.auth.check('claude') returns AuthState
amux auth checkmux.auth.checkAll() returns Record<AgentName, AuthState>

18.3 amux auth setup <agent>

Print setup guidance for authenticating with an agent. Does not perform authentication itself.

Output: Structured guidance including:

  • Required steps (numbered list).
  • Environment variables to set.
  • Commands to run.
  • Documentation links.
  • Platform-specific notes.

API mapping: mux.auth.getSetupGuidance('claude') returns AuthSetupGuidance.

18.4 Error Behavior

  • Unknown agent: exit code 3 (AGENT_NOT_FOUND).
  • auth check with unauthenticated result: exits with code 0 (the check succeeded; the result is "unauthenticated"). The status is reported in the output.

18b. amux skill -- Skill Management

File-convention only (no native harness command). Skills are folders containing a SKILL.md plus assets, installed under per-harness conventions.

amux skill list <agent> [--global|--project]
amux skill add <agent> <source-folder> [--name <n>] [--force] [--global|--project]
amux skill remove <agent> <name> [--global|--project]
amux skill where <agent>
amux skill agents # list supported harnesses

Supported harnesses: claude, codex, cursor, opencode, gemini, copilot. Paths: $HOME/.<agent>/skills/ (global) or <cwd>/.<agent>/skills/ (project).


18c. amux agent -- Sub-agent Management

File-convention only. Copies agent definition files (markdown/yaml/json) into per-harness sub-agent directories.

amux agent list <agent> [--global|--project]
amux agent add <agent> <source> [--name <n>] [--force] [--global|--project]
amux agent remove <agent> <name> [--global|--project]
amux agent where <agent>
amux agent agents # list supported harnesses

Supported: claude, claude-code, codex, cursor, opencode. Paths: $HOME/.<agent>/agents/ (global) or <cwd>/.<agent>/agents/ (project).

References:


18d. amux hooks -- Hook Management

Manage hook registrations and dispatch. Backed by HookConfigManager in core.

amux hooks <agent> discover # native hook types
amux hooks <agent> list
amux hooks <agent> add <hookType> [--handler builtin|command|script] [--target <t>] [--id <id>] [--global]
amux hooks <agent> remove <id> [--global]
amux hooks <agent> set <id> [--priority N] [--enabled true|false] [--target <t>]
amux hooks <agent> handle <hookType> # stdin JSON → dispatch → result

Storage: $HOME/.amux/hooks.json (global), <cwd>/.amux/hooks.json (project).


19. amux init -- Project Initialization

Create the .agent-mux/ directory in the current working directory with default configuration.

19.1 Syntax

amux init [flags...]

19.2 Behavior

  1. Creates .agent-mux/ in the current directory (or the directory specified by --project-dir).
  2. Creates .agent-mux/config.json with an empty object {}.
  3. Creates .agent-mux/profiles/ directory.
  4. Prints confirmation to stdout.
  5. If .agent-mux/ already exists, prints a message and exits with code 0 (idempotent).

19.3 Flags

FlagTypeDefaultDescription
--jsonbooleanfalseOutput result as JSON.

20. Signal Handling

The CLI handles process signals for graceful shutdown and run control.

20.1 Unix (macOS, Linux)

SignalBehavior
SIGINT (Ctrl+C)First: sends interrupt() to the active RunHandle. The agent may handle this gracefully (stop current tool call, remain alive). Second within 1 second: sends abort() to force shutdown. Third or if no active run: exits immediately.
SIGTERMInitiates graceful shutdown: sends SIGINT to all child processes, waits the grace period (default 5000ms), then sends SIGKILL to any remaining children. Exits with code 13 (ABORTED).
SIGKILLCannot be caught. OS terminates the process. Child processes receive SIGKILL via process group.
SIGTSTP (Ctrl+Z)Sends pause() to the active RunHandle.
SIGCONTSends resume() to the active RunHandle.

20.2 Windows

Windows does not have POSIX signals. The CLI uses alternative mechanisms:

EventBehavior
Ctrl+CHandled via process.on('SIGINT') (Node.js emulation). Behavior matches Unix SIGINT above.
Ctrl+BreakSends abort() to the active RunHandle. Equivalent to double-SIGINT on Unix.
Console close / SIGTERMprocess.on('SIGTERM') triggers graceful shutdown. Child processes are terminated via TerminateProcess Win32 API after the grace period.
SIGTSTP / SIGCONTNot available on Windows. Pause/resume is only available through REPL commands (/pause, /resume).

20.3 Zombie Prevention

All spawned child processes are registered in a cleanup list. On Node.js beforeExit and exit events, the CLI sends SIGKILL (Unix) or TerminateProcess (Windows) to any still-running children. This prevents zombie processes.

The grace period for graceful shutdown is configurable via AGENT_MUX_GRACE_PERIOD_MS environment variable (default: 5000ms).


21. Environment Variables

The following environment variables are recognized by the CLI. CLI flags take precedence over environment variables.

VariableTypeDefaultDescriptionEquivalent Flag
AGENT_MUX_CONFIG_DIRstring~/.agent-mux/Override global config directory.--config-dir
AGENT_MUX_PROJECT_DIRstring.agent-mux/Override project config directory.--project-dir
AGENT_MUX_DEFAULT_AGENTAgentName--Default agent when none is specified.--agent (global)
AGENT_MUX_GRACE_PERIOD_MSnumber5000Grace period in milliseconds before SIGKILL on shutdown.--
NO_COLORany--Disable colored output when set to any non-empty value. See no-color.org.--no-color
DEBUGstring--When set to amux or amux:*, enables debug logging to stderr.--debug
FORCE_COLORany--Force colored output even when stdout is not a TTY. Overridden by NO_COLOR and --no-color.--

21.1 Resolution Order

For any configuration value, the resolution order is (highest precedence first):

  1. CLI flags (e.g., --config-dir).
  2. Environment variables (e.g., AGENT_MUX_CONFIG_DIR).
  3. Project config file (.agent-mux/config.json).
  4. Global config file (~/.agent-mux/config.json).
  5. Adapter defaults.

This mirrors the SDK resolution order defined in 01-core-types-and-client.md, Section 4.1.1 and 02-run-options-and-profiles.md, Section 7.


22. Shell Completion

The CLI provides shell completion scripts for interactive use.

22.1 Generating Completion Scripts

# Bash
amux --completions bash > ~/.local/share/bash-completion/completions/amux
# or
amux --completions bash >> ~/.bashrc

# Zsh
amux --completions zsh > ~/.zfunc/_amux
# or add to .zshrc: fpath=(~/.zfunc $fpath); autoload -Uz compinit; compinit

# Fish
amux --completions fish > ~/.config/fish/completions/amux.fish

# PowerShell
amux --completions powershell >> $PROFILE

22.2 Completion Scope

Completions are provided for:

  • Top-level commands (run, install, adapters, capabilities, models, plugin, mcp, sessions, cost, config, profiles, auth, init).
  • Subcommands (e.g., plugin list, mcp install, config mcp add).
  • Flag names and their valid values (e.g., --agent completes to registered agent names, --thinking-effort completes to low, medium, high, max).
  • Agent names (positional argument for many commands).
  • Model IDs (for --model flag, dynamically queried from the model registry).
  • Profile names (for --profile flag).

23. Error Output Format

23.1 Human-Readable Errors

In human mode, errors are printed to stderr with the following format:

error: <message>
code: <ErrorCode>
agent: <agent> (when applicable)
hint: <actionable guidance> (when available)

Example:

error: Agent 'cursor' does not support native plugin CLI commands
code: CAPABILITY_ERROR
agent: cursor
hint: Agents with native plugin CLI: claude, gemini, codex, copilot, opencode

23.2 JSON Errors

In JSON mode (--json), errors are emitted as a JSON object to stdout:

{
"ok": false,
"error": {
"code": "CAPABILITY_ERROR",
"message": "Agent 'cursor' does not support native plugin CLI commands",
"agent": "cursor",
"recoverable": false
}
}

23.3 JSONL Run Errors

During amux run --json, errors appear as typed events in the JSONL stream:

{"type":"error","runId":"01J...","agent":"claude","timestamp":1718000000000,"code":"AUTH_ERROR","message":"Authentication required","recoverable":false}

The type field matches the error event types defined in 04-agent-events.md: auth_error, rate_limit_error, context_exceeded, crash, error.

23.4 Canonical Error Codes

All error codes used by the CLI are defined in 01-core-types-and-client.md, Section 3.1:

Error CodeDescription
CAPABILITY_ERRORAgent/model lacks required capability.
VALIDATION_ERRORInput fails schema or range validation.
AUTH_ERRORAuthentication required but not configured.
AGENT_NOT_FOUNDNo adapter registered for the agent name.
AGENT_NOT_INSTALLEDAdapter exists but CLI binary not on $PATH.
AGENT_CRASHAgent subprocess terminated unexpectedly.
SPAWN_ERRORFailed to spawn agent subprocess.
TIMEOUTRun exceeded wall-clock timeout.
INACTIVITY_TIMEOUTRun exceeded inactivity timeout.
PARSE_ERRORFailed to parse agent output or file.
CONFIG_ERRORConfig file read/write/parse failure.
CONFIG_LOCK_ERRORAdvisory file lock acquisition failed.
SESSION_NOT_FOUNDSpecified session does not exist.
PROFILE_NOT_FOUNDSpecified profile does not exist.
PLUGIN_ERRORPlugin operation failed.
RATE_LIMITEDAgent reported rate limiting.
CONTEXT_EXCEEDEDAgent's context window exceeded.
ABORTEDRun was aborted by user.
INTERNALInternal error in agent-mux.

24. Platform-Specific Notes

24.1 Windows

  • Signal handling: Windows lacks POSIX signals. See Section 20.2 for the alternative mechanisms used.
  • TTY detection: process.stdin.isTTY and process.stdout.isTTY work correctly on Windows terminals (cmd.exe, PowerShell, Windows Terminal). ConPTY is used for PTY-based agents.
  • PTY support: node-pty uses ConPTY on Windows 10 1809+ for agents requiring PTY (OpenClaw, some interactive modes).
  • Path handling: All internal paths use forward slashes. CLI output uses the platform-native separator. Config file paths (--config-dir, --project-dir) accept both forward and backslashes on Windows.
  • Color support: ANSI color codes are supported in Windows Terminal and PowerShell 7+. Legacy cmd.exe may not render colors correctly; --no-color is recommended in that environment.
  • Hermes on Windows: Hermes requires WSL2 on Windows. The hermes adapter detects whether WSL2 is available and spawns hermes through wsl when running on native Windows. If WSL2 is not detected, the adapter reports installed: false with guidance to install WSL2.
  • omp on Windows: omp has partial Windows support (see agent-mux-scope.md, Section 23). Some features may not work correctly on Windows.
  • Shell completion: PowerShell completion is supported via Register-ArgumentCompleter. See Section 22.1.

24.2 macOS

  • Homebrew: Several agents offer Homebrew install methods (claude, opencode). The amux install command prefers Homebrew on macOS when available.
  • Config paths: Global config at ~/ ($HOME, typically /Users/<user>/).

24.3 Linux

  • XDG compliance: Some agents store config in XDG-compliant locations (e.g., ~/.config/ for Gemini, Copilot, OpenCode). The adapters handle this transparently.
  • Config paths: Global config at ~/ ($HOME, typically /home/<user>/).

25. Command Summary

Quick reference of all commands and their SDK method mappings.

CommandSubcommandSDK Method
amux run--mux.run()
amux install--mux.adapters.installInstructions()
amux adapterslistmux.adapters.list() + mux.adapters.installed()
amux adaptersdetectmux.adapters.detect()
amux capabilities--mux.adapters.capabilities() + mux.models.model()
amux modelslistmux.models.catalog()
amux modelsgetmux.models.model()
amux modelsrefreshmux.models.refresh()
amux modelscurrentmux.config.getModelSelection() + mux.models.model()
amux modelssetmux.models.validate() + mux.config.setModelSelection()
amux pluginlistNative CLI delegation
amux plugininstallNative CLI delegation
amux pluginuninstallNative CLI delegation
amux pluginupdateNative CLI delegation
amux pluginmarketplaceNative CLI delegation
amux mcplistmux.mcp.list()
amux mcpinstallmux.mcp.install()
amux mcpuninstallmux.mcp.uninstall()
amux sessionslistmux.sessions.list()
amux sessionsshowmux.sessions.export()
amux sessionssearchmux.sessions.search()
amux sessionsexportmux.sessions.export()
amux sessionsdiffmux.sessions.diff()
amux sessionsresumemux.run({ sessionId })
amux sessionsforkmux.run({ forkSessionId })
amux costreportmux.sessions.totalCost()
amux configgetmux.config.get() / mux.config.getField()
amux configsetmux.config.setField()
amux configschemamux.config.schema()
amux configvalidatemux.config.validate()
amux configmcp listmux.config.getMcpServers()
amux configmcp addmux.config.addMcpServer()
amux configmcp removemux.config.removeMcpServer()
amux configreloadmux.config.reload()
amux profileslistmux.profiles.list()
amux profilesshowmux.profiles.show()
amux profilessetmux.profiles.set()
amux profilesdeletemux.profiles.delete()
amux profilesapplymux.profiles.apply()
amux authcheckmux.auth.check() / mux.auth.checkAll()
amux authsetupmux.auth.getSetupGuidance()
amux skilllist / add / remove / where / agentsFile-convention (copy into .{agent}/skills/)
amux agentlist / add / remove / where / agentsFile-convention (copy into .{agent}/agents/)
amux hooksdiscover / list / add / remove / set / handleHookConfigManager (core)
amux doctor--Capability / auth / runtime diagnostics
amux tui--Launch interactive Ink UI (@a5c-ai/agent-mux-tui)
amux init--createClient() + directory creation

26. Version and Help

# Print version
amux --version
amux -V

# Print help
amux --help
amux -h

# Command-specific help
amux run --help
amux plugin --help
amux mcp --help

--version prints the package version of @a5c-ai/agent-mux-cli and exits with code 0.

--help prints the usage summary for the command or subcommand and exits with code 0. Help text includes a brief description, syntax, available flags, and examples.


27. Type Reference Summary

This section lists the key types referenced throughout the CLI spec and where they are defined.

TypeSpecSection
AgentName, BuiltInAgentName01-core-types-and-client.md1.4
ErrorCode01-core-types-and-client.md3.1
AgentMuxError01-core-types-and-client.md3.1
CapabilityError01-core-types-and-client.md3.2
ValidationError01-core-types-and-client.md3.3
GlobalConfig01-core-types-and-client.md4.1.2
ClientOptions01-core-types-and-client.md5.1.1
InstalledAgentInfo01-core-types-and-client.md5.3.1
InstallMethod01-core-types-and-client.md5.3.1
RunOptions02-run-options-and-profiles.md2
ProfileData02-run-options-and-profiles.md10.2
ProfileManager02-run-options-and-profiles.md10
RunHandle03-run-handle-and-interaction.md2
RunResult03-run-handle-and-interaction.md3
AgentEvent04-agent-events.md2
AgentCapabilities06-capabilities-and-models.md2
ModelCapabilities06-capabilities-and-models.md2
SessionManager, SessionSummary, Session07-session-manager.md2
ConfigManager, AgentConfig08-config-and-auth.md2
AuthManager, AuthState08-config-and-auth.md8
PluginManager, InstalledPlugin, PluginListing09-plugin-manager.md2
McpServerConfig02-run-options-and-profiles.md4
RetryPolicy01-core-types-and-client.md5.1.1
CostRecord, CostSummary01-core-types-and-client.md4.2.3

Implementation Status (2026-04-12)

Five command surfaces have landed that extend the original spec. All are implemented under packages/cli/src/commands/.

amux install <agent> [--version V] [--force] [--dry-run] [--json]

Invokes the adapter's install(). Emits an InstallResult. Non-zero exit if ok is false. Used by the Dockerfile with HARNESSES=<csv> to pre-install harnesses into an image.

amux update <agent> [--dry-run] [--json]

Invokes the adapter's update(). Same result shape.

amux detect [<agent> | --all] [--json]

Invokes detectInstallation(). With --all iterates every registered adapter; with a specific agent returns one record. Prints installed, version, path, notes.

amux detect-host [--json]

Calls client.detectHost() and prints HostHarnessInfo { agent, confidence, source, matchedSignals } or "no harness detected". Confidence: high (≥ 2 env signals), medium (1 env signal), low (argv heuristic only).

amux remote install|update <host> [--mode ssh|docker|k8s|local] [--harness <agent>] [--force] [--json]

Four-step bootstrap over the chosen invocation mode:

  1. Probe amux --version on target.
  2. If missing or update/--force: npm install -g @a5c-ai/agent-mux-cli (or npm update -g).
  3. amux install <harness> (or amux update <harness>) on target.
  4. Verify with amux detect --all --json.

Default --mode is ssh when <host> is given, else local. Default --harness is claude-code.

Global flags actually accepted

From packages/cli/src/parse-args.ts the recognized globals are: --agent/-a, --model/-m, --json, --debug, --config-dir, --project-dir, --no-color, --version/-V, --help/-h, --completions <shell>. The top-level commands: run, install, uninstall, update, detect, detect-host, remote, adapters, capabilities, models, plugin, mcp, sessions, cost, config, profiles, auth, init, version, help.