Pydantic Models Py
MicrosoftOfficialCreated by Microsoft
- Skill
- Content generator
- Software development
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to defining data models in Python applications using Pydantic v2. It promotes a multi-model pattern that separates concerns by defining distinct classes for base attributes, creation requests, update requests, API responses, and database persistence. By following this pattern, developers can ensure consistent data validation, clean API contracts, and maintainable codebases.
What it does
- Defines a multi-model pattern including Base, Create, Update, Response, and InDB variants.
- Provides templates for consistent model structure across API and database layers.
- Demonstrates how to implement camelCase aliases for frontend compatibility.
- Guides the creation of optional update fields for partial resource modifications.
- Outlines integration steps for organizing models within a backend project structure.
- Includes best practices for Pydantic v2 validation and serialization.
When to use it
- When designing API request and response schemas for a Python backend.
- When defining database document structures that require specific metadata.
- When you need to enforce strict data validation across different application layers.
- When migrating or starting a new project using Pydantic v2.
Advantages
- Ensures consistent data contracts between backend and frontend.
- Reduces code duplication by using a shared Base model.
- Improves maintainability by separating creation, update, and response logic.
- Facilitates easier integration with TypeScript-based frontend applications.
Usage examples
- “Create a set of Pydantic models for a User resource using the multi-model pattern.”
- The agent generates a file containing UserBase, UserCreate, UserUpdate, UserResponse, and UserInDB classes, ensuring all fields are correctly typed and configured.
- “How do I define an update model where all fields are optional?”
- The agent provides a code snippet using Optional type hints and Field(None) to ensure the update model allows partial updates.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/microsoft/pydantic-models-py/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip pydantic-models-py.zip -d .agents/skills
Documentation by Microsoft
Pydantic Models
Create Pydantic models following the multi-model pattern for clean API contracts.
Quick Start
Copy the template from assets/template.py and replace placeholders:
{{ResourceName}}→ PascalCase name (e.g.,Project){{resource_name}}→ snake_case name (e.g.,project)
Multi-Model Pattern
| Model | Purpose |
|---|---|
Base | Common fields shared across models |
Create | Request body for creation (required fields) |
Update | Request body for updates (all optional) |
Response | API response with all fields |
InDB | Database document with doc_type |
camelCase Aliases
from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field
class MyModel(BaseModel):
model_config = ConfigDict(populate_by_name=True)
workspace_id: str = Field(..., alias="workspaceId")
created_at: datetime = Field(..., alias="createdAt")Optional Update Fields
class MyUpdate(BaseModel):
model_config = ConfigDict(populate_by_name=True)
name: Optional[str] = Field(None, min_length=1)
description: Optional[str] = NoneDatabase Document
class MyInDB(MyResponse):
doc_type: str = "my_resource"Integration Steps
Create models in
src/backend/app/models/Export from
src/backend/app/models/__init__.pyAdd corresponding TypeScript types
Reference Files
| File | Contents |
|---|---|
| references/capabilities.md | Additional non-hero capabilities, operation-group coverage, and production checklists. |
Files
- ATTRIBUTION.mdAdded by AutoGineer965 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md1.9 KiB
- assets/template.pyScript1.5 KiB
- references/capabilities.md1.1 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/skills · .github/plugins/azure-sdk-python/skills/pydantic-models-py · commit 0696600
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Microsoft or Microsoft.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download pydantic-models-py.zip