Agent skill · software engineering · sickn33
pydantic-ai
Build production-ready AI agents with PydanticAI — type-safe tool use, structured outputs, dependency injection, and multi-model support.
Why this skill is useful
Adds a framework for building type-safe AI agents with structured outputs and dependency injection, which includes executable code examples and integration patterns not commonly found in public documentation.
What it needs
Requires pydantic installed locally. About 6k tokens when loaded. Last updated 2026-08-07. 44,571 stars on the source repository.
What this skill does
PydanticAI — Typed AI Agents in Python Overview PydanticAI is a Python agent framework from the Pydantic team that brings the same type-safety and validation guarantees as Pydantic to LLM-based applications. It supports structured outputs (validated with Pydantic models), dependency injection for testability, streamed responses, multi-turn conversations, and tool use — across OpenAI, Anthropic, Google Gemini, Groq, Mistral, and Ollama. Use this skill when building production AI agents, chatbots, or LLM pipelines where correctness and testability matter. When to Use This Skill Use when building Python AI agents that call tools and return structured data Use when you need validated, typed LLM outputs (not raw strings) Use when you want to write unit tests for agent logic without hitting a real LLM Use when switching between LLM providers without rewriting agent code Use when the user asks about Agent, @agent.tool, RunContext, ModelRetry, or resulttype How It Works Step 1: Installation Step 2: A Minimal Agent Step 3: Structured Output with Pydantic Models Step 4: Tool Use Register tools with @agent.tool — the LLM can call them during a run: Step 5: Dependency Injection Inject services (database, HTTP clients, config) into agents for testability: Step 6: Testing with TestModel Write unit tests without real LLM calls: FunctionModel for deterministic test responses: Step 7: Streaming Responses Step 8: Multi-Turn Conversations Examples Example 1: Code Review Agent Example 2: Agent with Retry Logic Example 3: Multi-Agent Pipeline Best Practices ✅ Always define resulttype with a Pydantic model — avoid returning raw strings in production ✅ Use depstype with a dataclass for dependency injection — makes agents testable ✅ Use TestModel in unit tests — never hit a real LLM in CI ✅ Add @agent.resultvalidator for business-logic checks beyond Pydantic validation ✅ Use runstream for long outputs in user-facing applications to show progressive results ❌ Don't put secrets (API keys) in …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills sickn33/pydantic-ai--51902d