0Pricing
Claude Architect · Lesson

CI/CD & Structured Extraction

Headless mode, JSON output, schemas and validation loops.

Two Scenarios, One Theme

This lesson fuses two exam scenarios that share a single backbone: determinism under automation. Scenario 5 (Claude Code for CI/CD) and Scenario 6 (Structured Data Extraction) both ask the same question — how do you get machine-parseable, trustworthy output with no human in the loop?

The answer is the same in both worlds:

  • Headless / non-interactive execution so a pipeline can drive Claude.
  • JSON output with a schema so downstream code can parse results.
  • Validation loops that catch and repair structural errors before they propagate.

Master this and you cover a meaningful slice of D3 (Config & Workflows) and D4 (Structured Output) — together 40% of the exam.

Headless Mode in CI/CD

A pipeline has no TTY and no human to answer prompts. Claude Code must run non-interactively. The flag for this is -p (also written --print): it runs a single prompt, prints the result, and exits.

Pair it with --output-format json so the pipeline gets a structured envelope instead of free prose. Without these two flags, the command hangs waiting for interactive input and the build stalls.

  • -p / --print = non-interactive, required in pipelines.
  • --output-format json = parseable result (optionally with a schema).
# Headless review step in a CI job
claude -p "Review the staged diff for correctness bugs only. \
  Flag a comment ONLY when it contradicts the code." \
  --output-format json \
  > review.json

# Pipeline now parses review.json deterministically
jq '.result' review.json

All lessons in this course

  1. Support Agent & Multi-Agent Research
  2. Code Gen & Developer Productivity
  3. CI/CD & Structured Extraction
  4. Conversational Patterns & Agentic Tools
← Back to Claude Architect