compose-multiplatform-patterns — Compose Multiplatform patterns compose-multiplatform-patterns, everything-claude-code, affaan-m, official, Compose Multiplatform patterns, ai agent skill, ide skills, agent automation, Jetpack Compose state management, KMP navigation implementation, Compose UI optimization, Cross-platform UI development

Verified
v1.0.0
GitHub

About this Skill

Ideal for Cross-Platform Agents requiring advanced UI development capabilities with Compose Multiplatform and Jetpack Compose compose-multiplatform-patterns is a set of design patterns for building shared UI components across Android, iOS, Desktop, and Web using Compose Multiplatform and Jetpack Compose.

Features

State management with ViewModels and Compose state
Navigation implementation in KMP and Android projects
Designing reusable composables and design systems
Optimizing recomposition and rendering performance
Building shared UI across Android, iOS, Desktop, and Web

# Core Topics

affaan-m affaan-m
[91.3k]
[11990]
Updated: 3/21/2026

Quality Score

Top 5%
71
Excellent
Based on code quality & docs
Installation
SYS Universal Install (Auto-Detect)
> npx killer-skills add affaan-m/everything-claude-code/compose-multiplatform-patterns
Supports 19+ Platforms
Cursor
Windsurf
VS Code
Trae
Claude
OpenClaw
+12 more

Agent Capability Analysis

The compose-multiplatform-patterns skill by affaan-m is an open-source official AI agent skill for Claude Code and other IDE workflows, helping agents execute tasks with better context, repeatability, and domain-specific guidance. Optimized for Compose Multiplatform patterns, Jetpack Compose state management, KMP navigation implementation.

Ideal Agent Persona

Ideal for Cross-Platform Agents requiring advanced UI development capabilities with Compose Multiplatform and Jetpack Compose

Core Value

Empowers agents to build shared UI across Android, iOS, Desktop, and Web using Compose Multiplatform patterns, including state management with ViewModels, navigation, theming, and performance optimization, leveraging Jetpack Compose for seamless integration

Capabilities Granted for compose-multiplatform-patterns

Implementing navigation in KMP or Android projects with Compose Multiplatform
Designing reusable composables and design systems for cross-platform compatibility
Optimizing recomposition and rendering performance in Compose UI applications

! Prerequisites & Limits

  • Requires knowledge of Kotlin and Compose Multiplatform
  • Limited to Compose Multiplatform and Jetpack Compose ecosystems
  • Needs understanding of platform-specific UI considerations for Android, iOS, Desktop, and Web
Project
SKILL.md
7.7 KB
.cursorrules
1.2 KB
package.json
240 B
Ready
UTF-8
SKILL.md
Readonly

Compose Multiplatform Patterns

Patterns for building shared UI across Android, iOS, Desktop, and Web using Compose Multiplatform and Jetpack Compose. Covers state management, navigation, theming, and performance.

When to Activate

  • Building Compose UI (Jetpack Compose or Compose Multiplatform)
  • Managing UI state with ViewModels and Compose state
  • Implementing navigation in KMP or Android projects
  • Designing reusable composables and design systems
  • Optimizing recomposition and rendering performance

State Management

ViewModel + Single State Object

Use a single data class for screen state. Expose it as StateFlow and collect in Compose:

kotlin
1data class ItemListState( 2 val items: List<Item> = emptyList(), 3 val isLoading: Boolean = false, 4 val error: String? = null, 5 val searchQuery: String = "" 6) 7 8class ItemListViewModel( 9 private val getItems: GetItemsUseCase 10) : ViewModel() { 11 private val _state = MutableStateFlow(ItemListState()) 12 val state: StateFlow<ItemListState> = _state.asStateFlow() 13 14 fun onSearch(query: String) { 15 _state.update { it.copy(searchQuery = query) } 16 loadItems(query) 17 } 18 19 private fun loadItems(query: String) { 20 viewModelScope.launch { 21 _state.update { it.copy(isLoading = true) } 22 getItems(query).fold( 23 onSuccess = { items -> _state.update { it.copy(items = items, isLoading = false) } }, 24 onFailure = { e -> _state.update { it.copy(error = e.message, isLoading = false) } } 25 ) 26 } 27 } 28}

Collecting State in Compose

