From ACPX
Definitive command and behavior reference for the acpx CLI, including grammar, options, session rules, output modes, permissions, and exit codes.
How this command is triggered — by the user, by Claude, or both
Slash command
/acpx:cliuse-acpx/references/Files this command reads when invoked
The summary Claude sees in its command listing — used to decide when to auto-load this command
## Overview `acpx` is a headless ACP client for scriptable agent workflows. Default behavior is conversational: - prompt commands use a persisted session - session lookup is scoped by agent command and working directory (plus optional session name) - `exec` runs one prompt in a temporary session ## Full command grammar Global options apply to all commands. `<agent>` can be: - built-in friendly name (see Built-in agent registry in the use-acpx skill) - unknown token (treated as raw command) - overridden by `--agent <command>` escape hatch Prompt options: Notes: - Top-level `pro...
acpx is a headless ACP client for scriptable agent workflows.
Default behavior is conversational:
exec runs one prompt in a temporary sessionGlobal options apply to all commands.
acpx [global_options] [prompt_text...]
acpx [global_options] prompt [prompt_options] [prompt_text...]
acpx [global_options] exec [prompt_options] [prompt_text...]
acpx [global_options] cancel [-s <name>]
acpx [global_options] set-mode <mode> [-s <name>]
acpx [global_options] set <key> <value> [-s <name>]
acpx [global_options] status [-s <name>]
acpx [global_options] sessions [list | new [--name <name>] | ensure [--name <name>] | close [name] | show [name] | history [name] [--limit <count>]]
acpx [global_options] config [show | init]
acpx [global_options] <agent> [prompt_options] [prompt_text...]
acpx [global_options] <agent> prompt [prompt_options] [prompt_text...]
acpx [global_options] <agent> exec [prompt_options] [prompt_text...]
acpx [global_options] <agent> cancel [-s <name>]
acpx [global_options] <agent> set-mode <mode> [-s <name>]
acpx [global_options] <agent> set <key> <value> [-s <name>]
acpx [global_options] <agent> status [-s <name>]
acpx [global_options] <agent> sessions [list | new [--name <name>] | ensure [--name <name>] | close [name] | show [name] | history [name] [--limit <count>]]
<agent> can be:
--agent <command> escape hatchPrompt options:
-s, --session <name> Use named session instead of cwd default
--no-wait Queue prompt and return immediately if session is busy
-f, --file <path> Read prompt text from file (`-` means stdin)
Notes:
prompt, exec, cancel, set-mode, set, sessions, and bare acpx <prompt> default to codex.acpx reads prompt text from stdin when piped.--file works for implicit prompt, prompt, and exec commands.acpx with no args in an interactive terminal shows help.All global options:
| Option | Description | Details |
|---|---|---|
--agent <command> | Raw ACP agent command (escape hatch) | Do not combine with positional agent token. |
--cwd <dir> | Working directory | Defaults to current directory. Stored as absolute path for scoping. |
--approve-all | Auto-approve all permissions | Permission mode approve-all. |
--approve-reads | Auto-approve reads/searches, prompt for others | Default permission mode. |
--deny-all | Deny all permissions | Permission mode deny-all. |
--format <fmt> | Output format | text (default), json, quiet. |
--json-strict | Strict JSON mode | Requires --format json; suppresses non-JSON stderr output. |
--non-interactive-permissions <policy> | Non-TTY prompt policy | deny (default) or fail when approval prompt cannot be shown. |
--timeout <seconds> | Max wait time for agent response | Must be positive. Decimal seconds allowed. |
--ttl <seconds> | Queue owner idle TTL before shutdown | Default 300. 0 disables TTL. |
--verbose | Enable verbose logs | Prints ACP/debug details to stderr. |
Permission flags are mutually exclusive. Using more than one of --approve-all, --approve-reads, --deny-all is a usage error.
acpx --approve-all codex 'apply this patch and run tests'
acpx --approve-reads codex 'inspect the repo and propose a plan'
acpx --deny-all codex 'summarize this code without running tools'
acpx --non-interactive-permissions fail codex 'fail fast when prompt cannot be shown'
acpx --cwd ~/repos/api codex 'review auth middleware'
acpx --format json codex exec 'summarize open TODO items'
acpx --format json --json-strict codex exec 'machine-safe JSON output'
acpx --timeout 120 codex 'investigate flaky test failures'
acpx --ttl 30 codex 'keep queue owner warm for quick follow-up'
acpx --verbose codex 'debug adapter startup issues'
Each agent command supports the same shape.
piacpx [global_options] pi [prompt_options] [prompt_text...]
acpx [global_options] pi prompt [prompt_options] [prompt_text...]
acpx [global_options] pi exec [prompt_text...]
acpx [global_options] pi sessions [list | new [--name <name>] | ensure [--name <name>] | close [name]]
Built-in command mapping: pi -> npx pi-acp
openclawacpx [global_options] openclaw [prompt_options] [prompt_text...]
acpx [global_options] openclaw prompt [prompt_options] [prompt_text...]
acpx [global_options] openclaw exec [prompt_text...]
acpx [global_options] openclaw sessions [list | new [--name <name>] | ensure [--name <name>] | close [name]]
Built-in command mapping: openclaw -> openclaw acp
For repo-local OpenClaw checkouts, override the built-in command in config:
{
"agents": {
"openclaw": {
"command": "env OPENCLAW_HIDE_BANNER=1 OPENCLAW_SUPPRESS_NOTES=1 node scripts/run-node.mjs acp --url ws://127.0.0.1:18789 --token-file ~/.openclaw/gateway.token --session agent:main:main"
}
}
}
codexacpx [global_options] codex [prompt_options] [prompt_text...]
acpx [global_options] codex prompt [prompt_options] [prompt_text...]
acpx [global_options] codex exec [prompt_text...]
acpx [global_options] codex sessions [list | new [--name <name>] | ensure [--name <name>] | close [name]]
Built-in command mapping: codex -> npx @zed-industries/codex-acp
claudeacpx [global_options] claude [prompt_options] [prompt_text...]
acpx [global_options] claude prompt [prompt_options] [prompt_text...]
acpx [global_options] claude exec [prompt_text...]
acpx [global_options] claude sessions [list | new [--name <name>] | ensure [--name <name>] | close [name]]
Built-in command mapping: claude -> npx -y @zed-industries/claude-agent-acp
Unknown agent names are treated as raw commands:
acpx [global_options] my-agent [prompt_options] [prompt_text...]
acpx [global_options] my-agent exec [prompt_text...]
acpx [global_options] my-agent sessions
prompt subcommand (explicit)Persistent-session prompt command:
acpx [global_options] <agent> prompt [prompt_options] [prompt_text...]
acpx [global_options] prompt [prompt_options] [prompt_text...]
Behavior:
(agentCommand, cwd, name?)4 and guidance to run sessions new--no-wait returns after queue acknowledgementThe agent command itself also has an implicit prompt form:
acpx [global_options] <agent> [prompt_options] [prompt_text...]
acpx [global_options] [prompt_text...] # defaults to codex
exec subcommandOne-shot prompt (no saved session):
acpx [global_options] <agent> exec [prompt_options] [prompt_text...]
acpx [global_options] exec [prompt_options] [prompt_text...] # defaults to codex
Behavior:
--file <path>, and --file -cancel commandacpx [global_options] <agent> cancel [-s <name>]
acpx [global_options] cancel [-s <name>] # defaults to codex
Behavior:
session/cancel through queue-owner IPC when a prompt is running.nothing to cancel and exits success.set-mode commandacpx [global_options] <agent> set-mode <mode> [-s <name>]
acpx [global_options] set-mode <mode> [-s <name>] # defaults to codex
Behavior:
session/set_mode.<mode> values are adapter-defined (not globally standardized across all ACP adapters).Invalid params).set commandacpx [global_options] <agent> set <key> <value> [-s <name>]
acpx [global_options] set <key> <value> [-s <name>] # defaults to codex
Behavior:
session/set_config_option.sessions subcommandacpx [global_options] <agent> sessions
acpx [global_options] <agent> sessions list
acpx [global_options] <agent> sessions new
acpx [global_options] <agent> sessions new --name <name>
acpx [global_options] <agent> sessions ensure
acpx [global_options] <agent> sessions ensure --name <name>
acpx [global_options] <agent> sessions close
acpx [global_options] <agent> sessions close <name>
acpx [global_options] <agent> sessions show
acpx [global_options] <agent> sessions show <name>
acpx [global_options] <agent> sessions history
acpx [global_options] <agent> sessions history <name> [--limit <count>]
acpx [global_options] sessions ... # defaults to codex
Behavior:
sessions and sessions list are equivalentagentCommand (across all cwd values)sessions new creates a fresh cwd-scoped default sessionsessions new --name <name> creates a fresh named session for cwdsessions ensure returns the nearest matching active session or creates one for cwdsessions ensure --name <name> does the same for named sessionssessions close soft-closes the current cwd default sessionsessions close <name> soft-closes current cwd named sessionsessions show [name] displays stored session metadatasessions history [name] displays stored turn history previews (default 20, configurable with --limit)status commandacpx [global_options] <agent> status
acpx [global_options] <agent> status -s <name>
acpx [global_options] status
acpx [global_options] status -s <name>
Shows local process status for the cwd-scoped session:
running, dead, or no-sessionStatus checks are local and PID-based (kill(pid, 0) semantics).
config commandacpx [global_options] config show
acpx [global_options] config init
config show prints the resolved config from global + project files.config init writes a default global config template if missing.Config files:
~/.acpx/config.json<cwd>/.acpxrc.json (merged on top of global)Supported keys:
{
"defaultAgent": "codex",
"defaultPermissions": "approve-all",
"nonInteractivePermissions": "deny",
"authPolicy": "skip",
"ttl": 300,
"timeout": null,
"format": "text",
"agents": {
"my-custom": { "command": "./bin/my-acp-server" }
},
"auth": {
"my_auth_method_id": "credential-value"
}
}
CLI flags always override config values.
--agent escape hatch--agent <command> sets a raw adapter command explicitly.
Examples:
acpx --agent ./my-custom-acp-server 'do something'
acpx --agent 'node ./scripts/acp-dev-server.mjs --mode ci' exec 'summarize changes'
Rules:
--agent in one command.agentCommand).--agent is a usage error.Session records are stored in:
~/.acpx/sessions/*.json
For prompt commands:
.git while walking up from absoluteCwd.absoluteCwd up to that git root (inclusive).absoluteCwd (no parent-directory walk).(agentCommand, dir, optionalName).4 and print guidance to create one via sessions new.Use sessions new [--name <name>] when you explicitly want a fresh scoped session.
Use sessions ensure [--name <name>] when you want idempotent "get-or-create" behavior.
If a saved session PID is dead, acpx respawns the agent, tries session/load, and transparently falls back to session/new when loading fails.
When a prompt is already in flight for a session, acpx uses a per-session queue owner process:
acpx invocations enqueue prompts through local IPC--ttl, default 300s)--no-waitCtrl+C) during an active turn, acpx sends session/cancel first, waits briefly for cancelled completion, then force-kills only if neededclosed: true and closedAtsessions history-s, --session <name> adds name into the scope key so multiple parallel conversations can coexist in the same repo and agent command.
--cwd sets the starting point for directory-walk routing (bounded by git root) and the exact scope directory when creating sessions via sessions new.
--format controls output mode:
text (default): human-readable streamjson: raw ACP NDJSON stream for automationquiet: assistant text only--format json --json-strict: same ACP NDJSON stream, with non-JSON stderr output suppressedtext: assistant text, tool status blocks, client-operation logs, plan updates, and [done] <reason>json: one raw ACP JSON-RPC message per linequiet: concatenated assistant text onlyACP message examples:
{"jsonrpc":"2.0","id":"req-1","method":"session/prompt","params":{"sessionId":"019c...","prompt":"hi"}}
{"jsonrpc":"2.0","method":"session/update","params":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"Hello"}}}
{"jsonrpc":"2.0","id":"req-1","result":{"stopReason":"end_turn"}}
Hard rule for the ACP stream:
type/stream wrapper fields,When --format json is used:
sessions list/show/history) emit local JSON documents (not ACP stream traffic).sessions list with text: tab-separated id, name, cwd, lastUsedAt (closed sessions include a [closed] marker next to id)sessions list with json: a single JSON array of session recordssessions list with quiet: one session id per line (closed sessions include [closed])sessions show with text: key/value metadata dumpsessions show with json: full session record objectsessions history with text: tab-separated timestamp role textPreview entriessessions history with json: object containing entries arraystatus with text: key/value process status linesChoose exactly one mode:
--approve-all: auto-approve all permission requests--approve-reads: auto-approve read/search requests, prompt for other kinds (default)--deny-all: auto-deny/reject requests when possiblePrompting behavior in --approve-reads:
Allow <tool>? (y/N) for non-read/search requestsNon-interactive prompt policy:
--non-interactive-permissions deny: deny non-read/search prompts when no TTY (default)--non-interactive-permissions fail: fail with PERMISSION_PROMPT_UNAVAILABLE| Code | Meaning |
|---|---|
0 | Success |
1 | Agent/protocol/runtime error |
2 | CLI usage error |
3 | Timeout |
4 | No session found (prompt requires an explicit sessions new) |
5 | Permission denied (permission requested, none approved, and at least one denied/cancelled) |
130 | Interrupted (SIGINT/SIGTERM) |
No acpx-specific environment variables are currently defined.
Related runtime behavior:
~/.acpx/sessions)# Review a PR in a dedicated named session
acpx --cwd ~/repos/shop codex sessions new --name pr-842
acpx --cwd ~/repos/shop codex -s pr-842 \
'Review PR #842, list risks, and propose a minimal patch'
# Continue that same PR review later
acpx --cwd ~/repos/shop codex -s pr-842 \
'Now draft commit message and rollout checklist'
# Parallel workstreams in one repo
acpx codex sessions new --name backend
acpx codex sessions new --name docs
acpx codex -s backend 'fix checkout timeout'
acpx codex -s docs 'document payment retry behavior'
# One-shot ask with no saved context
acpx claude exec 'summarize src/session.ts in 5 bullets'
# Manage sessions
acpx codex sessions
acpx codex sessions new --name docs
acpx codex sessions show docs
acpx codex sessions history docs --limit 10
acpx codex sessions close docs
acpx codex status
# Prompt from file/stdin
echo 'triage failing tests' | acpx codex
acpx codex --file prompt.md
acpx codex --file - 'also check lint warnings'
# Config inspection
acpx config show
acpx config init
# JSON automation pipeline
acpx --format json codex exec 'review latest diff for security issues' \
| jq -r 'select(.type=="tool_call") | [.status, .title] | @tsv'
/cliSelects and executes optimal CLI tools for a given task using terminal-native expert patterns, with optional preference like 'modern' or 'standard'.
npx claudepluginhub est7/dotclaude --plugin acpx