structured-output
Installation
SKILL.md
Structured Output (Strict JSON)
Implement stable, schema-validated JSON outputs for agents. Use this when responses must be valid JSON, match a schema exactly, and be reliable under retries/streaming.
Core Workflow
- Define a strict schema (JSON Schema or Pydantic).
- Generate JSON-only output (no prose).
- Validate output against schema.
- If invalid, run a repair pass with a minimal error-focused prompt.
- For streaming, emit incremental JSON with a deterministic assembly buffer.
Prompt Pattern (Non-Streaming)
Use a strict system instruction and a minimal user prompt. Always require JSON only. Input can be empty; output must still match the schema.
Template: