What problem does it solve?
Positional tuples and dict[str, Any] payloads let same-typed values be swapped silently, causing runtime bugs that typecheckers miss. This Skill provides PostHog's house rules for replacing them with named, frozen dataclasses so swaps become typecheck failures.
Core Features & Use Cases
- Decorator selection: Guides use of @frozen from posthog.dataclasses (frozen=True, kw_only=True, slots=True defaults) and when to override each flag.
- Design rules: Covers naming, post_init invariant enforcement, Literal/enum field typing, dataclasses.replace evolution, match/case dispatch, and field(repr=False) for secrets.
- Layering guidance: Explains when functions should accept a dataclass instead of unpacked fields, with carve-outs for Temporal/celery wire signatures and facade contract DTOs.
- Use Case: When refactoring a function that returns (start, end) as a tuple, apply this Skill to convert it into a frozen BillingPeriod dataclass with keyword-only construction and invariant checks.
Quick Start
Ask the AI to review this Python function that returns a tuple of same-typed values and refactor it into a frozen dataclass following PostHog conventions.