Claude Code in CI
A pipeline runs Claude Code to review every pull request. The wrong answers all sort of work: pipe “yes” into it, ask for JSON in the prompt and parse it with a regex, paste the standards into the command. The trap is a workaround where the CLI already has the built-in setting. Ask who is there to answer, and who reads the output.
D3 Claude Code ConfigurationExam guide 3.6About 15 minutes
-p so it doesn't wait for input, use --output-format json with --json-schema for results a script can parse, and put the project's testing and review standards in CLAUDE.md.Start here: the overnight cleaning crew
An office is cleaned at night, when nobody is there.
A CI job (continuous integration: the robot that runs checks on every pull request) is that night shift. -p (or --print) runs Claude Code non-interactively: it answers and exits instead of waiting at a prompt. --output-format json with --json-schema makes the output a fixed form that a script can read and turn into inline comments on the pull request. CLAUDE.md is the sheet on the wall: the project's testing standards, fixtures and review criteria. And the review should come from an independent instance, not the session that wrote the code.
- Nobody is there to type (a pipeline, a scheduled job): run with
-p, the built-in non-interactive mode. - A script reads the result (inline PR comments, a dashboard):
--output-format jsonwith--json-schema. - The review ignores the team's conventions: put the testing standards, fixtures and review criteria in
CLAUDE.md. - The same job wrote the code it reviews: run the review as an independent instance.
Words in the question that tell you which side you're on
-p / --print
- “the job hangs”, “sits idle”
- “waits for input”, “pipeline never finishes”
- non-interactive, unattended
JSON + schema
- “post inline PR comments”
- “parse the findings”, “a script reads the result”
- “a key came back renamed”
CLAUDE.md
- “review ignores our standards”
- testing conventions, fixtures
- “developers get the same advice”
Independent reviewer
- “one call writes and reviews”
- “the review never flags its own tests”
Try it: run the review job
Switch each setting on or off. The simulator replays the same pull request, which has six planted issues: two general ones, two that break the team's testing standards, and two mistakes in tests that Claude generated earlier in the job. You see the CI log, what lands on the pull request, and how many of the six the review caught. The diagram above shows which parts are in place.
CI log
On the pull request
The log, the runs and the counts are illustrative, chosen to show the shape. They are not measurements. The exam guide's points: -p means no input hang, --output-format json with --json-schema gives machine-parseable findings for inline comments, CLAUDE.md carries the project's standards, and an independent instance reviews better than the session that generated the code.
Things to try: everything off, then turn on only -p: it stops hanging but posts nothing. Add JSON: three of five runs post. Add schema: every run posts, but only 2 of 6 issues. Then switch on CLAUDE.md and the independent instance one at a time to watch the meter fill.
The four traps
| Trap | What the wrong option looks like | Why it loses |
|---|---|---|
| Only usually works | “Pipe ‘yes’ into the command so any prompt is answered automatically.” | A workaround. -p is the built-in non-interactive mode. |
| Only usually works | “Ask in the prompt for the findings as JSON and parse the text with a regex.” | Free-text JSON can break. --output-format json with --json-schema gives machine-parseable output. |
| Wrong home | “Paste the team's review standards into the CI command's prompt each run.” | The standards then live in a pipeline file instead of the CLAUDE.md that every session already loads. |
| Delays the problem | “Have a person run the review locally and paste the results into the PR.” | It isn't automated. The guide's pattern runs Claude Code in the pipeline itself. |
Practice: three exam-style questions
Answer first, then open “Think it through”.
Rule to remember
-p so it never waits, JSON with a schema so code can read it, and CLAUDE.md for the standards. Review with an independent instance, not the session that wrote the code.
Exam guide 3.6: “-p / --print = non-interactive mode (no input hang).” “--output-format json + --json-schema for machine-parseable findings → inline PR comments.” “CLAUDE.md provides project context (testing standards, fixtures, review criteria).” “Session context isolation: the session that generated code is less effective at reviewing its own changes than an independent instance.”