skills/dougtrajano/pydanticai-docs/SKILL.md
Use this skill for requests related to Pydantic AI framework - building agents, tools, dependencies, structured outputs, and model integrations.
npx skillsauth add aiskillstore/marketplace pydanticai-docsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides guidance for using Pydantic AI - a Python agent framework for building production-grade Generative AI applications. Pydantic AI emphasizes type safety, dependency injection, and structured outputs.
Agents are the primary interface for interacting with LLMs. They contain:
Pydantic AI supports multiple LLM providers via model identifiers.
All models that supports tool-calling can be used with pydantic-ai-skills.
Two types of tools:
@agent.tool: Receives RunContext with dependencies@agent.tool_plain: Plain function without contextCollections of tools that can be registered with agents:
FunctionToolset: Group multiple toolsMCPServerTool: Model Context Protocol serversFor comprehensive information, fetch the complete Pydantic AI documentation: https://ai.pydantic.dev/llms.txt
This contains complete documentation including agents, tools, dependencies, models, and API reference.
from pydantic_ai import Agent
agent = Agent('openai:gpt-5.2')
result = agent.run_sync('What is the capital of France?')
print(result.output)
from pydantic_ai import Agent, RunContext
agent = Agent('openai:gpt-5.2', deps_type=str)
@agent.tool
def get_user_name(ctx: RunContext[str]) -> str:
"""Get the current user's name."""
return ctx.deps
result = agent.run_sync('What is my name?', deps='Alice')
from pydantic import BaseModel
from pydantic_ai import Agent
class CityInfo(BaseModel):
name: str
country: str
population: int
agent = Agent('openai:gpt-5.2', output_type=CityInfo)
result = agent.run_sync('Tell me about Paris')
print(result.output) # CityInfo(name='Paris', country='France', population=...)
from dataclasses import dataclass
from pydantic_ai import Agent, RunContext
@dataclass
class MyDeps:
api_key: str
user_id: int
agent = Agent('openai:gpt-5.2', deps_type=MyDeps)
@agent.tool
async def fetch_data(ctx: RunContext[MyDeps]) -> str:
# Access dependencies via ctx.deps
return f"User {ctx.deps.user_id}"
from pydantic_ai import Agent
from pydantic_ai.toolsets import FunctionToolset
toolset = FunctionToolset()
@toolset.tool
def search(query: str) -> str:
"""Search for information."""
return f"Results for: {query}"
agent = Agent('openai:gpt-5.2', toolsets=[toolset])
import asyncio
from pydantic_ai import Agent
agent = Agent('openai:gpt-5.2')
async def main():
result = await agent.run('Hello!')
print(result.output)
asyncio.run(main())
from pydantic_ai import Agent
agent = Agent('openai:gpt-5.2')
async with agent.run_stream('Tell me a story') as response:
async for text in response.stream():
print(text, end='', flush=True)
@agent.instructions
async def add_context(ctx: RunContext[MyDeps]) -> str:
return f"Current user ID: {ctx.deps.user_id}"
@agent.system_prompt
def add_system_info() -> str:
return "You are a helpful assistant."
@agent.tool(retries=3)
def unreliable_api(query: str) -> str:
"""Call an unreliable API."""
...
from pydantic_ai.models.test import TestModel
with agent.override(model=TestModel()):
result = agent.run_sync('Test prompt')
# Full installation
pip install pydantic-ai
# Slim installation (specific model)
pip install "pydantic-ai-slim[openai]"
deps_type and output_type for better IDE supportretries parameter for unreliable toolsTestModel or override() for unit testsdevelopment
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.