kotlin
1@Composable 2fun ItemListScreen(viewModel: ItemListViewModel = koinViewModel()) { 3 val state by viewModel.state.collectAsStateWithLifecycle() 4 5 ItemListContent( 6 state = state, 7 onSearch = viewModel::onSearch 8 ) 9} 10 11@Composable 12private fun ItemListContent( 13 state: ItemListState, 14 onSearch: (String) -> Unit 15) { 16 // Stateless composable — easy to preview and test 17}

Event Sink Pattern

For complex screens, use a sealed interface for events instead of multiple callback lambdas:

kotlin
1sealed interface ItemListEvent { 2 data class Search(val query: String) : ItemListEvent 3 data class Delete(val itemId: String) : ItemListEvent 4 data object Refresh : ItemListEvent 5} 6 7// In ViewModel 8fun onEvent(event: ItemListEvent) { 9 when (event) { 10 is ItemListEvent.Search -> onSearch(event.query) 11 is ItemListEvent.Delete -> deleteItem(event.itemId) 12 is ItemListEvent.Refresh -> loadItems(_state.value.searchQuery) 13 } 14} 15 16// In Composable — single lambda instead of many 17ItemListContent( 18 state = state, 19 onEvent = viewModel::onEvent 20)

Navigation

Type-Safe Navigation (Compose Navigation 2.8+)

Define routes as @Serializable objects:

kotlin
1@Serializable data object HomeRoute 2@Serializable data class DetailRoute(val id: String) 3@Serializable data object SettingsRoute 4 5@Composable 6fun AppNavHost(navController: NavHostController = rememberNavController()) { 7 NavHost(navController, startDestination = HomeRoute) { 8 composable<HomeRoute> { 9 HomeScreen(onNavigateToDetail = { id -> navController.navigate(DetailRoute(id)) }) 10 } 11 composable<DetailRoute> { backStackEntry -> 12 val route = backStackEntry.toRoute<DetailRoute>() 13 DetailScreen(id = route.id) 14 } 15 composable<SettingsRoute> { SettingsScreen() } 16 } 17}

Dialog and Bottom Sheet Navigation

Use dialog() and overlay patterns instead of imperative show/hide:

kotlin
1NavHost(navController, startDestination = HomeRoute) { 2 composable<HomeRoute> { /* ... */ } 3 dialog<ConfirmDeleteRoute> { backStackEntry -> 4 val route = backStackEntry.toRoute<ConfirmDeleteRoute>() 5 ConfirmDeleteDialog( 6 itemId = route.itemId, 7 onConfirm = { navController.popBackStack() }, 8 onDismiss = { navController.popBackStack() } 9 ) 10 } 11}

Composable Design

Slot-Based APIs

Design composables with slot parameters for flexibility:

kotlin
1@Composable 2fun AppCard( 3 modifier: Modifier = Modifier, 4 header: @Composable () -> Unit = {}, 5 content: @Composable ColumnScope.() -> Unit, 6 actions: @Composable RowScope.() -> Unit = {} 7) { 8 Card(modifier = modifier) { 9 Column { 10 header() 11 Column(content = content) 12 Row(horizontalArrangement = Arrangement.End, content = actions) 13 } 14 } 15}

Modifier Ordering

Modifier order matters — apply in this sequence:

kotlin
1Text( 2 text = "Hello", 3 modifier = Modifier 4 .padding(16.dp) // 1. Layout (padding, size) 5 .clip(RoundedCornerShape(8.dp)) // 2. Shape 6 .background(Color.White) // 3. Drawing (background, border) 7 .clickable { } // 4. Interaction 8)

KMP Platform-Specific UI

expect/actual for Platform Composables

kotlin
1// commonMain 2@Composable 3expect fun PlatformStatusBar(darkIcons: Boolean) 4 5// androidMain 6@Composable 7actual fun PlatformStatusBar(darkIcons: Boolean) { 8 val systemUiController = rememberSystemUiController() 9 SideEffect { systemUiController.setStatusBarColor(Color.Transparent, darkIcons) } 10} 11 12// iosMain 13@Composable 14actual fun PlatformStatusBar(darkIcons: Boolean) { 15 // iOS handles this via UIKit interop or Info.plist 16}

Performance

Stable Types for Skippable Recomposition

Mark classes as @Stable or @Immutable when all properties are stable:

kotlin
1@Immutable 2data class ItemUiModel( 3 val id: String, 4 val title: String, 5 val description: String, 6 val progress: Float 7)

Use key() and Lazy Lists Correctly

kotlin
1LazyColumn { 2 items( 3 items = items, 4 key = { it.id } // Stable keys enable item reuse and animations 5 ) { item -> 6 ItemRow(item = item) 7 } 8}

Defer Reads with derivedStateOf

kotlin
1val listState = rememberLazyListState() 2val showScrollToTop by remember { 3 derivedStateOf { listState.firstVisibleItemIndex > 5 } 4}

Avoid Allocations in Recomposition

kotlin
1// BAD — new lambda and list every recomposition 2items.filter { it.isActive }.forEach { ActiveItem(it, onClick = { handle(it) }) } 3 4// GOOD — key each item so callbacks stay attached to the right row 5val activeItems = remember(items) { items.filter { it.isActive } } 6activeItems.forEach { item -> 7 key(item.id) { 8 ActiveItem(item, onClick = { handle(item) }) 9 } 10}

Theming

Material 3 Dynamic Theming

kotlin
1@Composable 2fun AppTheme( 3 darkTheme: Boolean = isSystemInDarkTheme(), 4 dynamicColor: Boolean = true, 5 content: @Composable () -> Unit 6) { 7 val colorScheme = when { 8 dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { 9 if (darkTheme) dynamicDarkColorScheme(LocalContext.current) 10 else dynamicLightColorScheme(LocalContext.current) 11 } 12 darkTheme -> darkColorScheme() 13 else -> lightColorScheme() 14 } 15 16 MaterialTheme(colorScheme = colorScheme, content = content) 17}

Anti-Patterns to Avoid

  • Using mutableStateOf in ViewModels when MutableStateFlow with collectAsStateWithLifecycle is safer for lifecycle
  • Passing NavController deep into composables — pass lambda callbacks instead
  • Heavy computation inside @Composable functions — move to ViewModel or remember {}
  • Using LaunchedEffect(Unit) as a substitute for ViewModel init — it re-runs on configuration change in some setups
  • Creating new object instances in composable parameters — causes unnecessary recomposition

References

See skill: android-clean-architecture for module structure and layering. See skill: kotlin-coroutines-flows for coroutine and Flow patterns.

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is compose-multiplatform-patterns?

Ideal for Cross-Platform Agents requiring advanced UI development capabilities with Compose Multiplatform and Jetpack Compose compose-multiplatform-patterns is a set of design patterns for building shared UI components across Android, iOS, Desktop, and Web using Compose Multiplatform and Jetpack Compose.

How do I install compose-multiplatform-patterns?

Run the command: npx killer-skills add affaan-m/everything-claude-code/compose-multiplatform-patterns. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for compose-multiplatform-patterns?

Key use cases include: Implementing navigation in KMP or Android projects with Compose Multiplatform, Designing reusable composables and design systems for cross-platform compatibility, Optimizing recomposition and rendering performance in Compose UI applications.

Which IDEs are compatible with compose-multiplatform-patterns?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for compose-multiplatform-patterns?

Requires knowledge of Kotlin and Compose Multiplatform. Limited to Compose Multiplatform and Jetpack Compose ecosystems. Needs understanding of platform-specific UI considerations for Android, iOS, Desktop, and Web.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add affaan-m/everything-claude-code/compose-multiplatform-patterns. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use compose-multiplatform-patterns immediately in the current project.

Related Skills

Looking for an alternative to compose-multiplatform-patterns or another official skill for your workflow? Explore these related open-source skills.

View All

flags

Logo of facebook
facebook

flags is a feature flag management tool that enables developers to check flag states, compare channels, and debug issues across different release channels.

244.1k
0
Design

extract-errors

Logo of facebook
facebook

The extract-errors skill is a React tool that extracts error codes and updates them for frontend development.

244.1k
0
Design

fix

Logo of facebook
facebook

fix is a skill that resolves lint errors and formatting issues in JavaScript code using yarn prettier and yarn linc.

244.1k
0
Design

flow

Logo of facebook
facebook

Flow is a type checking system for JavaScript, enabling developers to catch type errors in their React code.

244.1k
0
Design