kotlin-patterns
Idiomatic Kotlin patterns, best practices, and conventions for building robust, efficient, and maintainable Kotlin applications with coroutines, null safety, and DSL builders.
npx skills add mturac/everything-openai-codex --skill kotlin-patterns --agent codex
Same command for any agent — swap --agent for claude-code, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
It instructs the agent to enforce idiomatic Kotlin conventions across seven key areas: null safety, immutability by default, expression bodies, data classes for value objects, sealed classes and interfaces, scope functions usage, extension functions, coroutines (structured concurrency and Flow), delegation, DSL builders (type-safe builders and configuration DSL), sequences for lazy evaluation, Gradle Kotlin DSL usage, and error handling patterns. It provides concrete Kotlin examples and anti-pattern notes to guide writing robust, maintainable Kotlin code.
How it works
The skill outlines core patterns and practices: use Kotlin's nullability and Elvis for safety; prefer val and immutable collections; favor single-expression functions; use data classes and value classes for value objects; model exhaustive hierarchies with sealed classes and sealed interfaces; apply appropriate scope functions (let, apply, also, run, with) and show common pitfalls; create and apply extension functions without polluting the namespace; utilize coroutines with structured concurrency (coroutineScope, supervisorScope) and Flow with proper error handling; leverage delegation for properties and interfaces; build DSLs using @DslMarker and lambda receivers; implement type-safe DSLs for server/configuration; use sequences for large/infinitely generated data; configure Gradle via Kotlin DSL; and adopt robust error handling patterns using Kotlin Result or sealed classes. Concrete code snippets demonstrate each concept.
When to use it
- Writing new Kotlin code
- Reviewing Kotlin code
- Refactoring existing Kotlin code
- Designing Kotlin modules or libraries
- Configuring Gradle Kotlin DSL builds
What it can touch
- Code authored with Kotlin language constructs as shown in examples (no external tools specified in this section).
Caveats
- License: MIT
- Declared tools: codex, copilot, cursor
- Sections are presented only where explicit content exists in the skill; no speculative or missing sections are added.
# Kotlin Development Patterns Idiomatic Kotlin patterns and best practices for building robust, efficient, and maintainable applications. ## When to Use - Writing new Kotlin code - Reviewing Kotlin code - Refactoring existing Kotlin code - Designing Kotlin modules or libraries - Configuring Gradle Kotlin DSL builds ## How It Works This skill enforces idiomatic Kotlin conventions across seven key areas: null safety using the type system and safe-call operators, immutability via `val` and `copy()` on data classes, sealed classes and interfaces for exhaustive type hierarchies, structured concurrency with coroutines and `Flow`, extension functions for adding behaviour without inheritance, type-safe DSL builders using `@DslMarker` and lambda receivers, and Gradle Kotlin DSL for build configuration. ## Examples **Null safety with Elvis operator:** ```kotlin fun getUserEmail(userId: String): String { val user = userRepository.findById(userId) return user?.email ?: "unknown@example.com" } ``` **Sealed class for exhaustive results:** ```kotlin sealed class Result<out T> { data class Success<T>(val data: T) : Result<T>() data class Failure(val error: AppError) : Result<Nothing>() data object
- When to Use
- How It Works
- Examples
- Core Principles
- 1. Null Safety
- 2. Immutability by Default
- 3. Expression Bodies and Single-Expression Functions
- 4. Data Classes for Value Objects
- Sealed Classes and Interfaces
- Modeling Restricted Hierarchies
- Sealed Interfaces for API Responses
- Scope Functions
- When to Use Each
- Anti-Patterns
What does the kotlin-patterns skill do?
Idiomatic Kotlin patterns, best practices, and conventions for building robust, efficient, and maintainable Kotlin applications with coroutines, null safety, and DSL builders.
How do I install it?
Run `npx skills add mturac/everything-openai-codex --skill kotlin-patterns --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From mturac/everything-openai-codex, a repository with 84 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
