Skip to main content
skill

prompt-engineering-instructor — Claude Code skill: structured LLM

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

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --skill ai-research/prompt-engineering-instructor
Open on GitHub

What prompt-engineering-instructor 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].

What it helps with

  • 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 for the agent

  • 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

How to install prompt-engineering-instructor

1claude-code-templates

npx claude-code-templates@latest --skill ai-research/prompt-engineering-instructor

2Skills CLI (Vercel)

npx skills add davila7/claude-code-templates --skill prompt-engineering-instructor -a claude-code

3Manually: put the files in place

~/.claude/skills/prompt-engineering-instructor/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/prompt-engineering-instructor/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about prompt-engineering-instructor

How do I install prompt-engineering-instructor in Claude?

Use the templates CLI: npx claude-code-templates@latest --skill ai-research/prompt-engineering-instructor. Or run npx skills add davila7/claude-code-templates --skill prompt-engineering-instructor -a claude-code. The skill file then sits at ~/.claude/skills/prompt-engineering-instructor/SKILL.md.

What does prompt-engineering-instructor do?

It documents how to get structured data back from an LLM with Instructor and Pydantic: response schemas, validation, automatic retries and streaming of partial results.

What do I need for this skill to work?

The instructor, pydantic, openai and anthropic packages, plus an API key for whichever provider you call. The examples build a separate client for Anthropic and for OpenAI.

Similar skills

Everything for AI and ML →

From the same set205

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor