
Instructor Structured Output
Get LLM replies as validated, typed Python objects using Pydantic schemas, with automatic retries
- Repository
- Orchestra-Research/AI-Research-SKILLs
- Stars
- 14,195
- Licence
- MIT
- Files
- 4 files
What it does
When a developer asks an AI model for data, the model normally returns free text that is hard to trust. With this skill installed, the agent knows how to write code using the Instructor library so the model's answer is forced into a defined data structure (a Pydantic model), checked for correct types and rules, and automatically retried with error feedback if the check fails. It also covers nested models, enums, custom validators and streaming partial results across Anthropic, OpenAI and other providers.
Great for
- Python developers building pipelines that turn LLM output into database rows or API payloads
- Teams that need consistent structured output across multiple model providers
- Developers who want validation and retry logic without writing it by hand
Skip it if
- Non-programmers who only want a one-off extraction in a chat window, since the skill produces Python code that must be run and set up
- Applications where a wrong value could cause harm without human review, because validation checks format and rules, not factual accuracy, and retries can still return plausible but incorrect data
- Projects not using Python, since the library and examples are Python-only
Try asking
- “Write a Python script that extracts name, age and email from customer emails into a Pydantic model using Claude”
- “Add validation so that invoice dates must be YYYY-MM-DD and totals must be positive, then retry on failure”
- “Stream partial results from an LLM so my UI can show a story title before the body finishes”
- “Switch my existing OpenAI extraction code to Anthropic using Instructor's consistent API”
Install in 3 steps
- 1
Download the skill
The ZIP contains the 4 original files, the MIT licence and an attribution note.
instructor.zip - 2
Add it to your agent
Claude Code (all projects)
mkdir -p ~/.claude/skills && unzip instructor.zip -d ~/.claude/skills/Claude Code / Agent SDK (this project only)
mkdir -p .claude/skills && unzip instructor.zip -d .claude/skills/Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.
- 3
Ask for the task
No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.
Get better results
- Review the generated Pydantic schema and validators before running, since they define what counts as a valid answer
- Set max_retries deliberately and watch API costs, because each retry is another paid model call
- Verify extracted values against the source for anything important; validation confirms shape, not truth
What's inside
- references/examples.md
- references/providers.md
- references/validation.md
- SKILL.md
Redistributed unmodified from Orchestra-Research/AI-Research-SKILLs under the MIT licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.