pydantic-ai-agents

pydantic-ai-agents is a skill for Claude Code, Codex from Fuenfgeld/pydantic-ai-skills. It costs 135 tokens per session (4,194 once invoked), scanned A, original, MIT.

A guide for building and debugging Pydantic AI v2 agents, which are programs that use language models together with application data, tools, and validated results.

In plain words
What is it for?
It helps create or fix agents, add tools and validators, manage application context, define instructions and hooks, and validate structured output.
Why use it?
Agent projects need consistent handling of dependencies, instructions, tools, callbacks, and structured responses. The guide provides patterns for setting up these parts and handling the v1-to-v2 changes.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It helps create or fix agents, add tools and validators, manage application context, define instructions and hooks, and validate structured output.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/fuenfgeld/pydantic-ai-skills/pydantic-ai-agents
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Fuenfgeld/pydantic-ai-skills --skill pydantic-ai-agents
Clone the repo
git clone --depth 1 https://github.com/Fuenfgeld/pydantic-ai-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pydantic-ai-agents

README.md
[![agentmods](https://agentmods.dev/badge/skills/fuenfgeld/pydantic-ai-skills/pydantic-ai-agents/github.svg)](https://agentmods.dev/skills/fuenfgeld/pydantic-ai-skills/pydantic-ai-agents)
Your own site
<a href="https://agentmods.dev/skills/fuenfgeld/pydantic-ai-skills/pydantic-ai-agents"><img src="https://agentmods.dev/badge/skills/fuenfgeld/pydantic-ai-skills/pydantic-ai-agents/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pydantic-ai-agents

Your own site · 80×15
<a href="https://agentmods.dev/skills/fuenfgeld/pydantic-ai-skills/pydantic-ai-agents"><img src="https://agentmods.dev/badge/skills/fuenfgeld/pydantic-ai-skills/pydantic-ai-agents.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 135 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,194 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00135 $0.04194
Opus 5 $0.00068 $0.02097
Sonnet 5 $0.00027 $0.00839
Haiku 4.5 $0.00014 $0.00419

Measured 12d ago against content hash 4c310cc0f005, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

pydantic-ai-agents scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

The scan reads SKILL.md. This mod also ships 15 executable files (references/01_dependencies.py, references/02_prompts.py, references/03_tools.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/pydantic-ai-agents/SKILL.md · 387 lines

How it starts

The opening of the file, as written. The whole thing — 387 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Pydantic AI Reference Skill

Targets Pydantic AI v2 (v2.0.0 released 2026-06-23). See the v1 → v2 migration notes at the end for the breaking changes this skill's examples already incorporate.

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 five 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
Instructions (instructions):
  • Reference: references/02_prompts.py
  • v2 recommended: use instructions= / @agent.instructions (instructions are NOT carried in message history, so they always reflect the current agent)
  • Make them dynamic using the @agent.instructions decorator
  • Inject data from ctx.deps into the prompt string
  • Legacy system_prompt= / @agent.system_prompt still work; their text IS carried in message history - only use when replaying history across agents
Tools (@agent.tool / @agent.tool_plain):
  • Reference: references/03_tools.py
  • v2: @agent.tool REQUIRES ctx: RunContext as first parameter; use @agent.tool_plain for context-free tools (it raises otherwise)
  • 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
Capabilities (capabilities) - NEW in v2:
  • Reference: references/13_capabilities_native_tools.py
  • THE core v2 primitive: one composable unit bundling tools, hooks, instructions, and model settings
  • Provider-adaptive capabilities: Thinking, WebSearch, WebFetch, ImageGeneration, MCP
  • Replaces v1's builtin_tools=, prepare_tools=, history_processors=, instrument=, event_stream_handler= Agent arguments

Read the full file on GitHub · 387 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 387 lines · 135 tokens per session scan A 4c310cc0f005

Subscribe to this mod's changes

pydantic-ai-agents is a skill published in the GitHub repository Fuenfgeld/pydantic-ai-skills (10 stars, last pushed 2mo ago), licensed MIT. It adds 135 tokens to every session and 4,194 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.