← Study Guide
5Exam Scenario

Claude Code for Continuous Integration

Integrating Claude Code into CI/CD for automated code review, test generation, and PR feedback — with prompts that give actionable feedback and minimize false positives.

Claude Code Configuration & WorkflowsPrompt Engineering & Structured Output

What this scenario tests

Non-interactive execution

A hanging pipeline is waiting for input — add -p / --print. CLAUDE_HEADLESS and --batch aren't real; stdin redirection is a workaround, not the fix.

Structured CI output

Use --output-format json + --json-schema for machine-parseable findings posted as inline PR comments.

Sync vs batch API

Blocking pre-merge checks need the synchronous API (batch has up to 24h, no SLA). Overnight technical-debt reports are ideal for the 50%-cheaper batch API. Don't move both to batch.

Multi-pass review for large PRs

A 14-file single-pass review with inconsistent/contradictory feedback → split into per-file local passes + a cross-file integration pass. A bigger model/context won't fix attention dilution.

Explicit criteria & avoiding duplicates

Define categorical report/skip criteria to cut false positives. On re-runs after new commits, include prior findings and report only new/unaddressed issues.

Edge Cases & Traps

  • Independent review instance beats self-review — the generator keeps its own reasoning bias.
  • 'Consensus across N runs' suppresses intermittently-detected real bugs.
  • Batch result ordering is solved by custom_id, not by avoiding batch.

🧠 Knowledge Check · 15 questions

Score: 0/15

1.A pipeline running Claude Code hangs indefinitely waiting for input. Correct fix?

2.You want review findings posted as inline PR comments programmatically. What produces machine-parseable output?

3.Two workflows: (1) a blocking pre-merge check, (2) an overnight tech-debt report. Your manager wants both on the Batch API for the 50% savings. Best evaluation?

4.On a re-run after new commits, how do you avoid re-posting duplicate review comments?

5.A teammate suggests fixing the hanging pipeline with CLAUDE_HEADLESS=true or --batch. Correct assessment?

6.Should the same session that generated the code also review it in CI?

7.A reviewer proposes running each check 3 times and only flagging issues all runs agree on. What's the downside?

8.The review has too many false positives from an instruction like 'check that comments are accurate'. Best fix?

9.The overnight technical-debt report can tolerate up to 24h latency. Which API fits and why?

10.A blocking pre-merge check makes developers wait for the result. Which API?

11.Someone worries batch results might come back out of order and corrupt the pipeline. Correct response?

12.A 14-file PR reviewed in a single pass gives inconsistent, contradictory feedback. Best restructuring?

13.Does moving to a larger context window fix the inconsistent multi-file review?

14.How do you give CI-invoked Claude the project's testing standards, fixtures, and review criteria?

15.Auto-generated tests keep duplicating scenarios that existing tests already cover. Best fix?