Run a command
runExecutes a single binary with args without a shell, returning structured output with smart truncation for build, test, and lint commands needing exit codes and error details.
Instructions
Run a single command — a binary plus an args array, executed directly without a shell (so no pipes, redirects, or ';'/'&&' in the string) — and return structured output with smart truncation. Pass the binary as command and its arguments as args (e.g. command='npm', args=['test']); for a real shell pipeline run the shell yourself: command='sh', args=['-c', 'a | b > c']. Keeps the last N lines of output by default (where errors typically appear), or the first N with mode='head'. Use for build, test, and lint commands where you need exit code and error details, not full verbose output.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Working directory | |
| args | No | Arguments passed directly to the binary (e.g. ['test']). With command='sh', use ['-c', '<shell script>']. | |
| mode | No | Keep the last N lines (tail, default) or the first N (head). | tail |
| command | Yes | The binary to execute — NOT a shell string (e.g. 'npm', 'git', 'sh'). For pipes/redirects, use command='sh' and put the script in args. | |
| timeout | No | Timeout in ms | |
| collapse | No | Merge consecutive repeated lines (timestamps ignored) into the first, marked ' [×N]' (default true). false = output verbatim. | |
| maxBytes | No | Optional cap on stdout/stderr byte length (UTF-8). | |
| maxLines | No | Max stdout/stderr lines to keep. 0 = unlimited. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stderr | Yes | ||
| stdout | Yes | ||
| elapsed | Yes | Wall-clock execution time in milliseconds | |
| exitCode | Yes | ||
| retained | No | ||
| truncated | Yes | ||
| stdoutLines | Yes |