Claude Certified Architect – Foundations Practice Question 15: Headless CI JSON

Claude Certified Architect, Foundations · Test 2 · question 5 of 10

Claude Code Configuration & Workflowsmedium

A team wants a CI job that runs Claude Code on every pull request to summarize test failures. The pipeline script must parse the result programmatically, and nobody is present to approve tool prompts. Security requires that the job can read files and run only git diff and the test command, nothing else. Which invocation fits?

Select one answer
Show answer and explanation

Answer:

  • A. claude -p "Summarize the test failures" --output-format json --allowedTools "Read,Bash(git diff *),Bash(npm test *)"

A is correct. -p runs Claude Code non-interactively (headless), --output-format json returns a structured result (including fields such as the result text, session information and cost) that a script can parse, and --allowedTools with permission-rule patterns pre-approves only the listed tools and command patterns, so no prompt is needed and nothing else that needs approval is allowed.

B is wrong because interactive mode is unsuitable for unattended CI, and faking a terminal does not give a safe or parseable result. C is wrong because --dangerously-skip-permissions removes all restrictions, violating the least-privilege requirement, and text output is harder to parse. D is wrong because allowing all of Bash is far broader than the requirement, and scraping prose is fragile compared with JSON output.

Reference: Run Claude Code programmatically

Practice Test 2 ›

Study guides for Claude Certified Architect, Foundations