PY

pydantic-models-py

Create consistent Pydantic models using Base, Create, Update, and Response variants. Ideal for robust Python API development.

Install

mkdir -p .claude/skills/pydantic-models-py && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/1234" && unzip -o skill.zip -d .claude/skills/pydantic-models-py && rm skill.zip

Installs to .claude/skills/pydantic-models-py

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Create Pydantic models following the multi-model pattern with Base, Create, Update, Response, and InDB variants. Use when defining API request/response schemas, database models, or data validation in Python applications using Pydantic v2.
238 chars✓ has a “when” trigger
Intermediate

Key capabilities

  • Define Base, Create, Update, Response, and InDB models
  • Implement camelCase aliases
  • Configure optional fields for PATCH requests
  • Add database document types

How it works

It applies a multi-model pattern to generate specialized variants of data models for different API and database layers.

Inputs & outputs

You give it
Resource schema definition
You get back
Set of Pydantic v2 models

When to use pydantic-models-py

  • Define consistent API request schemas
  • Generate database model variants
  • Validate incoming data with Pydantic v2

About this skill

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

ModelPurpose
BaseCommon fields shared across models
CreateRequest body for creation (required fields)
UpdateRequest body for updates (all optional)
ResponseAPI response with all fields
InDBDatabase 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] = None

Database Document

class MyInDB(MyResponse):
    doc_type: str = "my_resource"

Integration Steps

  1. Create models in src/backend/app/models/
  2. Export from src/backend/app/models/__init__.py
  3. Add corresponding TypeScript types

Reference Files

FileContents
references/capabilities.mdAdditional non-hero capabilities, operation-group coverage, and production checklists.

When not to use it

  • When working with non-Pydantic validation frameworks

Limitations

  • Requires adherence to the multi-model pattern

How it compares

It enforces a consistent multi-model structure that separates concerns between request, response, and database storage.

Compared to similar skills

pydantic-models-py side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
pydantic-models-py (this skill)329dNo flagsIntermediate
fastapi-templates5202moNo flagsIntermediate
fastapi-pro794moNo flagsAdvanced
fastapi-router-py529dNo flagsBeginner

Try saying

Example prompts that trigger this skill in your AI assistant.

More by microsoft

View all by microsoft

Search skills

Search the agent skills registry