CI CD Headless Flags
Definition
The CLI flags that run Claude Code non-interactively (headless) for CI/CD pipelines and scripting, controlling output format, tool access, turns, budget, and system prompt.
Key points
- Headless:
--print/-pruns one-shot without the interactive UI. - Output/input format:
--output-format text|json|stream-json;--input-format text|stream-json. - Schema validation:
--json-schema '{}'validates output against a JSON Schema (print mode) — see Structured outputs. - System prompt:
--append-system-promptadds to defaults;--system-promptreplaces them (dropping the default prompt).--bareskips hooks/skills/MCP/CLAUDE.md;--exclude-dynamic-system-prompt-sectionsaids CI cache reuse. - Tools:
--allowedTools/--allowed-tools(execute without prompt, e.g."Bash(git log *)" "Read");--disallowedTools(bare name removes from context; scopedBash(rm *)denies only matches);--toolsrestricts availability. Feeds the same model as permissions. - Limits/mode:
--max-turns N(print mode only; errors at the limit);--max-budget-usd N;--permission-mode default|acceptEdits|plan|auto|dontAsk|bypassPermissions|manual;--modelalias or full ID (overridesANTHROPIC_MODEL). - Session:
--resume/-r,--continue/-c,--fork-session,--add-dir— see Session Resume And Fork. - SDK equivalents:
permission_mode/permissionMode,max_turns/maxTurns.
Why it matters for the exam
- D3 (20%) and the "Claude Code for CI" scenario (D3+D4) test these flags directly — especially
--append-system-promptvs--system-prompt,--output-format,--json-schema, and--max-turns.
Common gotchas
--append-system-promptadds;--system-promptreplaces and drops the default prompt — a classic distractor pair.--max-turnsworks only in print mode and errors when the limit is hit (it does not silently stop).--disallowedToolswith a bare name removes the tool from context; a scoped pattern only denies matches.
See also
Sources
Referenced by
Practice questions optional · AI
Generate fresh practice questions about this concept with AI. These are not vault-verified.