Machine Mode and Diagnostics¶
Machine mode contract¶
Use global --json for machine-consumable output.
Envelope shape:
{
"version": "v2",
"data": {},
"meta": {
"contract": "bb.machine"
}
}
data holds command-specific payloads. Additive fields are allowed in v2; breaking changes require versioning.
Diagnostics behavior¶
- Diagnostics are emitted to
stderrto preservestdoutcontracts. - Use
--log-format jsonlfor machine-filterable diagnostics. - Use
--log-levelto tune verbosity (error,warn,info,debug). - Sensitive values are redacted from diagnostic output.
Example:
bb --json --log-level warn --log-format jsonl auth status 2> diagnostics.jsonl
Recommended scripting pattern¶
- Use
--jsonand parse only thedatapayload needed for automation. - Keep diagnostics in separate stderr capture.
- Validate bulk artifacts against published schemas when integrating with CI.
Error kinds and exit codes¶
Command failures use deterministic exit codes by error kind.
validation-> exit code2authenticationorauthorization-> exit code3not_found-> exit code4conflict-> exit code5transient-> exit code10not_implemented-> exit code11permanentandinternal(or unknown) -> exit code1
Example failure behavior:
bb repo view --repo BADFORMAT
echo $?
validation: --repo must be in PROJECT/slug format
2