Lv.1 0 XP

CI/CD Integration — Claude Code in Automated Pipelines

⚡ Exam Tested 8 min +35 XP
💡
THE ANALOGY

An automated quality inspector on a factory assembly line. Consistent. Tireless. Catches what humans miss when reviewing 50 PRs a week. The key: it must be configured to run unattended — no keyboard, no prompts.

⚠️ EXAM TRAP — The Wrong Answer People Choose

The -p / --print flag. Without it, Claude Code runs interactively and WAITS for keyboard input. In CI/CD, there is no keyboard. The pipeline hangs indefinitely until killed. -p is non-negotiable for all pipeline usage.

KEY POINTS
1 -p / --print: non-interactive mode — processes prompt, outputs to stdout, exits. REQUIRED for CI/CD.
2 --output-format json: structured output pipelines can parse programmatically for gating decisions.
3 Independent review instances: fresh Claude Code invocation for review — separate from any generation.
4 Exit codes: non-zero exit from Claude Code should fail the pipeline step.
5 --allowedTools in CI/CD: minimum necessary — cannot intervene if wrong tool runs in headless mode.