android-coroutines

Enforce production-quality Kotlin Coroutines patterns for Android development.

1|Updated Feb 20, 2026
One-click install
npx skills add https://github.com/escorponox/musiharmony --skill android-coroutines-escorponox
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: android-coroutines
Source: https://github.com/escorponox/musiharmony/tree/main/.claude/skills/android-coroutines
Command: npx skills add https://github.com/escorponox/musiharmony --skill android-coroutines-escorponox

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive set of rules and best practices for writing robust, efficient, and maintainable Kotlin Coroutines code specifically for Android development, ensuring structured concurrency and lifecycle safety.

Core Features & Use Cases

  • Structured Concurrency: Enforces proper scope management and cancellation.
  • Lifecycle Integration: Ensures coroutines respect Android component lifecycles.
  • Reactive Streams: Guides the use of Kotlin Flows for asynchronous data streams.
  • Error Handling: Implements robust error handling strategies for coroutines.
  • Use Case: When building an Android app that fetches data from a network API and displays it in a ViewModel, this skill ensures the data fetching is done off the main thread, handles potential errors gracefully, and automatically cancels the operation when the UI is no longer visible.

Quick Start

Use the android-coroutines skill to implement a main-safe suspend function for fetching user data in a repository.

Frequently Asked Questions about android-coroutines

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

FAQPage Schema
How do I ensure Kotlin coroutines respect Android lifecycle and avoid memory leaks?

To prevent memory leaks, enforce structured concurrency by binding Kotlin coroutine scopes to Android lifecycle components like ViewModelScope. This ensures asynchronous operations cancel automatically when the UI is destroyed.

What is the best way to handle errors and exceptions in Android coroutines?

The best way to handle exceptions in Android coroutines is by implementing robust error handling strategies within structured concurrency scopes. This ensures failures during asynchronous tasks are caught gracefully without crashing the app.

How do I collect Kotlin Flows safely in an Android app?

To collect Kotlin Flows safely, use lifecycle-aware collection methods provided by Android lifecycle components. This ensures the reactive data stream suspends or cancels automatically when the UI is not visible.

Why should I avoid using GlobalScope for asynchronous tasks in Android?

You should avoid GlobalScope because it bypasses structured concurrency and Android lifecycle integration. Prohibiting GlobalScope ensures asynchronous tasks are properly scoped, cancellable, and maintain state encapsulation.

How do I convert callbacks to suspend functions for Android network requests?

To convert callbacks to suspend functions, wrap asynchronous callback logic using Kotlin coroutine suspension mechanisms. This creates main-safe operations that execute sequentially without blocking the Android UI thread.