kotlin-concurrency-expert

Diagnose and remediate Kotlin Coroutines issues in Android apps.

1|2|Updated Jan 25, 2026
One-click install
npx skills add https://github.com/jhparktime/OnGuard --skill kotlin-concurrency-expert-jhparktime
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-concurrency-expert
Source: https://github.com/jhparktime/OnGuard/tree/main/.claude/skills/kotlin-concurrency-expert
Command: npx skills add https://github.com/jhparktime/OnGuard --skill kotlin-concurrency-expert-jhparktime

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Kotlin Coroutines usage in Android apps often suffers from lifecycle-safety issues, leaks, and improper scope handling, leading to ANRs and unstable apps.

Core Features & Use Cases

  • Triage and diagnose coroutine-related issues (ANR, crashes, race conditions) across Android components and architectures.
  • Apply minimal, safe fixes to enforce structured concurrency, proper scope usage, and correct dispatcher handling with minimal behavioral changes.
  • Provide lifecycle-safe patterns (viewModelScope, lifecycleScope, repeatOnLifecycle) and migration guidance to modern coroutine best practices.

Quick Start

Describe the issue or paste the code snippet, and I will propose coroutine-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 ANR and memory leaks in my Android app?

To fix Kotlin Coroutines ANR and leaks, diagnose improper scope usage and enforce structured concurrency. Apply minimal, safe fixes using lifecycle-aware scopes like viewModelScope to ensure proper cancellation and thread safety across MVVM architectures.

How do I implement lifecycle-safe coroutine collection in Android?

Implement lifecycle-safe coroutine collection using repeatOnLifecycle with lifecycleScope. This prescribed pattern prevents crashes and ensures multi-threaded data flows only emit when the Android lifecycle component is at least started, suspending collection appropriately on stop.

What is structured concurrency in Kotlin and how does it prevent race conditions?

Structured concurrency in Kotlin enforces parent-child coroutine hierarchies to prevent race conditions and leaks. By binding coroutines to specific scopes like lifecycleScope, it guarantees cancellation propagation and safe dispatcher handling across multi-threaded data flows.

Does this approach work with my existing Android MVVM architecture?

Yes, this approach works across Android codebases using MVVM architectures and lifecycle components. It applies minimal behavioral changes to diagnose coroutine issues and provides migration guidance to modern best practices without requiring a full rewrite.

Why are my Kotlin Coroutines causing crashes when the Android activity is destroyed?

Kotlin Coroutines cause crashes on activity destruction due to improper scope usage and lack of lifecycle-aware collection. Remediate this by migrating unsafe scopes to viewModelScope and applying structured concurrency to handle cancellation safely.