Skip to content
Skills Library
Programming · Building & coding

kotlin

/kotlin

Expert Kotlin assistance covering coroutines, Flow, null safety, extension functions, sealed classes/interfaces, and Kotlin Multiplatform. Use when developing Android applications, server-side Kotlin services with Ktor/Spring, or sharing cross-platform business logic.

Licence
MIT
Last repository change
01.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
2
Deprecation

No signals detected. Repository changed on 01.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Expert Kotlin assistance covering coroutines, Flow, null safety, extension functions, sealed classes/interfaces, and Kotlin Multiplatform. Use when developing Android applications, server-side Kotlin services with Ktor/Spring, or sharing cross-platform business logic.

Original author description

Expert Kotlin assistance covering coroutines, Flow, null safety, extension functions, sealed classes/interfaces, and Kotlin Multiplatform. Use when developing Android applications, server-side Kotlin services with Ktor/Spring, or sharing cross-platform business logic.

How it works

  1. When to Use
  2. Quick Start
  3. Core Concepts
  4. Common Patterns
  5. Best Practices
  6. Troubleshooting
  7. References
Original SKILL.md headings · 159 lines, 570 words
SKILL.md preview
---
name: kotlin
description: Expert Kotlin assistance covering coroutines, Flow, null safety, extension functions, sealed classes/interfaces, and Kotlin Multiplatform. Use when developing Android applications, server-side Kotlin services with Ktor/Spring, or sharing cross-platform business logic.
---

# Kotlin

Modern Kotlin development with coroutines, null safety, and idiomatic patterns.

## When to Use

- **Modern Android Application Development**: Google's official, primary language for native Android and Jetpack Compose.
- **Server-Side Microservices (Ktor / Spring Boot)**: Writing expressive, concise, null-safe enterprise web backends.
- **Kotlin Multiplatform (KMP)**: Sharing business logic, data models, and networking across Android, iOS, Desktop, and Web.
- **Asynchronous Coroutines & Reactive Flows**: Managing concurrent background tasks and streams without callback hell.

## Quick Start

```kotlin
data class User(
    val id: String,
    val name: String,
    val email: String,
    val createdAt: Instant = Clock.System.now()
)

suspend fun fetchUser(id: String): User? {
    return apiService.getUser(id)
}
```

## Core Concepts

### Kotlin Coroutines & Structured Concurrency

Lightweight cooperative multitasking with automated cancellation propagation:

```kotlin
import kotlinx.coroutines.*

suspend fun fetchUserProfile(userId: String): UserProfile = coroutineScope {
    // Run two network fetches in parallel
    val profileDeferred = async { api.getProfile(userId) }
    val ordersDeferred = async { api.getOrders(userId) }

    val profile = profileDeferred.await()
    val orders = ordersDeferred.await()
    profile.copy(orders = orders)
}
```

### Kotlin Flow (Asynchronous Cold Streams)

Reactive streams with built-in backpressure and transformation operators:

```kotlin
import kotlinx.coroutines.flow.*

fun streamStockPrices(symbol: String): Flow<Double> = flow {
    while (true) {
        emit(api.getCurrentPrice(symbol))
        delay(1000)
    }
}.map { it * 1.05 } // Apply transformation
 .flowOn(Dispatchers.IO)
```

### Extension Functions & Scope Functions

Extends existing classes without inheritance and scopes variable operations:

```kotlin
// Extension function on String
fun String.toSlug(): String = lowercase().replace(" ", "-").replace(Regex("[^a-z0-9-]"), "")

// Scope function (let, apply, run, also)
val user = User().apply {
    name = "Alex"
    role = "Lead"
}
```

## Common Patterns

### Parallel Coroutine Execution

**Problem**: Fetching multiple remote resources concurrently without blocking the main execution thread.

**Solution**:

```kotlin
// Suspend function
suspend fun fetchData(): List<Item> {
    return withContext(Dispatchers.IO) {
        api.fetchItems()
    }
}

// Parallel execution
suspend fun loadDashboard(): Dashboard {
    return coroutineScope {
        val user = async { fetchUser() }
        val orders = async { fetchOrders() }
        Dashboard(user.await(), orders.await())
    }
}

// Flow for streams
fun observeUsers(): Flow<List<User>> = flow {
    while (true) {
        emit(fetchUsers())
        delay(5000)
    }
}.flowOn(Dispatchers.IO)
```

