Question 1 · choose 1
Your CI job runs Claude Code on each pull request and must turn its review findings into inline comments through the code host's API. The posting script needs to parse every result reliably, with a file, line, severity and message for each finding. How should the job invoke Claude Code?
- Aclaude -p with the default text output, and a regular expression in the script that extracts each finding
- Bclaude -p with --verbose text output, parsed line by line for findings
- Cclaude -p with a prompt that asks for JSON, and a retry in the script whenever parsing fails
- Dclaude -p with --output-format json and a --json-schema for the findings, read from structured_output
Show the answer and why
Aclaude -p with the default text output, and a regular expression in the script that extracts each finding
Incorrect
Free text changes shape between runs, so a regular expression breaks on findings it does not expect.
Bclaude -p with --verbose text output, parsed line by line for findings
Incorrect
Verbose text is meant for people; the script would still guess where each finding starts and ends.
Cclaude -p with a prompt that asks for JSON, and a retry in the script whenever parsing fails
Incorrect
Asking for JSON does not validate it; the script still has to handle malformed output and retries.
Dclaude -p with --output-format json and a --json-schema for the findings, read from structured_output
Correct
With a schema, print mode returns validated JSON in structured_output, which a script can post without guessing.
For machine-parseable CI output, combine -p with --output-format json and --json-schema. The result's structured_output field holds output that matches the schema, ready to post as inline comments.
Anthropic documentation