SKILL Instructions
claude
cursor
chatgpt
#android
#kotlin
#coroutines
#flow
About
Guidance for writing safe, cancellable async code on Android with Kotlin coroutines and Flow. Covers scopes, dispatchers, exception handling, and lifecycle awareness.
Metadata (SKILL.md frontmatter)
- name
- android-kotlin-coroutines
- version
- 1.0.0
Instructions
Kotlin Coroutines on Android
- Use
viewModelScopein ViewModels,lifecycleScopein Activities/Fragments. - Never use
GlobalScope. - Switch dispatchers with
withContext(Dispatchers.IO)for IO; keep UI onMain. - Expose data with
StateFlow/SharedFlow, notLiveData, in new code. - Collect flows with
repeatOnLifecycle(Lifecycle.State.STARTED).