#CLI Reference
coterm provides both a CLI tool and a Unix socket for programmatic control. Every command is available through both interfaces.
#Socket
| Build | Path |
|---|---|
| Release | /tmp/coterm.sock |
| Debug | /tmp/coterm-debug.sock |
| Tagged debug build | /tmp/coterm-debug-<tag>.sock |
Override with the COTERM_SOCKET_PATH environment variable. Send one newline-terminated JSON request per call:
{"id":"req-1","method":"workspace.list","params":{}}
// Response:
{"id":"req-1","ok":true,"result":{"workspaces":[...]}}{"command":"..."} are not supported.#Access modes
| Mode | Description | How to enable |
|---|---|---|
| Off | Socket disabled | Settings UI or COTERM_SOCKET_MODE=off |
| Coterm processes only | Only processes spawned inside coterm terminals can connect. | Default mode in Settings UI |
| allowAll | Allow any local process to connect (no ancestry check). | Environment override only: COTERM_SOCKET_MODE=allowAll |
#CLI options
| Flag | Description |
|---|---|
--socket PATH | Custom socket path |
--json | Output in JSON format |
--window ID | Target a specific window |
--workspace ID | Target a specific workspace |
--surface ID | Target a specific surface |
--id-format refs|uuids|both | Control identifier format in JSON output |
#Workspace commands
list-workspaces
List all open workspaces.
coterm list-workspaces
coterm list-workspaces --json{"id":"ws-list","method":"workspace.list","params":{}}new-workspace
Create a new workspace.
coterm new-workspace{"id":"ws-new","method":"workspace.create","params":{}}select-workspace
Switch to a specific workspace.
coterm select-workspace --workspace <id>{"id":"ws-select","method":"workspace.select","params":{"workspace_id":"<id>"}}current-workspace
Get the currently active workspace.
coterm current-workspace
coterm current-workspace --json{"id":"ws-current","method":"workspace.current","params":{}}close-workspace
Close a workspace.
coterm close-workspace --workspace <id>{"id":"ws-close","method":"workspace.close","params":{"workspace_id":"<id>"}}#Split commands
new-split
Create a new split pane. Directions: left, right, up, down.
coterm new-split right
coterm new-split down{"id":"split-new","method":"surface.split","params":{"direction":"right"}}list-panels
List all surfaces in the current workspace.
coterm list-panels
coterm list-panels --json{"id":"surface-list","method":"surface.list","params":{}}list-pane-surfaces
List surfaces in the focused pane.
coterm list-pane-surfaces
coterm list-pane-surfaces --json{"id":"pane-surfaces","method":"pane.surfaces","params":{}}focus-panel
Focus a specific surface.
coterm focus-panel --panel <id>{"id":"surface-focus","method":"surface.focus","params":{"surface_id":"<id>"}}#Input commands
send
Send text input to the focused terminal.
coterm send "echo hello"
coterm send "ls -la\n"{"id":"send-text","method":"surface.send_text","params":{"text":"echo hello\n"}}send-key
Send a key press. Keys: enter, tab, escape, backspace, delete, up, down, left, right.
coterm send-key enter{"id":"send-key","method":"surface.send_key","params":{"key":"enter"}}send --surface
Send text to a specific surface.
coterm send --surface <id> "command"{"id":"send-surface","method":"surface.send_text","params":{"surface_id":"<id>","text":"command"}}send-key --surface
Send a key press to a specific surface.
coterm send-key --surface <id> enter{"id":"send-key-surface","method":"surface.send_key","params":{"surface_id":"<id>","key":"enter"}}#Notification commands
notify
Send a notification.
coterm notify --title "Title" --body "Body"
coterm notify --title "T" --subtitle "S" --body "B"{"id":"notify","method":"notification.create","params":{"title":"Title","subtitle":"S","body":"Body"}}list-notifications
List all notifications.
coterm list-notifications
coterm list-notifications --json{"id":"notif-list","method":"notification.list","params":{}}clear-notifications
Clear all notifications.
coterm clear-notifications{"id":"notif-clear","method":"notification.clear","params":{}}#Sidebar metadata commands
Set status pills, progress bars, and log entries in the sidebar for any workspace. Useful for build scripts, CI integrations, and AI coding agents that want to surface state at a glance.
set-status
Set a sidebar status pill. Use a unique key so different tools can manage their own entries.
coterm set-status build "compiling" --icon hammer --color "#ff9500" --priority 80
coterm set-status deploy "v1.2.3" --workspace workspace:2set_status build compiling --icon=hammer --color=#ff9500 --priority=80 --tab=<workspace-uuid>clear-status
Remove a sidebar status entry by key.
coterm clear-status buildclear_status build --tab=<workspace-uuid>list-status
List all sidebar status entries for a workspace.
coterm list-statuslist_status --tab=<workspace-uuid>set-progress
Set a progress bar in the sidebar (0.0 to 1.0).
coterm set-progress 0.5 --label "Building..."
coterm set-progress 1.0 --label "Done"set_progress 0.5 --label=Building... --tab=<workspace-uuid>clear-progress
Clear the sidebar progress bar.
coterm clear-progressclear_progress --tab=<workspace-uuid>log
Append a log entry to the sidebar. Levels: info, progress, success, warning, error.
coterm log "Build started"
coterm log --level error --source build "Compilation failed"
coterm log --level success -- "All 42 tests passed"log --level=error --source=build --tab=<workspace-uuid> -- Compilation failedclear-log
Clear all sidebar log entries.
coterm clear-logclear_log --tab=<workspace-uuid>list-log
List sidebar log entries.
coterm list-log
coterm list-log --limit 5list_log --limit=5 --tab=<workspace-uuid>sidebar-state
Dump all sidebar metadata (cwd, git branch, ports, status, progress, logs).
coterm sidebar-state
coterm sidebar-state --workspace workspace:2sidebar_state --tab=<workspace-uuid>#Utility commands
ping
Check if coterm is running and responsive.
coterm ping{"id":"ping","method":"system.ping","params":{}}
// Response: {"id":"ping","ok":true,"result":{"pong":true}}capabilities
List available socket methods and current access mode.
coterm capabilities
coterm capabilities --json{"id":"caps","method":"system.capabilities","params":{}}identify
Show focused window/workspace/pane/surface context.
coterm identify
coterm identify --json{"id":"identify","method":"system.identify","params":{}}#Environment variables
| Variable | Description |
|---|---|
COTERM_SOCKET_PATH | Override the socket path used by CLI and integrations |
COTERM_SOCKET_ENABLE | Force-enable/disable socket (1/0, true/false, on/off) |
COTERM_SOCKET_MODE | Override access mode (cotermOnly, allowAll, off). Also accepts coterm-only/coterm_only and allow-all/allow_all |
COTERM_WORKSPACE_ID | Auto-set: current workspace ID |
COTERM_SURFACE_ID | Auto-set: current surface ID |
TERM_PROGRAM | Set to ghostty |
TERM | Set to xterm-ghostty |
#Detecting Coterm
# Prefer explicit socket path if set
SOCK="${COTERM_SOCKET_PATH:-/tmp/coterm.sock}"
[ -S "$SOCK" ] && echo "Socket available"
# Check for the CLI
command -v coterm &>/dev/null && echo "coterm available"
# In coterm-managed terminals these are auto-set
[ -n "${COTERM_WORKSPACE_ID:-}" ] && [ -n "${COTERM_SURFACE_ID:-}" ] && echo "Inside coterm surface"
# Distinguish from regular Ghostty
[ "$TERM_PROGRAM" = "ghostty" ] && [ -n "${COTERM_WORKSPACE_ID:-}" ] && echo "In coterm"#Examples
#Python client
import json
import os
import socket
SOCKET_PATH = os.environ.get("COTERM_SOCKET_PATH", "/tmp/coterm.sock")
def rpc(method, params=None, req_id=1):
payload = {"id": req_id, "method": method, "params": params or {}}
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
sock.connect(SOCKET_PATH)
sock.sendall(json.dumps(payload).encode("utf-8") + b"\n")
return json.loads(sock.recv(65536).decode("utf-8"))
# List workspaces
print(rpc("workspace.list", req_id="ws"))
# Send notification
print(rpc(
"notification.create",
{"title": "Hello", "body": "From Python!"},
req_id="notify"
))#Shell script
#!/bin/bash
SOCK="${COTERM_SOCKET_PATH:-/tmp/coterm.sock}"
coterm_cmd() {
printf "%s\n" "$1" | nc -U "$SOCK"
}
coterm_cmd '{"id":"ws","method":"workspace.list","params":{}}'
coterm_cmd '{"id":"notify","method":"notification.create","params":{"title":"Done","body":"Task complete"}}'#Build script with notification
#!/bin/bash
npm run build
if [ $? -eq 0 ]; then
coterm notify --title "✓ Build Success" --body "Ready to deploy"
else
coterm notify --title "✗ Build Failed" --body "Check the logs"
fi