### Extension Functions

**Problem**: Adding domain-specific utility operations to standard or library types without inheritance.

**Solution**:

```kotlin
fun String.isValidEmail(): Boolean {
    return Regex("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}\$").matches(this)
}

fun <T> List<T>.secondOrNull(): T? = getOrNull(1)

inline fun <T> Result<T>.onSuccess(action: (T) -> Unit): Result<T> {
    if (this is Result.Success) action(data)
    return this
}
```

## Best Practices

**Do**:

- Leverage Kotlin Coroutines over Reactive Streams: Replace complex RxJava pipelines with clean coroutines and Flow.
- Use Sealed Interfaces for UI State: Model UI and domain state using `sealed interface` for exhaustive `when` expressions.
- Specify Dispatchers Explicitly: Use `Dispatchers.IO` for disk/network I/O, `Dispatchers.Default` for CPU math, and `Dispatchers.Main` for UI.
- Prefer Value Classes (`@JvmInline value class`): Create zero-allocation domain primitives for IDs and units of measure.

**Don't**:

- Use `GlobalScope.launch`: Always use structured concurrency with scoped lifecycles to prevent goroutine/coroutine leaks.
- Use the `!!` force-unwrap operator: Handle nullables cleanly using `?.let { ... }` or Elvis operator `?:`.
- Expose mutable collections: Expose read-only `List<T>` interfaces; keep `MutableList<T>` private inside classes.

## Troubleshooting

| Error                   | Cause                | Solution                  |
| ----------------------- | -------------------- | ------------------------- |
| `NullPointerException`  | Force unwrap on null | Use safe call `?.`        |
| `CancellationException` | Coroutine cancelled  | Handle or propagate       |
| `IllegalStateException` | Invalid state access | Check state before access |

## References

- [Kotlin Official Docs](https://kotlinlang.org/docs/)
- [Android Kotlin Guides](https://developer.android.com/kotlin)

Versions

RepositoryScoreLicence
This page · G1Joshi/Agent-Skills100MIT
claude-dev-suite/claude-dev-suite100MIT
dkbnull/hello-skill96MIT
appwrite/claude-plugin95BSD-3-Clause
clawic/skills90MIT

Database snapshot: 13.11.2026 · package version 9e7a2fd58cb9 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100kotlin-specialist
    Provides idiomatic Kotlin implementation patterns including coroutine concurrency, Flow stream handling, multiplatform architecture, Compose UI construction, Ktor server setup, and type-safe DSL design. Use when building Kotlin applications requiring coroutines, multiplatform…
  • 100kotlin-specialist
    Provides idiomatic Kotlin implementation patterns including coroutine concurrency, Flow stream handling, multiplatform architecture, Compose UI construction, Ktor server setup, and type-safe DSL design. Use when building Kotlin applications requiring coroutines, multiplatform…
  • 100kotlin-expert
    Expert-level Kotlin development, Android, coroutines, and multiplatform. Use when the user mentions Android, coroutines, multiplatform, or JVM, or when the task involves Kotlin Fundamentals, Android Development, Kotlin Multiplatform, or Kotlin Style.
  • 95lang-kotlin
    Use this skill when the user says 'Kotlin', 'coroutines', 'Flow', 'StateFlow', 'suspend function', 'structured concurrency', 'null safety Kotlin', 'data class', 'sealed interface', 'extension function', 'K2 compiler', 'KSP', 'Gradle Kotlin DSL', 'MockK', 'kotlinx.serialization'.…
  • 90agent-kotlin-expert
    Specialist subagent: Kotlin Multiplatform, Compose Multiplatform, coroutines, Ktor, and JVM ecosystem specialist. Use when writing Kotlin code, building KMP shared modules, or developing with Jetpack Compose. Trigger phrases: Kotlin, KMP, Compose Multiplatform, coroutines, Ktor,…
  • 100kotlin-idioms
    Kotlin coding idioms: compile-time null safety, data classes, sealed hierarchies, coroutines and Flow concurrency, and Kotest/MockK testing. Use when developing, refactoring, or reviewing Kotlin backend, Android, or multiplatform code.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.