pydantic-v2
Installation
SKILL.md
Pydantic v2
Pydantic v2 (released 2023-06, current stable 2.13 as of 2026-04-19, paired with Python 3.10-3.14 including 3.14 free-threaded builds) is a near-complete rewrite on pydantic-core (Rust). API is similar but not identical to v1 -- several v1 patterns silently break or behave differently. This skill documents the v2 idioms, the v1 migration gotchas, and the FastAPI integration surface.
Notable recent releases:
- 2.11 (2025): 2x schema build-time improvements, 2-5x memory reduction for nested models, PEP 695/696 generic syntax, experimental free-threaded Python 3.13,
validate_by_alias/validate_by_name/serialize_by_aliasconfig (populate_by_namepending v3 deprecation),Pathanddequeno longer accept constraints (2.11 release). - 2.12: Python 3.14 support (PEP 649/749 annotations), experimental
MISSINGsentinel,exclude_ifon fields,ensure_asciion JSON output,serialize_as_anyunified behavior,@model_validator(mode="after")classmethod deprecated -- write as instance method (2.12 release). - 2.13 (April 2026): Polymorphic serialization (
model_dump(polymorphic_serialization=True)),exclude_ifextended to computed fields,ascii_onlyinStringConstraints,model_fields_settracks post-instantiation extras (2.13 release).
When to load which section
- Writing a new model from scratch -> "Core model patterns" + "Validators"
- Migrating from v1 -> "v1 -> v2 migration checklist"
- Working with money / decimals -> "Monetary precision (CWE-681 defense)"
- FastAPI request/response models -> "FastAPI integration"
- Performance-sensitive hot path -> "Performance notes"
- Secret handling / redaction -> "Security and secrets"
- Validation observability or LLM agents -> "PydanticAI and Logfire"
Related skills
More from acaprino/alfio-claude-plugins
python-refactor
>
167file-organizer
>
76legal-advisor
Use PROACTIVELY for any legal question -- contracts, compliance, privacy, IP, employment law, terms of service, NDAs, corporate governance. Expert legal advisor specializing in technology law, compliance, and risk mitigation.
39python-comments
>
35deep-dive-analysis
>
35python-performance-optimization
>
31