pydantic
Installation
SKILL.md
Pydantic Skill
Think of Pydantic models as PHP type-hinted DTOs, Java POJOs with validation, or Rails Strong Parameters + serializers — but with automatic type coercion and validation built in.
Core Concepts
BaseModelis the foundation — define fields as class attributes with type hints.- Pydantic validates and coerces data at instantiation time; invalid data raises
ValidationError. - v2 is the current standard — avoid v1 patterns (
validator,orm_mode) in new code.
Defining Models
from pydantic import BaseModel, Field
from datetime import datetime