kotlin-concurrency-expert

Reviews Kotlin Coroutines usage in Android projects for lifecycle safety and structured concurrency.

349|154|Updated Feb 18, 2021
One-click install
npx skills add https://github.com/livekit/client-sdk-android --skill kotlin-concurrency-expert-livekit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-concurrency-expert
Source: https://github.com/livekit/client-sdk-android/tree/main/.agent/skills/kotlin-concurrency-expert
Command: npx skills add https://github.com/livekit/client-sdk-android --skill kotlin-concurrency-expert-livekit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Kotlin Coroutines misuse in Android apps leads to lifecycle leaks, race conditions, and UI jank. This Skill provides guidance to review and remediate coroutine usage to ensure structured concurrency and safe cancellation.

Core Features & Use Cases

  • Structured concurrency enforcement: ensures proper scopes and cancellation.
  • Lifecycle-safe patterns: promotes viewModelScope and lifecycleScope usage.
  • Thread-safety improvements: reduces race conditions and deadlocks across components.
  • Real-world scenarios: fixes ANRs, memory leaks, and improper dispatcher usage in Android apps.

Quick Start

Ask the Kotlin Concurrency Expert to review your Android project's coroutine usage and propose minimal, lifecycle-safe fixes.

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 Kotlin coroutines memory leaks in Android ViewModel?

Fix Kotlin coroutines memory leaks by enforcing structured concurrency and using lifecycle-aware scopes like viewModelScope, which automatically cancel background work when the ViewModel is cleared.

What is structured concurrency in Kotlin Android development?

Structured concurrency in Kotlin Android ensures coroutines are launched in proper scopes, enforcing hierarchical cancellation and preventing orphaned background tasks from causing race conditions or lifecycle leaks.

How do I audit Android coroutine dispatchers for thread safety?

Audit Android coroutine dispatchers by reviewing background work to ensure safe dispatching and testable usage, remediating improper dispatcher assignments that cause UI jank or race conditions across components.

Why do mis-scoped coroutines cause ANRs in Android apps?

Mis-scoped coroutines cause ANRs by running background work outside lifecycle-aware scopes, leading to blocked threads and memory leaks that freeze the UI and bypass structured concurrency cancellation.

Can I use lifecycleScope for background work in Android?

Use lifecycleScope for Android background work tied directly to UI lifecycles, ensuring proper cancellation when the lifecycle owner is destroyed, while viewModelScope handles ViewModel-specific concurrent tasks.