pydantic-model

pydantic-model is a skill for Claude Code from georgekhananaev/claude-skills-vault. It costs 28 tokens per session (2,473 once invoked), scanned A, original, MIT.

A guide for creating Pydantic v2 models, which are Python definitions that check and structure data moving through an application. It covers request and response models, validation rules, and converting data between MongoDB and an API.

In plain words
What is it for?
Use it when defining endpoint data models, adding validation, or mapping MongoDB records to API responses in a Python project.
Why use it?
It helps keep API data consistent and catches invalid values at the application boundary. It also avoids mixing older Pydantic v1 patterns with the v2 API.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

Good fit Use it when defining endpoint data models, adding validation, or mapping MongoDB records to API responses in a Python project.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/georgekhananaev/claude-skills-vault/pydantic-model
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add georgekhananaev/claude-skills-vault --skill pydantic-model
Clone the repo
git clone --depth 1 https://github.com/georgekhananaev/claude-skills-vault

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pydantic-model

README.md
[![agentmods](https://agentmods.dev/badge/skills/georgekhananaev/claude-skills-vault/pydantic-model/github.svg)](https://agentmods.dev/skills/georgekhananaev/claude-skills-vault/pydantic-model)
Your own site
<a href="https://agentmods.dev/skills/georgekhananaev/claude-skills-vault/pydantic-model"><img src="https://agentmods.dev/badge/skills/georgekhananaev/claude-skills-vault/pydantic-model/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pydantic-model

Your own site · 80×15
<a href="https://agentmods.dev/skills/georgekhananaev/claude-skills-vault/pydantic-model"><img src="https://agentmods.dev/badge/skills/georgekhananaev/claude-skills-vault/pydantic-model.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 28 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,473 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00028 $0.02473
Opus 5 $0.00014 $0.01236
Sonnet 5 $0.00006 $0.00495
Haiku 4.5 $0.00003 $0.00247

Measured 9d ago against content hash b0be82f97fec, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

pydantic-model scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

.claude/skills/pydantic-model/SKILL.md · 373 lines

How it starts

The opening of the file, as written. The whole thing — 373 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Pydantic Model Skill

Pydantic v2 model guidance for Travel Panel.

When to Use

  • Creating req/res models for endpoints
  • Defining DTOs
  • Adding validation rules
  • MongoDB ↔ API response conversion

Project Context

  • Models: app/classes/<feature>/
  • Version: Pydantic v2 only
  • Docs: docs/endpoint-development-guide.md

CRITICAL: v2 API Only

Deprecated (v1) Use (v2)
__fields__ model_fields
__validators__ model_validators
schema() model_json_schema()
parse_obj() model_validate()
dict() model_dump()
json() model_dump_json()

Model Creation

Step 1: Create Model File

Location: app/classes/<feature>/<feature>_models.py

from pydantic import BaseModel, Field, field_validator, model_validator
from typing import Optional, List
from datetime import datetime, timezone
from enum import Enum


class StatusEnum(str, Enum):
    ACTIVE = "active"
    INACTIVE = "inactive"
    PENDING = "pending"


class ItemCreate(BaseModel):
    """Create item request."""
    name: str = Field(..., min_length=1, max_length=255, examples=["My Item"])
    description: Optional[str] = Field(None, max_length=2000)
    status: StatusEnum = Field(default=StatusEnum.ACTIVE)
    tags: List[str] = Field(default_factory=list, max_length=10)
    price: float = Field(..., gt=0)

    @field_validator("name")
    @classmethod
    def validate_name(cls, v: str) -> str:
        v = v.strip()
        if not v:
            raise ValueError("Name cannot be empty")
        return v

    @field_validator("tags")
    @classmethod
    def validate_tags(cls, v: List[str]) -> List[str]:
        return list(set(tag.lower().strip() for tag in v if tag.strip()))


class ItemUpdate(BaseModel):
    """Update item request (all opt)."""
    name: Optional[str] = Field(None, min_length=1, max_length=255)
    description: Optional[str] = Field(None, max_length=2000)
    status: Optional[StatusEnum] = None
    tags: Optional[List[str]] = None
    price: Optional[float] = Field(None, gt=0)

    @model_validator(mode="after")
    def check_at_least_one_field(self) -> "ItemUpdate":
        if not self.model_dump(exclude_unset=True):
            raise ValueError("At least one field must be provided")
        return self


class ItemGet(BaseModel):
    """Item response."""
    id: str
    name: str
    description: Optional[str] = None
    status: str
    tags: List[str] = Field(default_factory=list)
    price: float
    company_id: str
    created_at: datetime
    updated_at: Optional[datetime] = None
    created_by: Optional[str] = None

    @classmethod
    def from_mongo(cls, doc: dict) -> "ItemGet":
        return cls(
            id=str(doc.get("_id", "")),
            name=doc.get("name", ""),
            description=doc.get("description"),
            status=doc.get("status", "active"),
            tags=doc.get("tags", []),
            price=doc.get("price", 0.0),
            company_id=doc.get("company_id", ""),
            created_at=doc.get("created_at", datetime.now(timezone.utc)),
            updated_at=doc.get("updated_at"),
            created_by=doc.get("created_by"),
        )


class ItemListMeta(BaseModel):
    totalRowCount: int
    page: Optional[int] = None
    pageSize: Optional[int] = None
    stats: Optional[dict] = None


class ItemListResponse(BaseModel):
    data: List[ItemGet]
    meta: ItemListMeta

Read the full file on GitHub · 373 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 373 lines · 28 tokens per session scan A b0be82f97fec

Subscribe to this mod's changes

pydantic-model is a skill published in the GitHub repository georgekhananaev/claude-skills-vault (28 stars, last pushed 1mo ago), licensed MIT. It adds 28 tokens to every session and 2,473 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

fastapi-expert

Use when building high-performance async Python APIs with FastAPI and Pydantic V2. Invoke to create REST endpoints, define Pydantic models, implement authentication flows, set up async SQLAlchemy database operations, add JWT authentication, build WebSocket endpoints, or generate OpenAPI documentation. Trigger terms…

Jeffallan/claude-skills · 95 tokens

django-expert

Use when building Django web applications or REST APIs with Django REST Framework. Invoke when working with settings.py, models.py, manage.py, or any Django project file. Creates Django models with proper indexes, optimizes ORM queries using selectrelated/prefetchrelated, builds DRF serializers and viewsets, and…

Jeffallan/claude-skills · 96 tokens

framework-migration-assistant

Automatically migrate Python web applications between frameworks (Flask → FastAPI, Django → FastAPI). Use when you need to migrate an existing web application to a modern framework while preserving functionality. The skill analyzes the codebase, updates routes, handlers, configuration, dependency injection patterns…

ArabelaTso/Skills-4-SE · 92 tokens

create-workflow-python

This skill creates a Dapr workflow application in Python. Use this skill when the user asks to "create a workflow in Python", "write a Python workflow application" or "build a workflow app in Python".

diagrid-labs/dapr-skills · 47 tokens

django

Use when building Django applications. Covers ORM query performance, model design, migrations, Django REST Framework, security defaults, and testing.

nimadorostkar/Claude-Skills-collection · 28 tokens

fastapi

Use when building APIs with FastAPI. Covers dependency injection, Pydantic v2 validation, async database access, authentication, background tasks, and testing.

nimadorostkar/Claude-Skills-collection · 34 tokens