Run command

run_command

run_command
mutating tool
mutating tool
run_command

Run a shell command in a pane, wait for completion, and capture output.

Returns:

RunCommandResult

Use when you need to run a shell command in a pane and get a typed result with exit status, timeout state, and captured pane output.

Avoid when you need raw interactive key driving — use send_keys for TUIs, key names, and partial commands.

Side effects: Sends a command to the pane’s interactive shell. The command may read or write files, start processes, or access the network depending on what the shell command does. Each command runs in a subshell, so directory or environment changes do not persist across calls. Set suppress_history=true for secret-bearing commands on shells that honor leading-space history suppression.

Example:

{
  "tool": "run_command",
  "arguments": {
    "command": "pytest -q",
    "pane_id": "%2",
    "timeout": 60
  }
}

Response:

{
  "pane_id": "%2",
  "exit_status": 0,
  "timed_out": false,
  "elapsed_seconds": 4.2,
  "output": ["..."],
  "output_truncated": false,
  "output_truncated_lines": 0
}

Parameters

Parameter

Type

Required

Default

Description

command

str

yes

Shell command to run in the target pane.

pane_id

str

no

Pane ID (e.g. ‘%1’).

session_name

str

no

Session name for pane resolution.

session_id

str

no

Session ID (e.g. ‘$1’) for pane resolution.

window_id

str

no

Window ID for pane resolution.

timeout

float

no

30.0

Maximum seconds to wait for command completion.

max_lines

int

no

Maximum pane output lines to return. Defaults to all captured visible output; pass a small value for a tail-only summary.

suppress_history

bool

no

False

Suppress shell history by prepending a space; only effective where the shell ignores space-prefixed commands. Default False.

socket_name

str

no

tmux socket name.