coroutines

Standardize Kotlin Coroutines patterns for Android ViewModels and UI state.

127|8|Updated Apr 6, 2026
One-click install
npx skills add https://github.com/hanamizuki/solopreneur --skill coroutines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: coroutines
Source: https://github.com/hanamizuki/solopreneur/tree/main/plugins/android-dev/skills/coroutines
Command: npx skills add https://github.com/hanamizuki/solopreneur --skill coroutines

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides authoritative rules and patterns for writing production-grade Kotlin Coroutines code on Android, addressing structured concurrency, lifecycle safety, and reactive streams to prevent leaks and race conditions.

Core Features & Use Cases

  • Structured concurrency guidance: avoid blocking the UI thread, manage job lifecycles, and improve testability.
  • Lifecycle integration: safe coroutine usage with viewModelScope, lifecycleScope, and repeatOnLifecycle.
  • Flow-based state management: using StateFlow/SharedFlow, proper cancellation, and robust error handling.

Quick Start

Create a simple ViewModel that uses viewModelScope to fetch data from a repository with suspend functions and exposes results via StateFlow.

Frequently Asked Questions about coroutines

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent memory leaks when using Kotlin coroutines on Android?

Prevent Android coroutine memory leaks by applying structured concurrency patterns, managing job lifecycles with viewModelScope or lifecycleScope, and using repeatOnLifecycle for safe Flow collection.

What is the best way to manage UI state with Kotlin coroutines and Flow?

Manage Kotlin coroutine UI state by exposing data through StateFlow or SharedFlow, ensuring robust error handling and proper cancellation to prevent race conditions in reactive streams.

How do I make Android coroutines testable?

Make Android coroutines testable by injecting dispatchers into your ViewModels and repositories, allowing you to control execution environments during unit testing.

Does this Kotlin coroutines pattern work for Android repository layers?

Yes, these Kotlin coroutine patterns support building Android repository layers by providing standardized suspend functions and structured concurrency rules for data fetching.

Why should I use structured concurrency in Android coroutines?

Use structured concurrency in Android coroutines to enforce job lifecycles, avoid blocking the UI thread, and guarantee that asynchronous tasks are properly cancelled when their scope ends.