add-dto

Generate Kotlin serializable data classes from JSON strings.

1|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/mattbobambrose/mattbobambrose-claude-skills --skill add-dto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-dto
Source: https://github.com/mattbobambrose/mattbobambrose-claude-skills/tree/main/plugins/kotlin-tools/skills/add-dto
Command: npx skills add https://github.com/mattbobambrose/mattbobambrose-claude-skills --skill add-dto

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill removes the manual, error-prone work of writing Kotlin DTO classes by generating kotlinx.serialization-compatible data classes directly from a JSON string, ensuring correct package placement, types, and naming conventions.

Core Features & Use Cases

  • Parse a provided JSON string and infer Kotlin types: String, Int/Long, Double, Boolean, List<T>, and nested objects.
  • Emit top-level @Serializable data classes with non-nullable val properties and trailing commas.
  • Add @SerialName annotations for JSON keys with underscores while using camelCase property names.
  • Generate separate top-level classes for nested JSON objects in the same file and prefer Long when integer values exceed Int range.
  • Save the file to src/main/kotlin using the package declared in src/main/kotlin/Main.kt.

Quick Start

Use the add-dto command with a target Kotlin filename followed by the JSON string to generate a serializable data class file in src/main/kotlin.

Frequently Asked Questions about add-dto

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

FAQPage Schema
How do I generate Kotlin data classes from a JSON string?

To generate Kotlin data classes from a JSON string, the Skill parses the JSON, infers types like String, Int, Long, Double, Boolean, and List<T>, and outputs @Serializable data classes with non-nullable val properties.

How does kotlinx serialization handle JSON keys with underscores in Kotlin?

kotlinx serialization handles JSON keys with underscores by applying @SerialName annotations to the properties while maintaining standard camelCase naming conventions for the Kotlin data class fields.

Can I automatically create Kotlin DTOs for nested JSON objects?

Yes, you can create Kotlin DTOs for nested JSON objects. The generation process automatically maps nested JSON objects into separate top-level @Serializable data classes within the same Kotlin file.

What is the best way to convert a large JSON payload into serializable Kotlin code?

The best way to convert a large JSON payload into serializable Kotlin code is using a code generator that automatically infers Long for integers exceeding Int range and enforces non-nullable val properties to prevent null reference errors.

Does generating Kotlin DTOs require a specific project structure?

Generating Kotlin DTOs requires a standard Kotlin project structure. The tool infers the target package by reading src/main/kotlin/Main.kt and automatically writes the generated data classes to the src/main/kotlin directory.

Why are my integer JSON values mapped to Long instead of Int in generated Kotlin DTOs?

Integer JSON values are mapped to Long instead of Int in generated Kotlin DTOs when the integer values exceed the standard Int range, ensuring data integrity and preventing integer overflow during serialization.