affaan-m avatar

Kotlin Patterns

This is a comprehensive reference for writing idiomatic Kotlin that goes beyond basic syntax. It covers the patterns that make Kotlin code actually feel like Kotlin: null safety with Elvis operators instead of force-unwrapping, sealed classes for exhaustive when expressions, structured concurrency with coroutineScope and async/await, and type-safe DSL builders. The examples are practical, showing things like modeling API errors with sealed interfaces and using value classes for zero-overhead type safety. Use this when you want your Kotlin to look like it was written by someone who understands the language's strengths, not just Java with different keywords.

skills.sh installs
5.9K
GitHub stars
300.3K
last updated
Aug 21, 2026

Install

$ npx -y skills add affaan-m/ecc --skill kotlin-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

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:

fun getUserEmail(userId: String): String {
    val user = userRepository.findById(userId)
    return user?.email ?: "unknown@example.com"
}

Sponsors

Details

Repository
github.com/affaan-m/ecc
Categories
Mobile Development, Java & JVM
First seen
Jul 14, 2026

More from affaan-m/ecc

All 263
1affaan-m avatarflutter-dart-code-reviewaffaan-m/eccLibrary-agnostic Flutter/Dart code review checklist covering widget best practices, state management patterns (BLoC, Riverpod, Provider, GetX, MobX, Signals), D5.8Kskills.sh installs
2affaan-m avatarkotlin-testingaffaan-m/eccKotlin testing patterns with Kotest, MockK, coroutine testing, property-based testing, and Kover coverage. Follows TDD methodology with idiomatic Kotlin practic5.7Kskills.sh installs
3affaan-m avatardart-flutter-patternsaffaan-m/eccProduction-ready Dart and Flutter patterns covering null safety, immutable state, async composition, widget architecture, popular state management frameworks (B5.7Kskills.sh installs
4callstack avatarreact-native-testingcallstack/react-native-testing-libraryWrite tests using React Native Testing Library (RNTL) v13 and v14 (`@testing-library/react-native`). Use when writing, reviewing, or fixing React Native compone5.5Kskills.sh installs
5avdlee avatarswift-testing-expertavdlee/swift-testing-agent-skillExpert guidance for Swift Testing: test structure, #expect/#require macros, traits and tags, parameterized tests, test plans, parallel execution, async waiting 5.5Kskills.sh installs
6affaan-m avatarkotlin-ktor-patternsaffaan-m/eccKtor server patterns including routing DSL, plugins, authentication, Koin DI, kotlinx.serialization, WebSockets, and testApplication testing.5.5Kskills.sh installs