building-pydantic-ai-agents

building-pydantic-ai-agents is a skill for Claude Code, Codex from pydantic/pydantic-ai. It costs 92 tokens per session (8,794 once invoked), scanned A, original, MIT.

A set of patterns for building AI agents with Pydantic AI, a Python framework for applications that use language models and tools.

In plain words
What is it for?
Use it when creating agents, adding tools or optional capabilities, producing structured results, streaming events, delegating tasks, or working with Pydantic AI code.
Why use it?
It provides guidance for structuring agent behavior, outputs, streaming, testing, and cooperation between multiple agents.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents).

Good fit Use it when creating agents, adding tools or optional capabilities, producing structured results, streaming events, delegating tasks, or working with Pydantic AI code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/pydantic/pydantic-ai/building-pydantic-ai-agents
About the project

Pydantic AI is a typed Python SDK for building AI agents that can use different language models and interfaces, including voice, image generation, and embeddings. Developers use it for applications ranging from structured data extraction to long-running multi-agent work. The catalogue entries provide workflows and configuration for its coding-agent and harness features.

pydantic/pydantic-ai · 20,889 stars · on GitHub · pydantic.dev

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 pydantic/pydantic-ai --skill building-pydantic-ai-agents
Clone the repo
git clone --depth 1 https://github.com/pydantic/pydantic-ai

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 building-pydantic-ai-agents

README.md
[![agentmods](https://agentmods.dev/badge/skills/pydantic/pydantic-ai/building-pydantic-ai-agents/github.svg)](https://agentmods.dev/skills/pydantic/pydantic-ai/building-pydantic-ai-agents)
Your own site
<a href="https://agentmods.dev/skills/pydantic/pydantic-ai/building-pydantic-ai-agents"><img src="https://agentmods.dev/badge/skills/pydantic/pydantic-ai/building-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 building-pydantic-ai-agents

Your own site · 80×15
<a href="https://agentmods.dev/skills/pydantic/pydantic-ai/building-pydantic-ai-agents"><img src="https://agentmods.dev/badge/skills/pydantic/pydantic-ai/building-pydantic-ai-agents.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 92 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 8,794 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. Third-party audits
  • Snyk pass 7 Sept 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00092 $0.08794
Opus 5.5 $0.00037 $0.03518
Sonnet 5.5 $0.00018 $0.01759
Haiku 4.5 $0.00009 $0.00879

Measured today against content hash bb979b79442c, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

building-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 today.

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.

pydantic_ai_slim/pydantic_ai/.agents/skills/building-pydantic-ai-agents/SKILL.md · 515 lines

How it starts

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

Building AI Agents with Pydantic AI

Pydantic AI is a Python agent framework for building production-grade Generative AI applications. This skill provides patterns, architecture guidance, and tested code examples for building applications with Pydantic AI.

When to Use This Skill

Invoke this skill when:

  • User asks to build an AI agent, create an LLM-powered app, or mentions Pydantic AI
  • User wants to add tools, capabilities (thinking, web search), or structured output to an agent
  • User asks to define agents from YAML/JSON specs or use template strings
  • User wants to stream agent events, delegate between agents, or test agent behavior
  • Code imports pydantic_ai or references Pydantic AI classes (Agent, RunContext, Tool)
  • User asks about hooks, lifecycle interception, or agent observability with Logfire
  • User wants to reach models from several providers with one API key (the Pydantic AI Gateway)
  • User wants an agent to run commands or access files in an attached workspace
  • The agent design includes optional instructions, specialist workflows, long-tail tools, or any context the model does not need on most turns

Do not use this skill for:

  • The Pydantic validation library alone (pydantic/BaseModel without agents)
  • Other AI frameworks (LangChain, LlamaIndex, CrewAI, AutoGen)
  • General Python development unrelated to AI agents

Quick-Start Patterns

Create a Basic Agent

Start new applications with Logfire instrumentation and prompt caching in place, so the first run is already visible and repeated prompt prefixes are read from the cache (see Set Up Observability and Model Access for credentials and alternatives):

import logfire

from pydantic_ai import Agent
from pydantic_ai.capabilities import Caching

logfire.configure()
logfire.instrument_pydantic_ai()

agent = Agent(
    'anthropic:claude-fable-5-1',
    name='hello_world_agent',
    instructions='Be concise, reply with one sentence.',
    capabilities=[Caching()],
)

result = agent.run_sync('Where does "hello world" come from?')
print(result.output)
"""
The first known use of "hello, world" was in a 1974 textbook about the C programming language.
"""

Read the full file on GitHub · 515 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. today Changed · +14 lines bb979b79442c
  2. 3d ago Changed c49b232964c4
  3. 4d ago Changed · +1 lines 0501b6e9980f
  4. 6d ago Changed · +7 lines 5beb0f39db22
  5. 7d ago Changed · +8 lines 9d823213a50a
  6. 10d ago Changed · +4 lines fb465da0f98e
  7. 11d ago Changed 04abc521e436
  8. 13d ago Changed · +2 lines 2e7ef7da3a89
  9. 17d ago Changed · +3 lines 00df1499b4d8
  10. 20d ago First seen · 476 lines · 92 tokens per session scan A baf8fb96764c

Subscribe to this mod's changes

building-pydantic-ai-agents is a skill published in the GitHub repository pydantic/pydantic-ai (20,889 stars, last pushed today), licensed MIT. It adds 92 tokens to every session and 8,794 once invoked, about $0.0004 per session on Opus 5.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-30.