kotlin-coroutines-kmp-dispatchers

Installation
SKILL.md

Coroutines and Dispatchers in KMP

Use this skill when implementing or reviewing coroutine concurrency, dispatcher choice, or main-thread safety across KMP targets.

Goals

  • Never block Main with disk/network/CPU-heavy work
  • Correct Dispatchers.Main behavior on Android and Kotlin/Native
  • Testable code via injectable dispatchers
  • Safe delivery of UI state to Compose and SwiftUI

Prefer official defaults

  • Use structured concurrency (coroutineScope, supervisorScope, ViewModel/presenter scope) — no unstructured GlobalScope for app work.
  • Run IO/CPU work on Dispatchers.Default or an injected IO dispatcher; switch to Main only for UI-facing emission.
  • Prefer repository / data APIs that are main-safe (safe to call from Main; they move work internally).
  • Inject CoroutineDispatcher (or a small DispatcherProvider) in types you unit-test.

Docs: https://kotlinlang.org/docs/coroutines-guide.html · https://kotlinlang.org/docs/multiplatform/compose-compatibility-and-versioning.html (lifecycle/coroutines artifacts as applicable)

Installs
1
First Seen
Sep 13, 2026