classes-instead-of-dicts

Enforce typed schema contracts using pydantic classes over freeform dicts.

2|Updated Jan 31, 2026
One-click install
npx skills add https://github.com/MRiabov/Problemologist-AI --skill classes-instead-of-dicts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: classes-instead-of-dicts
Source: https://github.com/MRiabov/Problemologist-AI/tree/main/.agents/skills/classes-instead-of-dicts
Command: npx skills add https://github.com/MRiabov/Problemologist-AI --skill classes-instead-of-dicts

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Enforce typed schema contracts by preferring classes (especially pydantic.BaseModel) over freeform dicts to prevent runtime errors and improve validation, testing, and API reliability.

Core Features & Use Cases

  • Prefer explicit typed classes for API contracts, data transfer, and function interfaces.
  • Use pydantic.BaseModel for input/output validation and SQLAlchemy models for persistence.
  • Refactor legacy dict-based contracts into typed models to improve maintainability and scalability.

Quick Start

Refactor a simple payload from a dict to a pydantic model and update API handlers to accept typed inputs.

Frequently Asked Questions about classes-instead-of-dicts

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why should I use pydantic models instead of dicts for API contracts?

Using pydantic models instead of dicts enforces typed schema contracts, preventing runtime errors by validating data at boundaries and improving API reliability, testing, and maintainability.

How do I refactor legacy dict-based payloads into typed data models?

Refactor legacy dict-based payloads by replacing them with pydantic.BaseModel classes for input/output validation and SQLAlchemy models for persistence, updating API handlers to accept typed inputs.

When do I need typed classes for data exchange in Python projects?

Typed classes for data exchange are needed when adding or modifying classes, planning storage logic, or designing API interfaces across Python projects using pydantic and SQLAlchemy to ensure reliable validation.

Does this approach work with both pydantic and SQLAlchemy for persistence?

Yes, this approach works with pydantic and SQLAlchemy by using pydantic.BaseModel for input/output validation and SQLAlchemy models for persistence, ensuring clear separation between transfer objects and persistence schemas.

What is the best way to enforce validation at API boundaries in Python?

The best way to enforce validation at API boundaries is preferring explicit typed classes like pydantic.BaseModel over freeform dicts, ensuring data exchange is validated and API contracts are strictly typed.