kotlin-patterns

Apply idiomatic Kotlin patterns for null-safety, immutability, and sealed hierarchies.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/sakamoto-family-smile/agent_monorepo --skill kotlin-patterns-sakamoto-family-smile
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-patterns
Source: https://github.com/sakamoto-family-smile/agent_monorepo/tree/main/.claude/skills/ecc/kotlin-patterns
Command: npx skills add https://github.com/sakamoto-family-smile/agent_monorepo --skill kotlin-patterns-sakamoto-family-smile

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide provides a structured approach to applying idiomatic Kotlin patterns to improve safety, readability, and maintainability across projects.

Core Features & Use Cases

  • Null-safety emphasis with proper type usage and safe-call patterns to minimize runtime NPEs.
  • Immutability by default through data classes and copy() to simplify state management.
  • Sealed classes and interfaces for exhaustive type hierarchies and safer when expressions.
  • Structured concurrency with coroutines and Flow to enable reliable asynchronous workflows.
  • Extension functions and DSL builders to create expressive, readable APIs.
  • Gradle Kotlin DSL usage to configure builds with type-safety and clarity.

Quick Start

Refactor a Kotlin module to adopt null-safety, data classes, and sealed hierarchies to improve safety and readability.

Frequently Asked Questions about kotlin-patterns

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

FAQPage Schema
How do I write idiomatic Kotlin code to prevent runtime null pointer exceptions?

Idiomatic Kotlin prevents null pointer exceptions by enforcing null-safety through proper type usage and safe-call patterns, minimizing runtime NPEs and making your codebase more robust.

What is the best way to manage state in Kotlin using data classes and sealed hierarchies?

The best way to manage state in Kotlin is by using data classes for immutability by default and sealed classes for exhaustive type hierarchies, which simplifies state management and enables safer when expressions.

How do I structure asynchronous workflows in Kotlin with coroutines and Flow?

You structure asynchronous workflows in Kotlin by applying structured concurrency with coroutines and Flow, enabling reliable asynchronous operations and maintaining clear scope management across your modules.

Can I use Kotlin DSL builders to create more readable APIs and Gradle scripts?

Yes, you can use Kotlin DSL builders and extension functions to create expressive, readable APIs, and apply Gradle Kotlin DSL to configure your builds with type-safety and clarity.

How do I refactor an existing Kotlin module to adopt safer patterns?

You refactor an existing Kotlin module by adopting null-safety, replacing standard classes with data classes, and implementing sealed hierarchies to immediately improve safety and readability.

When should I use sealed classes and interfaces in my Kotlin projects?

You should use sealed classes and interfaces in Kotlin when you need exhaustive type hierarchies and safer when expressions, ensuring all possible subtypes are handled at compile-time.