pydantic

pydantic is a skill for Claude Code 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 Code

Written for Claude Code: installed under .claude/.

Good fit Validating API requests and responses, configuration, database records, parsed data, and typed command-line inputs.

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

Made for: Claude Code.

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/github.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/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

Your own site · 80×15
<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="Reviewed on agentmods" width="80" 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. 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.00066 $0.07557
Opus 5.5 $0.00026 $0.03023
Sonnet 5.5 $0.00013 $0.01511
Haiku 4.5 $0.00007 $0.00756

Measured 1mo ago against content hash 80ea080fdca5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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. 1mo 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 1mo ago), licensed MIT. It adds 66 tokens to every session and 7,557 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.