3.6 · D317 questions · 5 free

Claude Code in CI/CD pipelines

Integrate Claude Code into CI/CD pipelines.

This subtopic (3.6) sits in Claude Code Configuration & Workflows (D3) on Anthropic's Claude Certified Architect — Foundations (CCA-F) exam. The bank holds 17 practice questions here — 3 easy, 10 medium, and 4 hard — with 5 free to try, answers and explanations included. 3 of the free questions are below; the rest are in the practice stream.

What the exam tests here

  • -p / --print flag for non-interactive mode in CI pipelines
  • --output-format json with --json-schema for structured CI output
  • CLAUDE.md provides project context to CI-invoked Claude Code
  • session isolation — independent review instance more effective than self-review
Practice this subtopic — 5 freeFree questions with answers ↓

Free practice questions: Claude Code in CI/CD pipelines

Question 1 of 3 · free · easy

Your team wants to call Claude Code from a CI pipeline without any interactive prompts. Which flag enables CLAUDE.md-configured Claude Code to run non-interactively and print its response?

Show answer & explanation

Correct answer: D. Use -p to run Claude Code in non-interactive print mode

The -p (--print) flag runs Claude Code non-interactively: it prints the response and exits. --bare skips CLAUDE.md and configuration, which contradicts the scenario requirement. --no-session-persistence and --permission-mode dontAsk do not enable headless execution.

Question 2 of 3 · free · hard

Your nightly Claude Code job runs claude -p "audit dependencies" and writes to a CI log. A downstream Python script greps for the line starting RESULT: and parses a Python dict literal. The job intermittently fails because Claude wraps its answer in prose or pretty-prints across lines. You want a schema-valid, single-document machine-readable output the script can parse deterministically. Which invocation best fixes this?

Show answer & explanation

Correct answer: A. Switch to claude -p ... --output-format json --json-schema schema.json and read the structured payload from the response metadata's structured_output field.

--output-format json paired with --json-schema constrains Claude's output to schema-valid JSON in the response metadata's structured_output field, eliminating the prose-wrap and multi-line parsing problems. An appended system prompt still relies on probabilistic compliance and does not enforce a schema. A slash command prefix changes the format superficially but does not constrain the rest of the message. stream-json produces a stream of events, not a single validated object — and Python dict literal parsing is unrelated.

Question 3 of 3 · free · medium

A team's CI job invokes Claude Code headlessly with -p. The CLAUDE.md at the project root defines coding conventions. After switching to --bare -p, the generated code ignores those conventions. What explains this change?

Show answer & explanation

Correct answer: B. --bare disables CLAUDE.md auto-discovery, so the coding conventions are not injected into the CI session

--bare specifically skips CLAUDE.md auto-discovery, removing the project's coding conventions from the CI session context. '--bare' does not fall back to the global CLAUDE.md. '--bare' has no effect on token budgets. '-p' (headless mode) does not suppress CLAUDE.md; only '--bare' does.

2 more free questions on this subtopic in the practice stream, plus 12 in the full bank. Keep practicing →

Related reading (Anthropic docs)