P2: Structured, Parseable Output

Definition

CLI tools MUST separate data from diagnostics and offer machine-readable output formats. Mixing status messages with data forces agents into fragile regex extraction that breaks on any format change.

Why Agents Need It

An agent calling a CLI needs three things from each invocation: the data, the error (if any), and the exit code. When data goes to stdout, diagnostics go to stderr, and errors carry machine-readable fields, the agent parses the result reliably without heuristics. Mix these channels or ship human-formatted output only, and the agent falls back to best-effort text parsing that fails unpredictably across versions, locales, and edge cases — silently at first, catastrophically later.

Requirements

MUST:

SHOULD:

MAY:

Evidence

Anti-Patterns

Measured by check IDs p2-output-json, p2-output-format, p2-stderr-diagnostics. Run agentnative check --principle 2 . against your CLI to see each.