Stream machine-readable JSON events

exec & automation

// what it does

--json makes exec emit a stream of JSON Lines events — thread.started, turn.started, item.*, turn.completed — instead of prose, so you can parse what Codex did and its final answer programmatically. Pipe it to jq to filter the stream.

// shell

$ codex exec --json "list the top 5 risky files" | jq

// gotcha

The output is JSONL (one event per line), not one JSON document — parse line by line or pipe through jq, which handles the stream. A single JSON.parse over the whole output fails.

// resources