pydantic
Skill1 starsChanged 4 months agoMITView on GitHub
Use when designing, implementing, reviewing, or debugging Pydantic models, validators or serializers.
8 other projects use a version of this.
Adopted by
Most recently taken up by
- ZRMYDYCG/ClaudeCodetheir own version, first seen Oct 17, 2026
- pydantic/skillstheir own version, first seen Oct 16, 2026
- nek1987/auto-agent-harnesstheir own version, first seen Oct 11, 2026
- kid-sid/claude-spellbooktheir own version, first seen Oct 9, 2026
- L-1124/QQMusicApitheir own version, first seen Oct 8, 2026
- pydantic/pydantictheir own version, first seen Aug 25, 2026
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- pydantic/pydantic★ 29ksame name
- L-1124/QQMusicApi★ 529same name
- kid-sid/claude-spellbook★ 190same name
- pydantic/skills★ 144same name
- arnabdeypolimi/claude_code_setup★ 4same name
- nek1987/auto-agent-harness★ 4same name
- Danifelipaez/NeoCafeIA★ 1same name
- ZRMYDYCG/ClaudeCode★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- duckdb-tipsSkill
- karpathy-guidelinesSkill
- openhoundSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 6 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
6
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Use this skill for Pydantic V2 data validation work in Python codebases.
- Very specific: line 27
Treat this skill and its references as the primary offline guide.
- Distinctive: line 29
Put validation and normalization on the Pydantic model that owns the data.
- Distinctive: line 30
Prefer built-in Pydantic features over custom parsing, custom conversion, or hand-written schema logic.
- Very specific: line 33
Verify behavior with both valid and invalid examples, including the exact ValidationError locations when validation rules matter.
- Distinctive: line 38
Check the project's existing Pydantic style before adding new patterns.
- Distinctive: line 40
Add or update tests that validate successful parsing, rejected inputs, default handling, aliases, strictness, and serialization where …
- Distinctive: line 41
Run focused tests, and include a quick direct model instantiation check when a dedicated test suite is unavailable.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Pydantic
Use this skill for Pydantic V2 data validation work in Python codebases.
When to Use
- Creating or changing
BaseModel,RootModel, Pydantic dataclass, or settings classes. - Adding field constraints, aliases, defaults, strictness, validators, serializers, or JSON Schema metadata.
- Validating non-model types with
TypeAdapter. - Debugging
ValidationError,PydanticUserError, schema rebuild, forward reference, coercion, or serialization behavior. - Reviewing or migrating code that still uses Pydantic V1 APIs like
dict(),json(),parse_obj(),@validator,@root_validator, orConfig.
Operating Rules
- Treat this skill and its references as the primary offline guide. If more detail is needed and internet access is available, use the public Pydantic documentation at
https://docs.pydantic.dev/latest/. - Model data shape with type annotations first, then add
Field,Annotated, validators, or config only where needed. - Put validation and normalization on the Pydantic model that owns the data. Use field validators for single-field logic and model validators for cross-field invariants.
- Prefer built-in Pydantic features over custom parsing, custom conversion, or hand-written schema logic. Use the source links in each reference only for deeper edge cases.
- Remember that Pydantic validation guarantees the output type and constraints, not that input data was already valid.
- Be explicit about coercion. Pydantic is lax by default; use strict validation when accepting coercion would be unsafe.
- Verify behavior with both valid and invalid examples, including the exact
ValidationErrorlocations when validation rules matter.
Workflow
- Identify the Pydantic version and the task category: model design, field constraints, validators, serialization, settings, TypeAdapter, JSON Schema, or migration.
- Check the project's existing Pydantic style before adding new patterns.
- Implement the smallest model or validation change that expresses the data contract.
- Add or update tests that validate successful parsing, rejected inputs, default handling, aliases, strictness, and serialization where applicable.
- Run focused tests, and include a quick direct model instantiation check when a dedicated test suite is unavailable.
Core References
| Topic | Use For | Reference |
| Models and validation | BaseModel, validation methods, extra data, forward refs, RootModel | models-validation |
| Fields and aliases | Field, defaults, Annotated, constraints, aliases | fields-aliases |
| Field types | Standard library, Pydantic, network, strict, constrained, encoded, and optional extra field types | field-types |
| Validators | field_validator, model_validator, validation context, errors | validators |
| Config and strict mode | ConfigDict, global config, strict validation | config-strict-mode |
| Serialization and JSON Schema | model_dump, serializers, schema generation | serialization-json-schema |
| TypeAdapter and settings | Ad-hoc validation, settings management | type-adapter-settings |
Templates
| Template | Use For |
| model.py.md | Starting a Pydantic V2 BaseModel with config, constraints, validation, and dumps. |
| validators.py.md | Copyable field, model, ValidationInfo, and reusable Annotated validator patterns. |
| settings.py.md | Starting a pydantic-settings configuration model with secret-safe patterns. |
Scripts
| Script | Use For |
| list_pydantic_fields.py | Importing a Pydantic V2 model and printing field annotations, aliases, defaults, and metadata. |
Quick Patterns
from typing import Annotated
from pydantic import BaseModel, ConfigDict, Field, ValidationError, field_validator
class User(BaseModel):
model_config = ConfigDict(extra='forbid')
id: int
email: Annotated[str, Field(min_length=3)]
display_name: str = Field(default='Anonymous', validate_default=True)
@field_validator('email', mode='after')
@classmethod
def require_at_sign(cls, value: str) -> str:
if '@' not in value:
raise ValueError('email must contain @')
return value
try:
user = User.model_validate({'id': '123', 'email': 'a@example.com'})
except ValidationError as exc:
print(exc.errors())
else:
print(user.model_dump())from pydantic import TypeAdapter
ids_adapter = TypeAdapter(list[int])
ids = ids_adapter.validate_python(['1', 2, 3])
payload = ids_adapter.dump_json(ids)Common Review Checks
- Required fields have no defaults; optional-nullable fields use
T | Noneand still need= Noneif they are not required. - Defaults that must be validated use
Field(validate_default=True)orConfigDict(validate_default=True). - Mutable defaults are intentional. Pydantic deep-copies unhashable defaults, but
default_factoryis clearer for generated values. - Cross-field validators account for field order when using
ValidationInfo.data. - Aliases distinguish validation input names from serialization output names when they differ.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

