structured-generation
Installation
SKILL.md
Structured Generation
Pain Signals — You Need This Pattern When:
- LLM output is parsed with regex, string splitting, or "hope"
- Downstream code breaks when the LLM returns an unexpected format
- The same prompt sometimes returns JSON, sometimes prose, sometimes partial JSON
- You are writing brittle extraction code to pull structured data from free text
- Different calls to the same prompt produce outputs with different field names or shapes
- A parsing failure means the entire operation fails with no recovery path
Core Principle
An LLM is a function. Like any function, it should have a defined return type. Structured Generation constrains the output to a schema so the caller can rely on the shape without parsing or guessing.
The constraint happens at three possible levels — use the strongest one available: