Choose the right general-purpose Python construct for structured data and contracts. Use this when drafting or reviewing whether code should use Enum, dataclass, ABC, or Protocol.
Choose one Python modeling construct for the job without drifting into framework or architecture policy.
Use this skill when:
Enum, dataclass, ABC, and ProtocolDo not use this skill when:
if/elif, match/case, or other control-flow styleEnum for closed symbolic values and named states.dataclass for structured in-memory data; prefer frozen=True unless mutation is intentional.ABC for explicit nominal contracts or shared base behavior; choose Protocol for structural compatibility.examples.md.Enum for named states, @dataclass(frozen=True) for immutable structured data, and Protocol only when unrelated classes just need the same callable shape.ABC before there is any contract pressure, use dataclass for a behavior-heavy service object, or turn a plain boolean flag into Enum without a semantic reason.examples.md: construct-based examples, anti-patterns, edge notes, and split signals