/authoring:structured-outputfrom authoring
Guarantees valid typed JSON from LLMs using constrained decoding, JSON Schema, Zod, Pydantic, and Instructor. Covers schema design, quality tradeoffs, and provider-specific patterns.
Ships in authoring. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
structured-output, constrained-decoding, json-schema, zod, pydantic, instructor
16 skills in this plugin
/claude-md-authoringBest practices for writing effective CLAUDE.md files. Use when creating, updating, or auditing CLAUDE.md files for projects or directories./cli-designDesign CLIs for humans and LLM agents — subcommand shape, output streams, exit codes, JSON modes, TTY-aware color, structured errors, mutation safety. Use when building or refactoring a CLI, adding machine-readable output, writing --help, deciding stdout vs stderr, or making a tool agent-friendly./commands-authoringGuide to writing slash commands for Claude Code. Use when creating commands that set mode, constraints, or workflows invoked via /command-name.npx claudepluginhub crouton-labs/crouton-kit --plugin authoringOther plugins' skills for the same job