CCAR-F scenarios › Claude Code for Continuous Integration · Question 41 of 60

Scenario 5 · Claude Code for Continuous Integration

Claude Code runs inside your CI/CD pipeline. It reviews pull requests automatically, proposes test cases, and posts feedback on the PR. The central challenge is writing prompts and configuration that produce actionable findings while keeping false positives low enough that developers keep trusting the output.

Claude Code Configuration & Workflows

Your pipeline runs `claude -p` to review each pull request, and a script then uses regular expressions to pull file names, line numbers, and messages out of the prose output so it can post inline PR comments. The script breaks every few days when Claude phrases a finding slightly differently. What is the most robust fix?

Show answer and explanation

Answer: B — Run with --output-format json and a --json-schema defining each finding's file, line, severity, and message, then post comments from those fields.

--output-format json together with --json-schema gives machine-parseable structured findings, which section 6 names as the way to post findings automatically as inline PR comments. (a) is a prompt-only request with no enforcement behind it. (c) avoids the problem by giving up inline comments. (d) adds a second model call and still produces output that has to be parsed, with no schema guaranteeing its shape.