kotlin-types-value-class

Installation
SKILL.md

Kotlin value class vs data class

Core principle

Prefer @JvmInline value class for single-field types that carry domain meaning. Data classes are for aggregating multiple fields. A value class gives you type safety (you can't mix up UserId and String) without the allocation overhead of a data class.

When to use this skill

  • Writing a new Kotlin type that wraps a single value
  • Reviewing a data class that has only one property
  • Seeing primitive types (String, Long, Int, etc.) used where a domain type would prevent misuse
  • Compose compiler reports showing unstable parameters that could be value classes

Decision flow

Related skills
Installs
91
GitHub Stars
541
First Seen
3 days ago