Get machine-readable JSON output
headless & scripting
// what it does
opencode run --format json emits the result as structured JSON instead of formatted text, so you can pipe it into jq or a CI step and read the response, session ID, and metadata programmatically. The default format is human-readable text.
// shell
$ opencode run "list every TODO in the codebase" --format json// gotcha
Only run supports --format; the TUI does not. Keep stdout clean — avoid --print-logs on the same invocation — so the JSON actually parses.