android-coroutines

Enforce production-quality Kotlin Coroutines patterns for Android asynchronous logic.

Updated Feb 28, 2026
One-click install
npx skills add https://github.com/trancee/noise-protocol --skill android-coroutines-trancee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: android-coroutines
Source: https://github.com/trancee/noise-protocol/tree/main/.github/skills/android-coroutines
Command: npx skills add https://github.com/trancee/noise-protocol --skill android-coroutines-trancee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides authoritative rules and patterns for writing production-quality Kotlin Coroutines code on Android, ensuring robust asynchronous operations and efficient UI updates.

Core Features & Use Cases

  • Structured Concurrency: Enforces safe and manageable coroutine lifecycles.
  • Lifecycle Integration: Seamlessly integrates coroutines with Android's lifecycle components.
  • Reactive Streams: Implements modern reactive patterns using Kotlin Flows.
  • Use Case: Develop a ViewModel that fetches user data from a network API, displays it in a list, and automatically updates the UI when new data is available, all while handling background operations and lifecycle events gracefully.

Quick Start

Use the android-coroutines skill to implement a ViewModel that fetches data from an API using Kotlin Coroutines.

Frequently Asked Questions about android-coroutines

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

FAQPage Schema
How do I handle Android lifecycle events when collecting Kotlin coroutines?

To handle Android lifecycle events with Kotlin coroutines, you must implement lifecycle-aware collection patterns. This ensures asynchronous logic automatically suspends and resumes operations during lifecycle changes, preventing memory leaks and crashes when background tasks outlive their UI components.

Why does using GlobalScope in Android coroutines cause issues?

Using GlobalScope in Android coroutines causes issues because it starts unstructured concurrency detached from any lifecycle. Prohibiting GlobalScope enforces structured concurrency, ensuring cooperative cancellation and preventing orphaned background operations that drain resources and cause memory leaks when the ViewModel is destroyed.

What is the best way to encapsulate state in a ViewModel using Kotlin coroutines?

The best way to encapsulate state in a ViewModel using Kotlin coroutines is applying state encapsulation patterns with reactive streams. By leveraging Kotlin Flows within ViewModel scopes, you achieve structured concurrency, ensuring UI state updates remain thread-safe, lifecycle-aware, and automatically cancelled when the ViewModel clears.

How do I ensure main-safety when converting callbacks to Kotlin coroutines on Android?

To ensure main-safety when converting callbacks to Kotlin coroutines on Android, you must apply dispatcher injection. This pattern routes blocking operations to background dispatchers while keeping UI updates on the main thread, guaranteeing that asynchronous logic never blocks the Android UI and remains responsive.

How do I handle exceptions in reactive streams implemented with Kotlin coroutines?

To handle exceptions in reactive streams implemented with Kotlin coroutines, you must follow structured concurrency exception handling best practices. This involves propagating errors gracefully through Kotlin Flows, ensuring that failures in asynchronous logic are caught and managed within the ViewModel scope without crashing the application.

Does this approach to Kotlin coroutines work without external Android libraries?

Yes, this approach to Kotlin coroutines works without external Android libraries, as it requires no dependencies. It applies production-quality patterns natively using Android's lifecycle components, ViewModel scopes, and Kotlin Flows to achieve structured concurrency and reactive stream implementation independently.