# prompt-engineering-instructor

Shows your agent how to pull typed data out of model responses with Instructor and Pydantic, retries included.

- skill · `type=skill` · Claude Code · 198 installs
- Author: Orchestra Research
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/ai-research/prompt-engineering-instructor
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/prompt-engineering-instructor

## What it does

The skill covers Instructor, a library that turns a model reply into a Python object instead of a blob of text. You define a Pydantic model — fields, types, constraints — and pass it as `response_model`. When the output does not match, Pydantic raises, Instructor sends the error back to the model and asks for another attempt. Three retries is the default.

Inside you get nested models, optional fields with defaults, enums for fixed value sets, built-in and custom validators, and checks that run across the whole model. Both Anthropic and OpenAI are covered: build the client with `instructor.from_anthropic(Anthropic())` or `instructor.from_openai(OpenAI())`, then call as usual.

Worth installing if you write extraction, JSON parsing or any pipeline that reads LLM answers. It will not run without a provider key and the packages named as dependencies: `instructor`, `pydantic`, `openai`, `anthropic`. Base install is `pip install instructor`; provider extras look like `instructor[anthropic]`.

## Install

### Claude Code (native platform)

1. **claude-code-templates**
```bash
npx claude-code-templates@latest --skill ai-research/prompt-engineering-instructor
```

2. **Skills CLI (Vercel)**
```bash
npx skills add davila7/claude-code-templates --skill prompt-engineering-instructor -a claude-code
```

3. **Manually: put the files in place**
- File: `~/.claude/skills/prompt-engineering-instructor/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/prompt-engineering-instructor/

### Codex

**Manually: put the files in place**
- File: `.agents/skills/prompt-engineering-instructor/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/prompt-engineering-instructor/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install davila7/claude-code-templates prompt-engineering-instructor
```

2. **Manually: put the files in place**
- File: `.github/skills/prompt-engineering-instructor/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/ai-research/prompt-engineering-instructor
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/prompt-engineering-instructor/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/ai-research/prompt-engineering-instructor

## When to use it
- pull named fields out of a free-form model reply
- check an LLM answer against a schema before it hits the database
- retry extraction when the model returns the wrong type
- parse nested JSON without hand-written checks
- receive a partial object while generation is still running

## Example prompts
- Write a Pydantic model that extracts name, age and email from text and show the call through instructor.from_anthropic
- Add a validator that enforces the YYYY-MM-DD date format and explain how Instructor retries on failure
- Build a nested Person model with an Address and print the city via person.address.city

## Similar
- [prompt-engineering-patterns](https://affpapa.org/en/nevibecode/skills/prompt-engineering-patterns.md) — skill · 23418 installs
- [prompt-engineering](https://affpapa.org/en/nevibecode/skills/neolabhq-prompt-engineering.md) — skill · 1400 installs
- [outlines](https://affpapa.org/en/nevibecode/skills/outlines.md) — skill · 951 installs
- [ai-prompt-engineering-safety-best-practices](https://affpapa.org/en/nevibecode/rules/ai-prompt-engineering-safety-best-practices.md) — rule · ★ 40418
- [context-engineering](https://affpapa.org/en/nevibecode/skills/mvschwarz-context-engineering.md) — skill · ★ 8172
- [agent-native-design](https://affpapa.org/en/nevibecode/skills/agent-native-design.md) — skill · 1900 installs

From the same set: [davila7/claude-code-templates](https://affpapa.org/en/nevibecode/by/davila7/claude-code-templates.md) — 205 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
