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.
npx agentmods add skills/vikasudasi/skill-vault/python-dataclasses-pydanticnpx skills add vikasudasi/skill-vault --skill python-dataclasses-pydanticgit clone --depth 1 https://github.com/vikasudasi/skill-vaultWrote 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.
[](https://agentmods.dev/skills/vikasudasi/skill-vault/python-dataclasses-pydantic)<a href="https://agentmods.dev/skills/vikasudasi/skill-vault/python-dataclasses-pydantic"><img src="https://agentmods.dev/badge/skills/vikasudasi/skill-vault/python-dataclasses-pydantic.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00033 | $0.01634 |
| Opus 5 | $0.00016 | $0.00817 |
| Sonnet 5 | $0.00007 | $0.00327 |
| Haiku 4.5 | $0.00003 | $0.00163 |
Grade A, and why
python-dataclasses-pydantic 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 2d 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.
How it starts
The opening of the file, as written. The whole thing — 159 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Data Modeling with Dataclasses + Pydantic
Use when a module carries structured records and you want type safety, validation, or clean JSON round-tripping. The two tools overlap but solve different problems: dataclasses are a lightweight typing/memory tool; Pydantic adds runtime validation + serialization at the boundary.
Type-safety with dataclasses
from __future__ import annotations
from dataclasses import dataclass
@dataclass(slots=True)
class Point:
x: float
y: float
@dataclass(slots=True) reduces memory and prevents accidental attribute typos
(an unknown attribute becomes an AttributeError, not a silent new field).
Validation + serialization with Pydantic (v2)
from pydantic import BaseModel, Field
class SkillInput(BaseModel):
name: str = Field(min_length=3, max_length=64)
description: str
tags: list[str] = Field(default_factory=list)
port: int = Field(ge=1, le=65535)
@field_validator("name")
@classmethod
def _no_whitespace(cls, v: str) -> str:
v = v.strip()
if not v:
raise ValueError("name must not be blank")
return v
Pydantic v2 is the current API (pydantic ≥ 2.0). Key calls:
Model.model_validate(data)— validate/coerce a dict or object.Model.model_validate_json(s)— parse + validate a JSON string directly.model.model_dump()/model.model_dump_json()— serialize to dict / JSON.Field(...)— constraints and defaults (min_length,ge,default_factory).@field_validator("x")— per-field post-validation transforms/checks.@computed_field— a read-only property exposed inmodel_dump().ConfigDict/model_config— e.g.model_config = ConfigDict(frozen=True, extra="forbid").
Nesting composes cleanly: a field whose type is another BaseModel is validated
recursively, so you get a typed, validated object graph from JSON in one call.
Decision table: dataclass vs Pydantic
| Concern | @dataclass |
Pydantic BaseModel |
|---|---|---|
| Runtime validation / coercion of inputs | ✗ none | ✓ automatic, per-field |
| JSON round-trip | manual asdict/json.dumps |
model_dump_json() / model_validate_json |
| Performance (creation in hot loops) | fast, near-plain-class | slower — validation overhead per instantiation |
| Mutable default lists/dicts | foot-gun (see Pitfalls) | default_factory handled, but Field(default_factory=...) still required |
| Immutable value objects | frozen=True |
ConfigDict(frozen=True) |
| Serialization shape control | manual | rich (by_alias, exclude_unset, computed_field) |
| Syntax/deps | stdlib, zero deps | third-party dependency |
What ships with it
2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
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.
- 2d ago First seen · 159 lines · 33 tokens per session scan A f43f9aa9b470
python-dataclasses-pydantic is a skill published in the GitHub repository vikasudasi/skill-vault (0 stars, last pushed 17d ago), licensed Apache-2.0. It adds 33 tokens to every session and 1,634 once invoked, about $0.0002 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-08-31.
Other skills, from other repositories
add-new-model
Add support for a newly-released LLM model in pydantic-ai (e.g. openai:gpt-5.6, anthropic:claude-sonnet-5). Use when a provider ships a new model id and you need to wire literals, profile flags, and tests to recognize it. Handles SDK-lag, gateway list conventions, and capability probing.
building-pydantic-ai-agents
Build AI agents with Pydantic AI — tools, capabilities (including on-demand loading), structured output, streaming, testing, and multi-agent patterns. Use when the user mentions Pydantic AI, imports pydanticai, or asks to build an AI agent, add tools/capabilities, defer capability loading, stream output, define agents…
migrating-langchain-to-pydantic-ai
Migrate Python LangChain or LangGraph applications to Pydantic AI. Use for LangChain agents, chains, LCEL, or direct LangGraph graphs, persistence, interrupts, and streaming. Do not use for migrations centered on createdeepagent or Deep Agents harness features.
datamodel-code-generator
Use this skill when the user wants Python data models, Pydantic models, dataclasses, TypedDicts, msgspec structs, or type-safe Python classes generated from OpenAPI, AsyncAPI, JSON Schema, GraphQL, JSON/YAML/CSV sample data, MCP tool schemas, Protocol Buffers, XML Schema, Apache Avro, or existing Python model objects.…
test-generator
Generate pytest test cases for Python functions and classes.
pydantic-ai-agents
Build and debug Pydantic AI v2 agents using best practices for dependencies, instructions, tools, capabilities, hooks, and structured output validation. Use when the user wants to: (1) Create a new Pydantic AI agent, (2) Debug or fix an existing agent, (3) Add features like tools, validators, capabilities, hooks, or…