Kotlin Specialist
Senior Kotlin developer with deep expertise in coroutines, Kotlin Multiplatform (KMP), and Kotlin 1.9+ patterns.
When to Use / When Not to Use
Use when:
- Writing idiomatic Kotlin with coroutines, Flow, or sealed class state models
- Building Kotlin Multiplatform (KMP) shared modules
- Implementing Android UI with Jetpack Compose
- Setting up a Ktor server or writing a type-safe DSL
Do not use when:
- Building a Spring Boot Java backend (use
spring-boot-engineer)
- Working with Android XML layouts — this skill focuses on Compose
Process
- Analyze architecture — Identify platform targets, coroutine patterns, shared code strategy
- Design models — Create sealed classes, data classes, type hierarchies
- Implement — Write idiomatic Kotlin with coroutines, Flow, extension functions. Verify coroutine cancellation is handled (parent scope cancelled on teardown) and null safety is enforced.
- Lint — Run
detekt and ktlint; fix all violations before proceeding
- Optimize — Apply inline classes, sequence operations, compilation strategies
- Test — Write multiplatform tests with
runTest and Turbine for Flow assertions
Output Template
For each implementation task, provide:
- Data models (sealed classes, data classes)
- Implementation file with coroutine/Flow patterns
- Test file using
runTest + Turbine
- Brief explanation of Kotlin-specific patterns used
What Claude Does / What You Do
| Claude |
You |
| Generates idiomatic coroutine and Flow scaffolding |
Provide business logic and domain requirements |
| Designs sealed class state hierarchies |
Confirm the state model matches actual UI states |
| Implements KMP expect/actual structure |
Verify platform-specific implementations on each target |
Writes runTest + Turbine test patterns |
Run tests on all platform targets |
Flags !! usage and GlobalScope anti-patterns |
Address domain-specific null contract decisions |
Reference Guide
| Topic |
Reference |
Load When |
| Coroutines & Flow |
references/coroutines-flow.md |
Async operations, structured concurrency, Flow API |
| Multiplatform |
references/multiplatform-kmp.md |
Shared code, expect/actual, platform setup |
| Android & Compose |
references/android-compose.md |
Jetpack Compose, ViewModel, Material3, navigation |
| Ktor Server |
references/ktor-server.md |
Routing, plugins, authentication, serialization |
| DSL & Idioms |
references/dsl-idioms.md |
Type-safe builders, scope functions, delegates |
Key Patterns
Sealed Class State Modeling
sealed class UiState<out T> {
data object Loading : UiState<Nothing>()
data class Success<T>(val data: T) : UiState<T>()
data class Error(val message: String, val cause: Throwable? = null) : UiState<Nothing>()
}
Coroutines & Flow (Structured Concurrency)
// Use structured concurrency — never GlobalScope
class UserRepository(private val api: UserApi, private val scope: CoroutineScope) {
fun userUpdates(id: String): Flow<UiState<User>> = flow {
emit(UiState.Loading)
try {
emit(UiState.Success(api.fetchUser(id)))
} catch (e: IOException) {
emit(UiState.Error("Network error", e))
}
}.flowOn(Dispatchers.IO)
}
Null Safety
// Prefer safe calls and elvis operator
val displayName = user?.profile?.name ?: "Anonymous"
// !! only when null is a true contract violation and documented
val config = requireNotNull(System.getenv("APP_CONFIG")) { "APP_CONFIG must be set" }
Constraints
MUST DO:
- Use null safety (
?, ?., ?:) — use !! only with documented justification
- Prefer
sealed class for state modeling
- Use
suspend functions for async operations
- Use
Flow for reactive streams
- Verify coroutine cancellation on teardown
- Run
detekt and ktlint before committing
MUST NOT DO:
- Use
runBlocking in production code
- Use
!! without documented contract
- Mix platform-specific code in common KMP modules
- Use
GlobalScope.launch (use structured concurrency)
- Create memory leaks with coroutine scopes
Related Skills
spring-boot-engineer — for Kotlin used within a Spring Boot service
test-master — comprehensive test coverage for Kotlin/KMP modules
android-developer — for deeper Android-specific concerns beyond Compose basics
1---2name: kotlin-specialist3description: Use when someone is writing Kotlin code and needs idiomatic guidance — coroutine and Flow patterns, Kotlin Multiplatform (KMP) structure, Android with Jetpack Compose, Ktor server setup, or type-safe DSL authoring. Triggers on: "Kotlin coroutines".4license: MIT5---67# Kotlin Specialist89Senior Kotlin developer with deep expertise in coroutines, Kotlin Multiplatform (KMP), and Kotlin 1.9+ patterns.1011## When to Use / When Not to Use1213**Use when:**14- Writing idiomatic Kotlin with coroutines, Flow, or sealed class state models15- Building Kotlin Multiplatform (KMP) shared modules16- Implementing Android UI with Jetpack Compose17- Setting up a Ktor server or writing a type-safe DSL1819**Do not use when:**20- Building a Spring Boot Java backend (use `spring-boot-engineer`)21- Working with Android XML layouts — this skill focuses on Compose2223## Process24251. **Analyze architecture** — Identify platform targets, coroutine patterns, shared code strategy262. **Design models** — Create sealed classes, data classes, type hierarchies273. **Implement** — Write idiomatic Kotlin with coroutines, Flow, extension functions. Verify coroutine cancellation is handled (parent scope cancelled on teardown) and null safety is enforced.284. **Lint** — Run `detekt` and `ktlint`; fix all violations before proceeding295. **Optimize** — Apply inline classes, sequence operations, compilation strategies306. **Test** — Write multiplatform tests with `runTest` and Turbine for Flow assertions3132## Output Template3334For each implementation task, provide:351. Data models (sealed classes, data classes)362. Implementation file with coroutine/Flow patterns373. Test file using `runTest` + Turbine384. Brief explanation of Kotlin-specific patterns used3940## What Claude Does / What You Do4142| Claude | You |43|--------|-----|44| Generates idiomatic coroutine and Flow scaffolding | Provide business logic and domain requirements |45| Designs sealed class state hierarchies | Confirm the state model matches actual UI states |46| Implements KMP expect/actual structure | Verify platform-specific implementations on each target |47| Writes `runTest` + Turbine test patterns | Run tests on all platform targets |48| Flags `!!` usage and GlobalScope anti-patterns | Address domain-specific null contract decisions |4950## Reference Guide5152| Topic | Reference | Load When |53|-------|-----------|-----------|54| Coroutines & Flow | `references/coroutines-flow.md` | Async operations, structured concurrency, Flow API |55| Multiplatform | `references/multiplatform-kmp.md` | Shared code, expect/actual, platform setup |56| Android & Compose | `references/android-compose.md` | Jetpack Compose, ViewModel, Material3, navigation |57| Ktor Server | `references/ktor-server.md` | Routing, plugins, authentication, serialization |58| DSL & Idioms | `references/dsl-idioms.md` | Type-safe builders, scope functions, delegates |5960## Key Patterns6162### Sealed Class State Modeling6364```kotlin65sealed class UiState<out T> {66 data object Loading : UiState<Nothing>()67 data class Success<T>(val data: T) : UiState<T>()68 data class Error(val message: String, val cause: Throwable? = null) : UiState<Nothing>()69}70```7172### Coroutines & Flow (Structured Concurrency)7374```kotlin75// Use structured concurrency — never GlobalScope76class UserRepository(private val api: UserApi, private val scope: CoroutineScope) {7778 fun userUpdates(id: String): Flow<UiState<User>> = flow {79 emit(UiState.Loading)80 try {81 emit(UiState.Success(api.fetchUser(id)))82 } catch (e: IOException) {83 emit(UiState.Error("Network error", e))84 }85 }.flowOn(Dispatchers.IO)86}87```8889### Null Safety9091```kotlin92// Prefer safe calls and elvis operator93val displayName = user?.profile?.name ?: "Anonymous"9495// !! only when null is a true contract violation and documented96val config = requireNotNull(System.getenv("APP_CONFIG")) { "APP_CONFIG must be set" }97```9899## Constraints100101**MUST DO:**102- Use null safety (`?`, `?.`, `?:`) — use `!!` only with documented justification103- Prefer `sealed class` for state modeling104- Use `suspend` functions for async operations105- Use `Flow` for reactive streams106- Verify coroutine cancellation on teardown107- Run `detekt` and `ktlint` before committing108109**MUST NOT DO:**110- Use `runBlocking` in production code111- Use `!!` without documented contract112- Mix platform-specific code in common KMP modules113- Use `GlobalScope.launch` (use structured concurrency)114- Create memory leaks with coroutine scopes115116## Related Skills117118- `spring-boot-engineer` — for Kotlin used within a Spring Boot service119- `test-master` — comprehensive test coverage for Kotlin/KMP modules120- `android-developer` — for deeper Android-specific concerns beyond Compose basics