From authoring
Generates reliable typed JSON from LLMs using constrained decoding, JSON Schema, Zod, Pydantic, and Instructor. Use for structured output, schema validation, data extraction, API responses, and debugging malformed JSON.
How this skill is triggered — by the user, by Claude, or both
Slash command
/authoring:structured-outputThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Structured output guarantees valid typed JSON from LLMs — the model can only emit tokens that conform to your schema. The question isn't how it works but when you need it.
Structured output guarantees valid typed JSON from LLMs — the model can only emit tokens that conform to your schema. The question isn't how it works but when you need it.
Use when: data extraction, API responses, agent tool outputs, any downstream code that parses the response.
Don't use when: prose, creative writing, chat, or when the quality cost outweighs the reliability gain.
For code examples and provider-specific patterns, see reference.md.
Constrained decoding has a cost. Tam et al. (2024) showed JSON constraints dropped math accuracy by 26–32 percentage points across tested models. The mechanism: forced key ordering means the model must generate answer tokens before reasoning tokens, disrupting sequential reasoning.
The fix is schema design, not giving up on structured output. Enforcement is syntactic, not semantic — valid JSON can still be semantically wrong.
The PARSE paper (2025) found structural reorganization was the top optimization for extraction accuracy — more impactful than model choice or prompt engineering. A single ambiguous field name (final_choice alongside potential_final_choices) collapsed accuracy from 95% → 4.5% in Instructor's experiments.
Put a reasoning or thinking field first in your schema. LLMs generate keys in order — reasoning before answer tokens restores chain-of-thought within structured output. Instructor showed this alone recovers accuracy from 33% → 92% on GSM8K.
{
"type": "object",
"properties": {
"reasoning": { "type": "string", "description": "Step-by-step analysis before concluding" },
"answer": { "type": "string" },
"confidence": { "type": "string", "enum": ["high", "medium", "low"] }
},
"required": ["reasoning", "answer", "confidence"],
"additionalProperties": false
}
minimum/maximum/pattern — neither Anthropic nor OpenAI enforces these at the grammar level. Validate post-generation.These patterns apply directly to tool-design — tool schemas are structured output schemas.
Type system (Zod/Pydantic)
→ JSON Schema
→ LLM with constrained decoding
→ Validate (syntactic: already guaranteed; semantic: your validators)
→ Retry with error feedback on failure
Libraries doing this loop:
max_retries.zodResponseFormat + beta.chat.completions.parse() — returns .parsed typed directly.zodOutputFormat helper from @anthropic-ai/sdk/helpers/zod.generateObject / streamObject with a Zod schema.Zod v4 has native z.toJSONSchema() for converting schemas to JSON Schema format.
For mechanism details, provider comparison, streaming patterns, and failure modes, see reference.md.
npx claudepluginhub crouton-labs/crouton-kit --plugin authoringExtracts typed, validated JSON from LLM APIs using response_format, tool_use, and schema-constrained decoding across OpenAI, Anthropic, and Google.
Applies prompt engineering patterns like few-shot, chain-of-thought, structured JSON outputs, optimization, and templates to boost LLM reliability and performance in production apps.
Guides Pydantic schema design for Atomic Agents apps using BaseIOSchema. Covers fields, constraints, validators, enums, and patterns like chat input/output.