A CI step needs a validated report from Claude Code. Which flags fit?
Why C is the answer
claude -p with --output-format json and --json-schema
-p runs without a person. --json-schema puts validated output in structured_output, and the exit code tells CI whether the run worked.
In detail
- -p runs Claude Code without a person, which CI needs.
- --output-format json gives machine-readable output, and --json-schema adds validated structured_output.
- The exit code tells the pipeline whether the run worked.
- Define the schema around what the pipeline will do with the result.
Use case
An illustrative scenario, not a real incident.
A pipeline needs a security report it can act on. With -p and a JSON schema, it receives structured_output with fields it can check, and the build fails when a high-severity finding appears.
See it in different ways
flowchart LR
A["CI job"] --> B["claude -p with JSON output"]
B --> C{"Exit code"}
C -->|"0"| D["Parse the result"]
C -->|"Non-zero"| E["Fail the job"]sequenceDiagram participant CI as CI job participant C as claude -p CI->>C: Prompt, --output-format json, --json-schema C-->>CI: structured_output and exit code CI->>CI: Pass or fail the step
flowchart LR S0["claude -p"] --> S1["JSON schema applied"] --> S2["structured_output"] --> S3["Pipeline decides"]
Key point: Use a schema when a machine reads the output.
Why the other options are wrong
- A. claude with --output-format text, parsed afterward with a regular expression
- Parsing free text is fragile, and it breaks when the wording changes.
- B. claude --interactive --verbose
- Interactive mode waits for a person, so it hangs in CI.
- D. claude --continue followed by a prompt typed in by the build agent
- --continue resumes a session. Nobody is there to type a prompt.

