pydantic-ai-agents
Build and debug Pydantic AI agents using best practices for dependencies, dynamic system prompts, tools, and structured output validation. Use when the user wants to: (1) Create a new Pydantic AI agent, (2) Debug or fix an existing agent, (3) Add features like tools, validators, or dynamic prompts, (4) Integrate OpenRouter for multi-model access, (5) Add Logfire for debugging/observability, (6) Structure agent architecture with dependency injection.
npx skills add majiayu000/claude-skill-registry --skill pydantic-ai-agents --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Pydantic AI Reference Skill ## Pydantic AI Developer Guide ### 0. Environment Setup Store API keys in a `.env` file and add it to `.gitignore`: ``` OPENAI_API_KEY=your_key OPENROUTER_API_KEY=your_key LOGFIRE_API_KEY=your_key ``` Load with `python-dotenv`: `load_dotenv()`. Never hardcode keys in source code. ### 1. Core Architecture Pydantic AI agents have four key components: #### Dependencies (deps): - **Reference**: `references/01_dependencies.py` - Use dataclasses to hold API keys, database connections, and user context - Never use global variables for state #### System Prompts (system_prompt): - **Reference**: `references/02_prompts.py` - Make prompts dynamic using `@agent.system_prompt` decorator - Inject data from `ctx.deps` into the prompt string #### Tools (@agent.tool): - **Reference**: `references/03_tools.py` - **IMPORTANT**: When `deps_type` is set on the agent, ALL tools must have `ctx: RunContext` as first parameter - even if they don't use it - Use `ctx.deps` to access injected dependencies #### Validators (output_type): - **Reference**: `references/04_validators.py` - Use Pydantic models to enforce structured output - Use `@field_validator` for logic checks ### 2.
- Pydantic AI Developer Guide
- 0. Environment Setup
- 1. Core Architecture
- 2. Promoting Instructions (System Prompt Engineering)
- 3. OpenRouter Integration
- 4. Debugging with Logfire
- 5. Advanced Patterns
- 6. Conversation History (Persistent Memory)
- 7. Testing Best Practices
- 8. Usage
- 9. Complete Example
What does the pydantic-ai-agents skill do?
Build and debug Pydantic AI agents using best practices for dependencies, dynamic system prompts, tools, and structured output validation. Use when the user wants to: (1) Create a new Pydantic AI agent, (2) Debug or fix an existing agent, (3) Add features like tools, validators, or dynamic prompts, (4) Integrate OpenRouter for multi-model access, (5) Add Logfire for debugging/observability, (6) Structure agent architecture with dependency injection.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill pydantic-ai-agents --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
