Scripting
The CLI is built to be driven by shell scripts, CI jobs and coding agents. Data goes to stdout, everything else goes to stderr, exit codes are stable and every prompt can be turned off.
Output
Output is text when stdout is a terminal and JSON when it is piped or redirected; force a format with --output json or --output text, the POLYLANE_OUTPUT variable or the config file, in that order of precedence. stdout carries only data, whether JSON, table rows or streamed tokens, so it is safe to pipe. stderr carries spinners, progress, hints and errors, and in JSON mode an error arrives as an object with code, message and hint, where code matches the exit code.
Flags for scripts
| Flag | Description |
|---|---|
--output json | Force JSON regardless of terminal state |
--quiet | Suppress spinners and progress; stdout stays pure data |
--non-interactive | Fail fast on missing input instead of prompting |
--yes | Skip confirmation on destructive commands |
--dry-run | Show what would happen without making changes |
--full | Return full objects on list commands instead of the narrow field projection |
--api-key <key> | Override the stored API key for one call |
--workspace <id> | Override the default workspace for one call |
With --non-interactive, polylane cloud disconnect refuses to run unless you also pass --yes, while other confirmations, such as polylane memory delete, are skipped, so pass --yes explicitly to make intent clear. POLYLANE_API_KEY and POLYLANE_WORKSPACE_ID set the credential and workspace from the environment, which suits CI; see Authentication.
Exit codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Usage error: bad flag, missing argument |
| 3 | Authentication error |
| 4 | Rate limit or plan upgrade required |
| 5 | Timeout |
| 6 | Network error |
| 130 | Interrupted with Ctrl-C |
Branch on the exit code first to decide whether to retry, re-authenticate or surface the failure, then parse the error object on stderr for detail.
Example
polylane issue list --active --severity critical --output json --quiet \
| jq -r '.items[] | "\(.id)\t\(.title)"'
polylane issue list returns an object with items and count, and each item is projected to id, severity, status, title, resourceKind, resourceId, detectedAt and investigationThreadId; --full returns the complete objects. Issues explains the lifecycle behind each status.
Related
- Authentication: API keys and environment variables for CI.
- Configuration: output and timeout settings and the config file.
- Issues: the statuses and severities the
issuecommands return. - Threads: what
thread askstarts and how a thread progresses.