Skip to content
Back to skills

Keep Value Dataclasses Frozen

ASecurity

When declaring a dataclass that carries values rather than state, make it frozen

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 17, 2026
ai-agents

Security analysis

A100/100

Scanned October 17, 2026

npx -y skills add samugit83/cortex --skill keep-value-dataclasses-frozen --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Keep Value Dataclasses Frozen?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Keep Value Dataclasses Frozen
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/samugit83-keep-value-dataclasses-frozen/badge)](https://www.skillsdirectory.com/skills/samugit83-keep-value-dataclasses-frozen)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: keep-value-dataclasses-frozen
description: When declaring a dataclass that carries values rather than state, make it frozen
---

# Frozen dataclasses

A value object that cannot be mutated can be shared, compared and put in a set
without anyone having to check who else holds a reference.

1. Declare it `@dataclass(frozen=True)`.
2. Add `order=True` only when the natural ordering is obvious from the field
   order; otherwise give it an explicit key function at the call site.
3. Build a changed copy with `dataclasses.replace(value, field=new)` rather
   than reaching in and assigning.

Keep mutable containers out of a frozen dataclass's fields: freezing the object
does not freeze the list inside it, and the guarantee stops being one.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.