pydantic

pydantic is a skill for Claude Code, Codex from arnabdeypolimi/claude_code_setup. It costs 66 tokens per session (7,557 once invoked), scanned A, original, MIT.

A Python validation guide for Pydantic v2, a library that checks incoming data against declared types and rules.

In plain words
What is it for?
Validating API requests and responses, configuration, database records, parsed data, and typed command-line inputs.
Why use it?
It helps reject malformed data and convert or report values consistently at application boundaries.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/arnabdeypolimi/claude_code_setup/pydantic
Any agent
npx skills add arnabdeypolimi/claude_code_setup --skill pydantic
Clone the repo
git clone --depth 1 https://github.com/arnabdeypolimi/claude_code_setup

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/arnabdeypolimi/claude_code_setup/pydantic.svg)](https://agentmods.dev/skills/arnabdeypolimi/claude_code_setup/pydantic)
Your own site
<a href="https://agentmods.dev/skills/arnabdeypolimi/claude_code_setup/pydantic"><img src="https://agentmods.dev/badge/skills/arnabdeypolimi/claude_code_setup/pydantic.svg" alt="Measured on agentmods" height="20"></a>
Per session 66 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 7,557 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00066 $0.07557
Opus 5 $0.00033 $0.03778
Sonnet 5 $0.00013 $0.01511
Haiku 4.5 $0.00007 $0.00756

Measured 3d ago against content hash 80ea080fdca5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pydantic 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 3d 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.

.claude/skills/pydantic/SKILL.md · 1,325 lines

How it starts

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

Pydantic Validation Skill

Summary

Python data validation using type hints and runtime type checking with Pydantic v2's Rust-powered core for high-performance validation.

When to Use

  • API request/response validation (FastAPI, Django)
  • Settings and configuration management (env variables, config files)
  • ORM model validation (SQLAlchemy integration)
  • Data parsing and serialization (JSON, dict, custom formats)
  • Type-safe data classes with automatic validation
  • CLI argument parsing with type safety

Quick Start

from pydantic import BaseModel, Field, EmailStr
from datetime import datetime

class User(BaseModel):
    id: int
    name: str = Field(..., min_length=1, max_length=100)
    email: EmailStr
    created_at: datetime = Field(default_factory=datetime.now)
    is_active: bool = True

# Validate data
user = User(id=1, name="Alice", email="[email protected]")
print(user.model_dump())  # {'id': 1, 'name': 'Alice', ...}

# Automatic type coercion
user2 = User(id="2", name="Bob", email="[email protected]")
assert user2.id == 2  # String "2" coerced to int

# Validation error
try:
    User(id=3, name="", email="invalid")
except ValidationError as e:
    print(e.errors())

Core Concepts

BaseModel Foundation

from pydantic import BaseModel, ConfigDict

class Product(BaseModel):
    model_config = ConfigDict(
        str_strip_whitespace=True,
        validate_assignment=True,
        use_enum_values=True,
        arbitrary_types_allowed=False
    )

    name: str
    price: float
    quantity: int = 0

# Usage
product = Product(name="  Widget  ", price=19.99)
assert product.name == "Widget"  # Whitespace stripped

# Validate on assignment
product.price = "29.99"  # Auto-converts to float

Field Configuration

from pydantic import Field, field_validator
from typing import Annotated

class Item(BaseModel):
    # Field constraints
    sku: str = Field(pattern=r'^[A-Z]{3}-\d{4}$')
    price: float = Field(gt=0, le=10000)
    stock: int = Field(ge=0, default=0)

    # Annotated types (Pydantic v2)
    quantity: Annotated[int, Field(ge=1, le=100)]

    # Descriptions and examples
    description: str = Field(
        ...,
        description="Product description",
        examples=["High-quality widget"]
    )

    # Deprecated fields
    old_field: str | None = Field(None, deprecated=True)

    @field_validator('sku')
    @classmethod
    def validate_sku(cls, v: str) -> str:
        if not v.startswith('ABC'):
            raise ValueError('SKU must start with ABC')
        return v

Read the full file on GitHub · 1,325 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. 3d ago First seen · 1,325 lines · 66 tokens per session scan A 80ea080fdca5

Subscribe to this mod's changes

pydantic is a skill published in the GitHub repository arnabdeypolimi/claude_code_setup (4 stars, last pushed 3mo ago), licensed MIT. It adds 66 tokens to every session and 7,557 once invoked, about $0.0003 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.

Related

Other skills, from other repositories

modelcontextprotocol-python-sdk-context

Answers questions about the official Model Context Protocol (MCP) Python SDK (mcp package on PyPI, modelcontextprotocol/python-sdk on GitHub). Tracks the main branch (v2 pre-alpha — MCPServer/snakecase/constructor-on handlers). Use when working with MCP servers or clients in Python, debugging v1→v2 migrations, or…

nick-railsback/skill-engine · 116 tokens

bump-dependency

Bumps a Python package dependency across Home Assistant Core integrations, regenerates core requirement files, runs verification tests and prek lint, and prepares a pull request with proper release/compare links.

home-assistant/core · 42 tokens

agent-framework-azure-ai-py

Build persistent agents on Azure AI Foundry using the Microsoft Agent Framework Python SDK.

sickn33/agentic-awesome-skills · 24 tokens

python-feature-lifecycle

Guidance for package and feature lifecycle in the Agent Framework Python codebase, including stage meanings, feature-stage decorators, feature enums, and how to move APIs from one stage to the next.

microsoft/agent-framework · 43 tokens

python-development

Coding standards, conventions, and patterns for developing Python code in the Agent Framework repository. Use this when writing or modifying Python source files in the python/ directory.

microsoft/agent-framework · 35 tokens

python-sdk

Implement or modify Python SDK behavior under python/composio, including tools, toolkits, sessions, auth configs, connected accounts, client integration, and shared Python models. Use for Python core runtime/API work; pair with python-testing and cross-sdk-parity when TypeScript must match.

ComposioHQ/composio · 60 tokens