compose-multiplatform-patterns

Implements Compose Multiplatform and Jetpack Compose patterns for state, navigation, theming, and performance.

Updated Apr 18, 2026
One-click install
npx skills add https://github.com/JohnRebellion/.claude-public --skill compose-multiplatform-patterns-johnrebellion
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: compose-multiplatform-patterns
Source: https://github.com/JohnRebellion/.claude-public/tree/main/claude/skills/compose-multiplatform-patterns
Command: npx skills add https://github.com/JohnRebellion/.claude-public --skill compose-multiplatform-patterns-johnrebellion

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building shared UI across Android, iOS, Desktop, and Web with Compose Multiplatform involves recurring decisions about state management, navigation, theming, and recomposition performance, and getting these wrong leads to buggy, hard-to-maintain code. ## Core Features & Use Cases - State Management Patterns: Single-state-object ViewModels with StateFlow, lifecycle-aware collection via collectAsStateWithLifecycle, and sealed-interface event sinks for complex screens. - Type-Safe Navigation: Serializable route objects with Compose Navigation 2.8+, including dialog and bottom-sheet destinations. - Composable Design & Performance: Slot-based APIs, correct modifier ordering, @Stable/@Immutable types, keyed lazy lists, and derivedStateOf to minimize recomposition. - Use Case: When building a KMP app screen, apply the ViewModel + single state class pattern with an event sink, wire it to a stateless composable, and navigate using @Serializable routes. ## Quick Start Ask the AI to scaffold a Compose Multiplatform screen with a ViewModel using a single state data class, an event sink, and type-safe navigation to a detail route.

Frequently Asked Questions about compose-multiplatform-patterns

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

FAQPage Schema
How do I manage UI state in Compose Multiplatform ViewModels?▼

Use a single immutable data class for screen state exposed as StateFlow from the ViewModel, and collect it in Compose with collectAsStateWithLifecycle. Update state via MutableStateFlow.update with copy operations rather than mutableStateOf.

How to implement type-safe navigation in Jetpack Compose?▼

Define routes as @Serializable objects or data classes and register them with composable<Route> in a NavHost using Navigation 2.8+. Retrieve arguments with backStackEntry.toRoute<Route>() and navigate by passing route instances to navController.navigate.

Can I share Compose UI between Android and iOS with KMP?▼

Yes, Compose Multiplatform supports shared UI across Android, iOS, Desktop, and Web from commonMain. Platform-specific behavior like status bar handling is implemented with expect/actual composable declarations per source set.

Why does my composable recompose too often?▼

Excessive recomposition usually comes from unstable parameter types, new object instances created in composable parameters, or reading state eagerly. Mark classes @Immutable or @Stable, wrap derived values in derivedStateOf, and hoist computations into remember or the ViewModel.

Should I pass NavController into composables?▼

No, passing NavController deep into composables couples them to navigation and harms previewability and testing. Pass lambda callbacks or a single event sink function instead, and keep navigation calls at the NavHost or screen entry level.