⌨️--json-schema Flag
Also known as claude --json-schema, structured_output
It makes claude -p answer in a JSON shape you set.
Think of it like
It is like a form with boxes. Each answer fills the same boxes.
Example
Emma's job sorts bug reports. With --json-schema, each answer has the same three fields. Her code can file each report without reading the words.
Why it matters
Code downstream can trust the shape, so it does not break on a reply worded a new way.
Definition
Example code
bash
claude -p "List the functions in auth.py" --output-format json --json-schema '{"type":"object","properties":{"functions":{"type":"array"}}}'Common mistake
Key takeaways
- 1Your shape. As a JSON Schema.
- 2structured_output. Where it lands.
- 3Check it exists. It can be missing.