data-structures

Define Python data-structure conventions for Pydantic models and dataclasses.

Updated Nov 11, 2025
One-click install
npx skills add https://github.com/libertininick/chain-reaction --skill data-structures
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: data-structures
Source: https://github.com/libertininick/chain-reaction/tree/main/.claude/skills/data-structures
Command: npx skills add https://github.com/libertininick/chain-reaction --skill data-structures

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides Python data-structure conventions to standardize when choosing between Pydantic models, dataclasses, and other data containers, ensuring consistency across the codebase and code reviews.

Core Features & Use Cases

  • Validation-first modeling: Prefer Pydantic BaseModel for external API boundaries and validation.
  • Lightweight internal containers: Use dataclasses for simple internal data containers with optional immutability.
  • Decision guidance: Clear decision flow for when to apply Pydantic vs dataclasses, including examples and best practices.

Quick Start

Adopt the conventions in your code review and project scaffolding. Start by identifying whether a data structure represents external input/output or internal state, then apply the recommended pattern accordingly.

Frequently Asked Questions about data-structures

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

FAQPage Schema
When should I use Pydantic models vs dataclasses in Python?

Choose Pydantic models for external API boundaries requiring validation and serialization, and use dataclasses for lightweight internal state containers. This distinction standardizes Python data structures and ensures type safety across your codebase.

How do I standardize Python data-structure conventions across a codebase?

Standardize Python data structures by applying a decision flow that categorizes data containers as either external input/output or internal state. Use Pydantic for validation-first modeling and dataclasses for simple internal containers to enforce consistency.

Are dataclasses better than Pydantic for internal Python state?

Dataclasses are better for internal Python state when you need lightweight containers with optional immutability and do not require external validation. Pydantic is preferred for API boundaries where data validation and serialization are critical.

Does using Pydantic for all Python data structures impact performance?

Using Pydantic for all data structures introduces validation overhead that may impact performance for simple internal state. Prefer dataclasses for lightweight internal containers to optimize performance while reserving Pydantic for necessary API boundary validation.

How do I apply data-structure conventions during Python code reviews?

Apply data-structure conventions during Python code reviews by checking whether a data container represents external input/output or internal state. Enforce Pydantic for API boundaries and dataclasses for internal containers to maintain consistency.

What is validation-first modeling in Python?

Validation-first modeling in Python prioritizes Pydantic BaseModel for external API boundaries to ensure data integrity. It enforces clear guidelines for validation and serialization before processing, distinguishing external inputs from internal state.