Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Structured Outputs?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/adityaaatiwari-structured-outputs-anvil)
---
name: structured-outputs
description: Extract reliable typed JSON from LLMs using schema-constrained decoding, runtime validation, enums, and bounded retries
---
<!-- Generated by `anvil plugin build` from catalog/. Edit the catalog, not this file. -->
# Structured outputs
Use when converting natural language or model reasoning into strongly typed application objects or tool payloads.
## Schema design
- Use provider native JSON Schema / `strict: true` structured output modes where available rather than prompting for raw markdown JSON blocks.
- Keep schemas shallow with clear field names, explicit `description` hints, tight enums, and nullable fields instead of hallucination-prone required strings.
- Prefer `"unknown"` / `"none"` enum options and brief `reasoning` fields before classification verdicts when accuracy matters.
## Validation and repair
- Validate every parsed JSON payload at runtime using Zod or Pydantic; never trust `JSON.parse` types directly.
- Handle refusal fields explicitly, and cap schema-repair retries (`<= 2` attempts passing exact validation error paths back to the model) with circuit-breaking fallbacks.
## Verify
Run tests covering malformed JSON, enum boundary cases, refusal payloads, nullable fields, and retry cap enforcement.