pydantic-models-py — Claude Code skill: Pydantic v2 models
A skill that lays out Pydantic v2 models in five variants: Base, Create, Update, Response and InDB. Useful when you need request and response schemas for an API.
npx skills add microsoft/skills --skill pydantic-models-py -a claude-codeWhat pydantic-models-py does
The skill documents a multi-model pattern. Shared fields go in Base, required creation fields in Create, all-optional update fields in Update, the full API response in Response, and the database document with a doc_type field in InDB. Each variant inherits from the previous one, so you are not retyping the same fields.
A ready template sits at assets/template.py. Copy it and replace two placeholders: {{ResourceName}} in PascalCase and {{resource_name}} in snake_case. For camelCase aliases the template shows ConfigDict(populate_by_name=True) paired with Field(..., alias=...), which keeps incoming JSON in the client's casing while your Python code stays snake_case.
A second file, references/capabilities.md, carries production checklists. Then the integration steps: models go into src/backend/app/models/, get exported from src/backend/app/models/__init__.py, and matching TypeScript types are added alongside. That last step is where the skill stops helping — it does not generate the frontend types for you, so those stay hand-maintained.
What it helps with
- define API request and response schemas without repeating fields
- separate required create fields from optional update fields
- accept camelCase JSON while keeping snake_case in code
- attach a
doc_typemarker to a database document - group models in one module and export them from the package
Example prompts for the agent
- Create Pydantic models for a Project resource using the multi-model pattern
- Add camelCase aliases for workspaceId and createdAt to the model
- Write an Update model where every field is optional
How to install pydantic-models-py
1Skills CLI (Vercel)
npx skills add microsoft/skills --skill pydantic-models-py -a claude-code2Manually: put the files in place
~/.claude/skills/pydantic-models-py/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/pydantic-models-py/
Manually: put the files in place
.agents/skills/pydantic-models-py/SKILL.mdFor all projects use ~/.agents/skills/
Manually: put the files in place
.cursor/skills/pydantic-models-py/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install microsoft/skills pydantic-models-py2Manually: put the files in place
.github/skills/pydantic-models-py/SKILL.mdPlatform CLI
gemini skills install https://github.com/microsoft/skills --path .github/plugins/azure-sdk-python/skills/pydantic-models-pyManually: put the files in place
.devin/skills/pydantic-models-py/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about pydantic-models-py
How do I install pydantic-models-py in Claude?
Run npx skills add microsoft/skills --skill pydantic-models-py -a claude-code. The skill file then lands at ~/.claude/skills/pydantic-models-py/SKILL.md.
What does pydantic-models-py do?
It helps you define Pydantic v2 models in the multi-model pattern: Base, Create, Update, Response and InDB. It ships a template at assets/template.py with placeholders for the resource name.
Which other platforms are supported?
Besides Claude, the skill installs into GitHub Copilot with gh skill install microsoft/skills pydantic-models-py, and can be placed manually for Codex, Cursor and Gemini CLI.
Source text
SKILL.md · MIT
---
name: pydantic-models-py
description: 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.
license: MIT
metadata:
author: Microsoft
version: "1.0.0"
---
# Pydantic Models
Create Pydantic models following the multi-model pattern for clean API contracts.
## Quick Start
Copy the template from [assets/template.py](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
```python
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
```python
class MyUpdate(BaseModel):
model_config = ConfigDict(populate_by_name=True)
name: Optional[str] = Field(None, min_length=1)
description: Optional[str] = None
```
## Database Document
```python
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
| File | Contents |
|------|----------|
| [references/capabilities.md](references/capabilities.md) | Additional non-hero capabilities, operation-group coverage, and production checklists. |
© Microsoft · MIT · microsoft/skills