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.
More from this scenario
- The CI review job re-runs on every push to an open pull request. Developers complain…
- A nightly CI job asks Claude Code to propose new unit tests for recently changed…
- Tests generated in CI are often low value, such as getter checks and assertions that a…
- Your pipeline has Claude Code generate a fix for a failing build and then, in the same…
- Select two. Developers say the automated PR review flags too many non-issues, such as…