datamodel-code-generator
Generate Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct from OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, and raw JSON/YAML/CSV.
datamodel-code-generator is an agent skill that enables coding agents to automatically generate type-safe Python data models from schema definitions and data sources. It teaches compatible agents (Codex, Claude Code) when and how to invoke the datamodel-codegen CLI to produce Pydantic v2 models, dataclasses, TypedDict, or msgspec.Struct classes from OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, and raw JSON/YAML/CSV. The skill helps agents produce validated, IDE-ready Python code during development workflows, eliminating manual model creation and reducing serialization errors.
Key Features
Use Cases
- 01Generate Pydantic models from OpenAPI specifications for FastAPI or REST client development
- 02Convert JSON Schema definitions to validated dataclasses for configuration management
- 03Create TypedDict types from GraphQL schemas for type-safe query responses
- 04Transform MCP tool schemas into Pydantic models for Model Context Protocol server development
- 05Migrate existing Python models between output types (Pydantic to dataclass, TypedDict to msgspec)
- 06Automate model updates in CI pipelines when API schemas change
Related Skills
View moresuperpowers
An agentic skills framework & software development methodology that works.
skills
Skills for Real Engineers. Straight from my .agents directory.
skills
Public repository for Agent Skills
ponytail
Makes your AI agent think like the laziest senior dev in the room. The best code is the code you never wrote.
datamodel-code-generator — FAQ
What is the datamodel-code-generator agent skill?+
It's a coding agent skill that teaches AI assistants like Codex and Claude Code to generate Python data models from schema files using the datamodel-codegen CLI. The skill helps agents recognize when to invoke the generator and which options to use for different input formats and output styles.
How do I install this agent skill?+
Copy the skills/datamodel-code-generator directory to your agent's skill search path: .agents/skills/ for Codex or .claude/skills/ for Claude Code (project-local), or to ~/.agents/skills/ or ~/.claude/skills/ for personal installs. First install the datamodel-codegen CLI tool itself via 'uv tool install datamodel-code-generator' or 'pip install datamodel-code-generator'.
Which AI clients work with this skill?+
Currently supports Codex and Claude Code as documented in the README. Other coding agents that follow similar skill discovery conventions may work if they can execute shell commands and read local skill documentation.
Do I need API keys or accounts?+
No external API keys required for the skill itself. However, generating models from remote URLs requires network access, and using the --allow-remote-refs option needs the [http] extra installed. The playground runs entirely locally in the browser via Pyodide.
Is this skill free and open source?+
Yes, the skill and datamodel-code-generator tool are MIT licensed and free to use. The repository is maintained by Koudai Aono with community contributions.
What input formats can agents generate models from?+
The skill teaches agents to handle OpenAPI 3, AsyncAPI, JSON Schema, GraphQL, Apache Avro, Protocol Buffers, XML Schema, MCP tool schemas, raw JSON/YAML/CSV data, and existing Python types (Pydantic, dataclass, TypedDict) via the --input-model option.
How do I install datamodel-code-generator?+
Open the source repository on GitHub and follow its README. datamodel-code-generator is a skill — MCP Agents Market links you directly to the official repo.
Is datamodel-code-generator free?+
datamodel-code-generator is an open-source project hosted on GitHub. Check the repository for its license and any usage requirements.