---
name: "instructor-pydantic-structured-data"
description: "Extract validated Pydantic data models with automated LLM self-correction retries."
metadata:
  author: "Jason Liu"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "extract data with instructor"
  - "use response_model instructor"
  - "retry on validation error"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Instructor Pydantic Extraction with Auto-Retry

Wraps OpenAI, Anthropic, and Groq clients with Instructor (instructor.patch): response_model parsing, validation_error hooks, and automatic re-prompting on schema violations.

## When to Invoke
Invoke this skill whenever you need to:
- extract data with instructor
- use response_model instructor
- retry on validation error

## Execution SOP & Rules
1. Patch client instances with client = instructor.from_openai(OpenAI()).
2. Specify response_model=MyModel in chat completions to enable typed schema extraction.
3. Set max_retries=3 to allow Instructor to re-prompt the model with validation feedback.
4. Use docstrings on Pydantic fields to provide guidance on expected formatting.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
