py-pydantic-patterns
Build Pydantic v2 Models Correctly
Pydantic v1 habits can cause validation and serialization defects. This skill provides Pydantic v2 patterns for schemas, validators, configuration, unions, and serialization.
Install with my Agent
Copy this request to your Agent. It includes the canonical Skill page and manifest.
Review the Skillstore skill "py-pydantic-patterns" from https://skillstore.io/skills/cjharmath-py-pydantic-patterns.md and its manifest at https://skillstore.io/api/skills/cjharmath-py-pydantic-patterns/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.Your Agent should still show its plan and request any confirmation required by the security policy.
Agent-readable resources
Use these links when an AI agent, crawler, or script needs clean context instead of reading the full page.
Test it
Using "py-pydantic-patterns". A developer asks how to migrate models that use Config, validator, and dict methods.
Expected outcome:
- A migration checklist that maps each v1 construct to its v2 replacement.
- Notes about model configuration, validator decorators, and model dumping behavior.
- A short testing plan for validation and serialization edge cases.
Using "py-pydantic-patterns". An API team needs request models for scores, ratings, and optional notes.
Expected outcome:
- A schema design plan with field constraints and default handling.
- Guidance for validation errors and OpenAPI descriptions.
- Recommendations for reusable constrained types.
Using "py-pydantic-patterns". A reviewer wants to check response serialization before release.
Expected outcome:
- A review summary covering excluded fields, aliases, computed fields, and serializer methods.
- Risks to test before exposing the response contract.
Security Audit
SafeAll static findings are false positives caused by Markdown code fences, inline-code formatting, or benign local grep examples in SKILL.md. No prompt injection, data exfiltration intent, destructive behavior, or unauthorized command execution was found.
Risk Factors
⚙️ External commands (32)
Share & cite this report
Share the versioned assessment report, neutral badge, embed card, and citations. Skillstore reports evidence without deciding whether this Skill is safe.
Copy report link
https://skillstore.io/skills/cjharmath-py-pydantic-patterns/audits/8?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown badge
[](https://skillstore.io/skills/cjharmath-py-pydantic-patterns?utm_source=security_passport_badge)HTML badge
<a href="https://skillstore.io/skills/cjharmath-py-pydantic-patterns?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/cjharmath-py-pydantic-patterns/security.svg" alt="Skillstore security assessment" loading="lazy"></a>Embed card
<iframe src="https://skillstore.io/embed/skills/cjharmath-py-pydantic-patterns.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>Academic citations (APA · BibTeX · CFF)
APA citation
CJHarmath. (2026). py-pydantic-patterns security audit report (audit version 8) [Author version unspecified]. Skillstore. https://skillstore.io/skills/cjharmath-py-pydantic-patterns/audits/8BibTeX citation
@techreport{cjharmath-cjharmath-py-pydantic-patterns-2026,
author = {CJHarmath},
title = {py-pydantic-patterns security audit report (audit version 8)},
institution = {Skillstore},
year = {2026},
number = {8},
url = {https://skillstore.io/skills/cjharmath-py-pydantic-patterns/audits/8},
note = {Author version unspecified}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "py-pydantic-patterns security audit report (audit version 8)"
version: "unspecified"
type: report
authors:
- name: "CJHarmath"
date-released: "2026-07-06"
url: "https://skillstore.io/skills/cjharmath-py-pydantic-patterns/audits/8"
identifiers:
- type: other
value: "skillstore:cjharmath-py-pydantic-patterns:audit:8"
description: "Skillstore immutable audit report identifier"
Skillstore Score
Why this score Evidence Confidence: HighWhat You Can Build
Migrate legacy Pydantic models
Replace v1 validators, config classes, and dump methods with Pydantic v2 equivalents.
Design API request schemas
Create constrained input models with clear validation errors and OpenAPI-friendly field metadata.
Review response serialization
Check model output, computed fields, aliases, and excluded fields before exposing API responses.
Try These Prompts
Create a Pydantic v2 model for this request body. Include field constraints, helpful error messages, and serialization guidance.
Review this Pydantic model for v1 patterns. List each required v2 change and explain the safer replacement.
Design Pydantic v2 validators for these related fields. Include when to use field validators versus model validators.
Design a Pydantic v2 schema strategy for these polymorphic responses. Use discriminated unions and explain serialization tradeoffs.
Best Practices
- Use Pydantic v2 APIs consistently when adding or changing models.
- Pair validator changes with tests for invalid, missing, and boundary values.
- Keep request, response, create, read, and update schemas separate when their fields differ.
Avoid
- Mixing v1 validators and v2 model configuration in the same schema.
- Returning ORM objects without enabling attribute-based model validation.
- Hiding serialization rules in ad hoc response code instead of model serializers.