kotlin-types-value-class

Identify when to replace single-field Kotlin wrappers with @JvmInline value classes.

1|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/leogallego/ansible-jane --skill kotlin-types-value-class-leogallego
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-types-value-class
Source: https://github.com/leogallego/ansible-jane/tree/main/skills/kotlin-types-value-class
Command: npx skills add https://github.com/leogallego/ansible-jane --skill kotlin-types-value-class-leogallego

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prefer @JvmInline value classes for single-field domain types to provide compile-time type safety without the allocation overhead of data classes.

Core Features & Use Cases

  • Guidance on when to use value classes vs data classes for domain types.
  • Decision flow to evaluate single-field wrappers, domain meaning, and performance implications.
  • Compose stability and serialization considerations to avoid breaking changes across Kotlin projects.

Quick Start

Identify a single-field Kotlin type and replace its wrapper with an @JvmInline value class to ensure type safety without allocations.

Frequently Asked Questions about kotlin-types-value-class

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use an inline value class instead of a data class in Kotlin?

Value classes are preferred over data classes when wrapping a single field to enforce domain meaning. This approach provides compile-time type safety while ensuring zero allocation overhead at runtime.

How do Kotlin value classes affect Jetpack Compose stability?

Kotlin value classes maintain Compose stability because their underlying primitive values are stable. Using @JvmInline wrappers for domain types ensures they do not trigger unnecessary recompositions.

Does autoboxing apply to @JvmInline value classes?

Autoboxing considerations apply to @JvmInline value classes when used in nullable contexts or generic collections. While generally zero-allocation, boxing occurs to preserve type-safety when wrapped values require object representation.

How do I serialize Kotlin value classes on the JVM?

Kotlin/JVM serialization handles value classes by serializing their underlying wrapped property. You must ensure compatibility with common Kotlin projects by configuring serializers to handle the single-field @JvmInline structure correctly.

What are the limitations of using inline value classes for type-safety?

Limitations of inline value classes include autoboxing in generic collections and potential serialization complexities. You should evaluate single-field wrappers carefully to avoid breaking changes across Kotlin projects.