building-pydantic-ai-agents

building-pydantic-ai-agents is a skill for Claude Code, Codex from mfmezger/ai_agent_dotfiles. It costs 76 tokens per session (2,701 once invoked), scanned A, original, MIT.

Guidance for building AI agents in Python with Pydantic AI, a framework for applications that use language models and tools.

In plain words
What is it for?
Use it to create agents, add tools, return structured results, stream responses, define agents from YAML or JSON, connect agents together, and test or observe their behavior.
Why use it?
It gives coding patterns for common agent tasks and helps keep agent inputs, outputs, events, and tests organized.

Skill for Claude CodeCodex

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

Good fit Use it to create agents, add tools, return structured results, stream responses, define agents from YAML or JSON, connect agents together, and test or observe their behavior.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mfmezger/ai_agent_dotfiles/building-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 mfmezger/ai_agent_dotfiles --skill building-pydantic-ai-agents
Clone the repo
git clone --depth 1 https://github.com/mfmezger/ai_agent_dotfiles

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/mfmezger/ai_agent_dotfiles/building-pydantic-ai-agents/github.svg)](https://agentmods.dev/skills/mfmezger/ai_agent_dotfiles/building-pydantic-ai-agents)
Your own site
<a href="https://agentmods.dev/skills/mfmezger/ai_agent_dotfiles/building-pydantic-ai-agents"><img src="https://agentmods.dev/badge/skills/mfmezger/ai_agent_dotfiles/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/mfmezger/ai_agent_dotfiles/building-pydantic-ai-agents"><img src="https://agentmods.dev/badge/skills/mfmezger/ai_agent_dotfiles/building-pydantic-ai-agents.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 76 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,701 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.00076 $0.02701
Opus 5.5 $0.00030 $0.01080
Sonnet 5.5 $0.00015 $0.00540
Haiku 4.5 $0.00008 $0.00270

Measured 3mo ago against content hash 4fed3c0a468c, 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 3mo ago.

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.

shared/skills/building-pydantic-ai-agents/SKILL.md · 275 lines

How it starts

The opening of the file, as written. The whole thing — 275 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

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

from pydantic_ai import Agent

agent = Agent(
    'anthropic:claude-sonnet-4-6',
    instructions='Be concise, reply with one sentence.',
)

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.
"""

Add Tools to an Agent

import random

from pydantic_ai import Agent, RunContext

agent = Agent(
    'google-gla:gemini-3-flash-preview',
    deps_type=str,
    instructions=(
        "You're a dice game, you should roll the die and see if the number "
        "you get back matches the user's guess. If so, tell them they're a winner. "
        "Use the player's name in the response."
    ),
)


@agent.tool_plain
def roll_dice() -> str:
    """Roll a six-sided die and return the result."""
    return str(random.randint(1, 6))


@agent.tool
def get_player_name(ctx: RunContext[str]) -> str:
    """Get the player's name."""
    return ctx.deps


dice_result = agent.run_sync('My guess is 4', deps='Anne')
print(dice_result.output)
#> Congratulations Anne, you guessed correctly! You're a winner!

Read the full file on GitHub · 275 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. 3mo ago First seen · 275 lines · 76 tokens per session scan A 4fed3c0a468c

Subscribe to this mod's changes

building-pydantic-ai-agents is a skill published in the GitHub repository mfmezger/ai_agent_dotfiles (7 stars, last pushed 4mo ago), licensed MIT. It adds 76 tokens to every session and 2,701 once invoked, about $0.0003 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-31.

Related

building-pydantic-ai-agents compared with skills from other repositories

building-pydantic-ai-agents next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
building-pydantic-ai-agentsmfmezger/ai_agent_dotfilesSkill74mo agoMITA76Claude Code, Codex
python-engineering-guidelinesanywhere-labs/Agents-AnywhereSkill3.9ktodayApache-2.0A75Codex
python-patternsDVNghiem/FlowDeckSkill4415d agoMITA33Claude Code, Codex
writing-pythonalexei-led/cc-thingzSkill37yesterdayMITA74Claude Code, Codex
mainframe-python-backendCATWILLgh/MAINFRAMESkill213d agoMITA40Claude Code, Codex
test-generatorbestdeejay-design/agent-skillsSkill52mo agoMITA0Claude Code
python-developmentHK-hub/AgentSkillsSkill73mo agoMITA63Claude Code, Codex