Lesson 3.6Lesson 18 of 30
Claude Code in CI/CD
Integrate Claude Code into CI/CD pipelines
Key points
- 1In CI, run
claude -p "..."(--print): Claude Code answers non-interactively and exits. Without -p it opens an interactive session and the job hangs waiting for input. - 2For findings a script must parse, add
--output-format jsonwith--json-schema: each finding comes back as validated fields (file, line, severity, message) that the job posts as inline PR comments. - 3CI-invoked Claude Code reads the committed project
CLAUDE.md. Put testing standards, what makes a test valuable, fixture conventions and review criteria there, not in a personal file or a long prompt in the workflow YAML. - 4Review with an independent instance: the session that generated the code keeps its own reasoning and is worse at spotting its mistakes. Run the review as a separate
claude -pcall, not a resumed generator session. - 5Per-run context goes in the prompt: on re-review after new commits, pass the prior findings and ask for only new or still-unaddressed issues; for test generation, pass the existing test files so covered scenarios are not duplicated.
What the exam guide checks here
Objective wording from the exam guide (English).
- 3.6.K1-p / --print runs Claude Code non-interactively
- 3.6.K2--output-format json and --json-schema enforce structured CI output
- 3.6.K3CLAUDE.md provides project context to CI-invoked Claude Code
- 3.6.K4Session isolation: the generating session reviews its own code worse than an independent instance
- 3.6.S1Use -p in CI to avoid interactive hangs
- 3.6.S2Use --output-format json with --json-schema for machine-parseable findings posted as PR comments
- 3.6.S3On re-review include prior findings and report only new or unaddressed issues
- 3.6.S4Provide existing tests so generation avoids duplicate scenarios
- 3.6.S5Document testing standards, valuable test criteria and fixtures in CLAUDE.md
Lock it in
Answer scenario questions on this topic. Every option comes with an explanation.
Practise 3.6 · 23 questions