kotlin-concurrency-expert

Triage Kotlin Coroutine usage in Android projects for lifecycle and scope issues.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Kotlin Coroutines issues in Android can cause lifecycle leaks, misused scopes, and unsafe threading. This skill helps detect and remediate coroutine usage to improve reliability and maintainability.

Core Features & Use Cases

  • Structured concurrency improvements: ensure work is properly scoped and cancellable.
  • Lifecycle-safe patterns: replace GlobalScope with lifecycle-bound scopes and lifecycle-aware collectors.
  • Testability and deterministic behavior: inject dispatchers and write tests to validate correctness.

Quick Start

Review the Android project's Coroutine usage and propose a lifecycle-safe, deterministic fix plan.

Frequently Asked Questions about kotlin-concurrency-expert

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

FAQPage Schema
How do I fix GlobalScope usage in Android Kotlin Coroutines?

To enforce structured concurrency in Android Kotlin Coroutines, replace GlobalScope with lifecycle-bound scopes like viewModelScope or lifecycleScope. This ensures work is properly scoped, cancellable, and safe from lifecycle leaks.

How do I test Kotlin Coroutines deterministically in Android?

To test Kotlin Coroutines deterministically in Android, inject dispatchers into your classes instead of hardcoding them. This allows you to override dispatchers in tests, ensuring controlled, reproducible execution and validating concurrency correctness.

What causes lifecycle leaks with Kotlin Coroutines in Android?

Lifecycle leaks with Kotlin Coroutines in Android are caused by improper scopes and unsafe threading. Launching work in GlobalScope or failing to handle cancellation properly keeps background tasks alive past the UI lifecycle, creating memory leaks.

What is the best way to handle cancellation in Kotlin Coroutines?

The best way to handle cancellation in Kotlin Coroutines is to enforce structured concurrency within lifecycle-aware scopes. This ensures automatic cancellation propagation, proper error handling, and state encapsulation across UI and background tasks.

Why do I need to inject dispatchers in Android Kotlin Coroutines?

You need to inject dispatchers in Android Kotlin Coroutines to achieve testability and deterministic behavior. Injecting dispatchers decouples execution from hardcoded threading, allowing you to write tests that validate correctness and safely configure background tasks.