Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add PostHog/posthog-foss --skill writing-dataclassesgit clone --depth 1 https://github.com/PostHog/posthog-fossWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/posthog/posthog-foss/writing-dataclasses)<a href="https://agentmods.dev/skills/posthog/posthog-foss/writing-dataclasses"><img src="https://agentmods.dev/badge/skills/posthog/posthog-foss/writing-dataclasses/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/posthog/posthog-foss/writing-dataclasses"><img src="https://agentmods.dev/badge/skills/posthog/posthog-foss/writing-dataclasses.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00157 | $0.01648 |
| Opus 5.5 | $0.00063 | $0.00659 |
| Sonnet 5.5 | $0.00031 | $0.00330 |
| Haiku 4.5 | $0.00016 | $0.00165 |
Grade A, and why
writing-dataclasses scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 79 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Writing dataclasses
The point of every rule here is the same: values that share a type get swapped silently, and a positional tuple or a dict[str, Any] lets that happen. A named, frozen dataclass makes the swap a typecheck failure instead of a runtime bug. Everything below follows from that; if a rule doesn't serve it in your case, say so in the PR and skip it.
When a dataclass, when not
- Return or pass a dataclass instead of a tuple when two or more elements share a type (
(start, end),(width, height),(rows, columns)), or when the tuple has roughly 3+ elements and positional access hurts readability. A small tuple of clearly different types ((user, count)) is fine as-is. - Prefer a dataclass over
dict[str, Any]when a fixed set of values crosses a function boundary. A dict key typo fails at runtime; a dataclass field typo fails typecheck. Dicts stay for genuinely dynamic key sets. NamedTupleis not the answer for the swap problem: it still unpacks positionally.
Which decorator
Use @frozen from posthog.dataclasses for internal value and result objects. It is @dataclass with frozen=True, kw_only=True, slots=True as defaults, and every flag is overridable:
from posthog.dataclasses import frozen
@frozen
class BillingPeriod:
start: datetime
end: datetime
@frozen(slots=False) # class uses functools.cached_property
class ParsedQuery: ...
@frozen(frozen=False) # genuinely mutated after construction (a builder, an accumulator)
class RunAccumulator: ...
kw_only=Trueis what actually prevents swaps at construction:BillingPeriod(start=a, end=b), neverBillingPeriod(a, b). Don't override it without a reason.slots=Trueblocksfunctools.cached_propertyand ad-hoc attributes; override withslots=Falserather than dropping@frozen.- A bare
@dataclasswith no explicitfrozen=fails the ratchet inposthog/test/repo_invariants/test_dataclass_defaults.pyand is flagged by the advisoryprefer-frozen-dataclassessemgrep rule.@dataclass(frozen=False)passes; the ratchet asks for a stated choice, not immutability. If you only moved an existing bare@dataclass, regenerate the baseline withpython posthog/test/repo_invariants/test_dataclass_defaults.pyinstead of decorating it. - Don't add
frozen=Falseto a bare@dataclassyou didn't otherwise touch. The ratchet counts per file against a baseline; an unchanged count passes, and the edit is churn in someone else's file. - Facade contracts (
products/<name>/backend/facade/contracts.py) are frozen dataclasses too, usuallypydantic.dataclasses.dataclass(frozen=True)so they validate on construction. See products/architecture.md.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3mo ago First seen · 79 lines · 157 tokens per session scan A bfbbbe1674c8
writing-dataclasses is a skill published in the GitHub repository PostHog/posthog-foss (736 stars, last pushed today), licensed MIT. It adds 157 tokens to every session and 1,648 once invoked, about $0.0006 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
writing-dataclasses compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| writing-dataclassesPostHog/posthog-foss | Skill | 736 | today | MIT | A | 157 | Claude Code, Codex |
| matlabK-Dense-AI/scientific-agent-skills | Skill | 59k | 3d ago | MIT | A | 44 | Claude Code |
| pennylaneK-Dense-AI/scientific-agent-skills | Skill | 59k | 3d ago | MIT | A | 74 | Claude Code |
| holoscan-install-wheelNVIDIA/skills | Skill | 4.3k | today | Apache-2.0 | A | 34 | Claude Code, Codex |
| python-engineering-guidelinesanywhere-labs/Agents-Anywhere | Skill | 3.9k | today | Apache-2.0 | A | 75 | Codex |
| future-self-liteTHU-MAIC/OpenMAIC | Skill | 46k | today | MIT | A | 20 | Claude Code, Codex |
| rocm-kernelshuggingface/kernels | Skill | 803 | today | Apache-2.0 | A | 93 | Claude Code |