# Claude Code in CI/CD pipelines

*Claude Certified Architect - Foundations Study Guide · Claude Code Configuration & Workflows · Last updated October 22, 2026 · https://www.certifyforce.com/study-guide/claude-certified-architect-foundations/claude-code-configuration-and-workflows/claude-code-in-ci-cd-pipelines*

Running Claude Code unattended in CI: -p print mode, --output-format json with --json-schema and reading structured_output, failing on exit codes and missing output, CLAUDE.md as CI project context versus --bare, prior findings and existing tests in context, and the GitHub Actions and GitLab CI/CD integrations.

- Certification: Claude Certified Architect - Foundations
- Exam section: Claude Code Configuration & Workflows
- Study guide: https://www.certifyforce.com/study-guide/claude-certified-architect-foundations

**Official exam objective:**

> Integrate Claude Code into CI/CD pipelines

## What the exam expects

- Run Claude Code in a pipeline with `-p` so the job does not hang waiting for interactive input.
- Produce machine-parseable findings with `--output-format json` plus `--json-schema`, read them from `structured_output`, and fail the job on a non-zero exit or a missing field.
- Give CI-invoked Claude Code project context (review criteria, testing standards, fixtures) through a committed CLAUDE.md, and know that `--bare` skips it.
- Avoid duplicate output on reruns by passing prior findings and asking only for new or unaddressed issues, and avoid duplicate test suggestions by passing the existing tests.
- Wire Claude Code into GitHub Actions or GitLab CI/CD, with the review run independent of the session that wrote the code.

Key terms: **print mode** (`-p`/`--print`: one non-interactive run that prints a response and exits); **`structured_output`** (the JSON field holding schema-validated output); **bare mode** (`--bare`: skips auto-discovery of CLAUDE.md, hooks, skills, MCP servers and more); **`claude_args`** (the GitHub Action input that passes CLI flags); **automation mode** (the Action running from a `prompt` input without an `@claude` mention).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| Non-interactive flag | `-p` / `--print` | [CLI reference](https://code.claude.com/docs/en/cli-reference) |
| Output formats | `text` (default), `json`, `stream-json` | [Run Claude Code programmatically](https://code.claude.com/docs/en/headless) |
| `--json-schema` | Validated JSON after the workflow; print mode only | [CLI reference](https://code.claude.com/docs/en/cli-reference) |
| Where validated data lands | `structured_output`; `result` holds the text | [Run Claude Code programmatically](https://code.claude.com/docs/en/headless) |
| No valid structured output | Field is absent; check before use | [Run Claude Code programmatically](https://code.claude.com/docs/en/headless) |
| Exit codes | 0 on success, non-zero when the run fails | [Run Claude Code programmatically](https://code.claude.com/docs/en/headless) |
| `--bare` skips | Hooks, skills, commands, subagents, plugins, MCP, auto memory, CLAUDE.md | [CLI reference](https://code.claude.com/docs/en/cli-reference) |
| `--bare` future | Recommended for scripts; future default for `-p` | [Run Claude Code programmatically](https://code.claude.com/docs/en/headless) |
| `--max-turns` | Print mode only; no limit by default; errors at the limit | [CLI reference](https://code.claude.com/docs/en/cli-reference) |
| CI project standards | `CLAUDE.md` in the repository root | [Claude Code GitHub Actions](https://code.claude.com/docs/en/github-actions) |
| SDK retry failure | `error_max_structured_output_retries` | [Get structured output from agents](https://code.claude.com/docs/en/agent-sdk/structured-outputs) |

## Check yourself

- Why does a CI step that calls `claude "..."` without `-p` time out?
- When is `structured_output` missing from a `--json-schema` run?
- Where should review criteria live so both the GitHub Action and local sessions use them?
- What does `--bare` skip, and how do you restore project conventions?

## Sources

- [Run Claude Code programmatically](https://code.claude.com/docs/en/headless)
- [CLI reference](https://code.claude.com/docs/en/cli-reference)
- [Claude Code GitHub Actions](https://code.claude.com/docs/en/github-actions)
- [Claude Code GitLab CI/CD](https://code.claude.com/docs/en/gitlab-ci-cd)
- [Get structured output from agents](https://code.claude.com/docs/en/agent-sdk/structured-outputs)
- [Best practices for Claude Code](https://code.claude.com/docs/en/best-practices)
- [Common workflows](https://code.claude.com/docs/en/common-workflows)
- [Claude Certified Architect – Foundations Exam Guide v1.0](https://everpath-course-content.s3-accelerate.amazonaws.com/instructor%2F6nizmqk8tpzpfjvt6qmmav7rh%2Fpublic%2F1783542750%2FClaude+Certified+Architect+%E2%80%93+Foundations+Exam+Guide.pdf)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 10 linked practice questions, and unlimited timed mock exams are included with the Claude Certified Architect - Foundations pack (USD $19): https://www.certifyforce.com/practice-exams
