shared-coroutines

Configure cross-platform coroutine dispatchers, scopes, and flow sharing for Kotlin Multiplatform projects.

61|17|Updated Feb 2, 2026
One-click install
npx skills add https://github.com/ahmed3elshaer/everything-claude-code-mobile --skill shared-coroutines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shared-coroutines
Source: https://github.com/ahmed3elshaer/everything-claude-code-mobile/tree/main/skills/shared-coroutines
Command: npx skills add https://github.com/ahmed3elshaer/everything-claude-code-mobile --skill shared-coroutines

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cross-platform Kotlin Multiplatform projects often duplicate coroutine boilerplate across common and platform modules. This Skill provides a centralized, reusable coroutine configuration to unify dispatchers, scopes, and flow sharing.

Core Features & Use Cases

  • Platform Dispatchers via expect/actual: PlatformDispatchers.main, PlatformDispatchers.io, PlatformDispatchers.default, and PlatformDispatchers.unconfined for consistent control across Android, iOS, and native targets.

  • Shared Coroutine Scopes: ApplicationScope, ViewScope, and useCaseScope to tie lifecycles to app components and business logic, improving testability and lifecycle safety.

  • Flow Sharing & Caching: shareIn and cachedIn utilities to reuse streams across UI layers and caches across scopes.

  • Patterns & Reuse: BaseRepository, BaseUseCase, and FlowUseCase abstractions to reduce boilerplate and standardize async operations.

  • Use Case Scenarios: asynchronous data fetch, background tasks, and lifecycle-aware streams in multiplatform apps.

Quick Start

Install the shared-coroutines module into your Kotlin Multiplatform project, replace direct Dispatcher usage with PlatformDispatchers, initialize ApplicationScope and ViewScope, and adopt the shareIn and cachedIn helpers in your flows.

Frequently Asked Questions about shared-coroutines

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

FAQPage Schema
How do I configure coroutines consistently across Android, iOS, and shared Kotlin Multiplatform code?

Shared-coroutines provides platform dispatchers via expect/actual declarations—PlatformDispatchers.main, .io, .default, and .unconfined—that unify dispatcher access across all targets. Install the module, replace direct Dispatcher usage with PlatformDispatchers, and initialize ApplicationScope and ViewScope to standardize async operations across platforms.

Can I reuse Flow streams and avoid duplicating subscription logic in Kotlin Multiplatform projects?

Yes. Shared-coroutines includes shareIn and cachedIn utilities that cache and share flow emissions across UI layers and scopes, reducing redundant subscriptions. Use these helpers in BaseRepository and FlowUseCase abstractions to centralize stream sharing across common and platform modules.

What's the best way to manage coroutine scope lifecycles tied to app components in multiplatform apps?

Shared-coroutines provides ApplicationScope for app-level tasks, ViewScope for UI lifecycle binding, and useCaseScope for business logic. These scopes improve testability and prevent scope leaks by aligning coroutine lifetime with component lifecycle across Android, iOS, and native targets.

Do I need platform-specific coroutine artifacts for each target when using Kotlin Multiplatform?

Yes. Shared-coroutines requires kotlinx-coroutines-core plus platform-specific artifacts—such as kotlinx-coroutines-android on Android. The Skill's expect/actual pattern abstracts platform differences so you configure once in common code and the runtime selects the correct dispatcher for each target.

How can I reduce boilerplate in data fetching and background tasks across multiplatform modules?

Shared-coroutines provides BaseRepository, BaseUseCase, and FlowUseCase abstractions that standardize async patterns. These base classes encapsulate dispatcher selection, scope management, and flow caching, allowing you to inherit consistent behavior without rewriting coroutine setup per module.

What happens if I don't use platform-aware dispatchers in a Kotlin Multiplatform project?

Without platform dispatchers, you risk incorrect thread affinity—main-thread operations may run off-thread on iOS or Native, causing crashes or UI freezes. Shared-coroutines's PlatformDispatchers ensure each platform routes work to the correct thread pool, preventing concurrency bugs across targets.