kotlin-patterns

Review Kotlin code for idiomatic patterns and null safety.

Updated May 9, 2026
One-click install
npx skills add https://github.com/RambleRainbow/jd --skill kotlin-patterns-ramblerainbow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-patterns
Source: https://github.com/RambleRainbow/jd/tree/main/.claude/skills/kotlin-patterns
Command: npx skills add https://github.com/RambleRainbow/jd --skill kotlin-patterns-ramblerainbow

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves the problem of writing inconsistent, non-idiomatic Kotlin code that is prone to runtime errors, hard to maintain, and fails to leverage Kotlin's built-in safety features like null safety and type-safe builders.

Core Features & Use Cases

  • Idiomatic Kotlin Conventions: Enforces best practices for null safety, immutability, data classes, sealed types, and expression-bodied functions to write clean, bug-resistant code.
  • Concurrency & Reactive Patterns: Provides guidance for structured coroutines, Kotlin Flow, and proper cancellation handling to build reliable asynchronous applications.
  • Build & DSL Configuration: Includes type-safe DSL builder patterns and Gradle Kotlin DSL best practices for modular, maintainable project setups.
  • Use Case: Use this Skill when refactoring a legacy Kotlin codebase to eliminate force-unwrapping of nullable types, replace mutable global state with immutable data structures, and adopt structured concurrency for background tasks.

Quick Start

Request a code review of your existing Kotlin service class to identify non-idiomatic patterns and get step-by-step refactoring suggestions aligned with Kotlin best practices.

Frequently Asked Questions about kotlin-patterns

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

FAQPage Schema
How do I refactor legacy Kotlin code to fix force-unwrapped nullable types?

To refactor legacy Kotlin code, eliminate force-unwrapping of nullable types and replace mutable global state with immutable data structures. This enforces null safety and reduces runtime errors while aligning with idiomatic Kotlin conventions.

What is structured concurrency in Kotlin coroutines and when should I use it?

Structured concurrency in Kotlin coroutines manages asynchronous tasks through strict parent-child lifecycles, ensuring proper cancellation handling. Use it when building reliable asynchronous applications to prevent memory leaks and background task crashes.

How do I write type-safe DSL builders in Kotlin?

Writing type-safe DSL builders in Kotlin involves using extension functions and receiver types to create fluent, restricted configuration syntax. This approach ensures compile-time safety and enables modular, maintainable project setups like Gradle Kotlin DSL scripts.

What are the best practices for using sealed type hierarchies in Kotlin?

Best practices for using sealed type hierarchies in Kotlin include leveraging them for restricted class inheritance and exhaustive when-expressions. This maximizes type system safety and ensures all possible states are handled at compile-time.

Does Gradle Kotlin DSL support idiomatic collection operations for build configuration?

Yes, Gradle Kotlin DSL fully supports idiomatic collection operations alongside type-safe DSL builder patterns. Applying these conventions ensures modular, maintainable build setups while preventing configuration syntax errors at compile-time.

Why does my Kotlin code fail to maintain immutability during state updates?

Kotlin code fails to maintain immutability when relying on mutable global state instead of immutable data structures. Transition to data classes with val properties and functional collection operations to ensure robust state management.