compose-architecture

Audit Jetpack Compose screens for MVVM/MVI architecture and performance issues.

1|1|Updated May 23, 2026
One-click install
npx skills add https://github.com/santimattius/performance-compose-skills --skill compose-architecture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: compose-architecture
Source: https://github.com/santimattius/performance-compose-skills/tree/main/skills/compose-architecture
Command: npx skills add https://github.com/santimattius/performance-compose-skills --skill compose-architecture

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It prevents common Jetpack Compose architecture mistakes that trigger excessive recompositions, unstable UI models, and leaky lifecycle behavior when wiring ViewModels to screens.

Core Features & Use Cases

  • Lifecycle-aware state collection: prefer collectAsStateWithLifecycle and avoid collectAsState for production screens, especially in Compose Multiplatform.
  • Stable UiState/UiAction modeling: enforce all-val, stable property types (ImmutableList/@Immutable) and event-as-state patterns instead of one-shot Channels/SharedFlow.
  • Performance-first composition strategy: defer state reads from Composition to Layout/Drawing using lambda-based Modifier patterns, and apply atomic UiState updates with update { }.
  • Clean Screen/Content split: keep Screen as the bridging layer that talks to the ViewModel and navigation, while Content remains stateless, previewable, and testable.

Quick Start

Use the compose-architecture skill to review a feature screen and refactor it to a Screen/Content split with a stable UiState collected via collectAsStateWithLifecycle, optimized so state reads occur as low as possible in the tree.

Frequently Asked Questions about compose-architecture

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

FAQPage Schema
How do I prevent excessive recompositions in Jetpack Compose when wiring ViewModels?

Prevent excessive recompositions in Jetpack Compose by using stable, all-val UiState models with ImmutableList, deferring state reads to Layout/Drawing via lambda-based Modifiers, and applying atomic state updates with update { }.

Why does collectAsState cause lifecycle leaks in Compose Multiplatform?

collectAsState causes lifecycle leaks in Compose Multiplatform because it collects state without lifecycle awareness. You must use collectAsStateWithLifecycle instead to pause collection when the app moves to the background.

What is the best way to structure MVVM screens in Jetpack Compose for testability?

The best way to structure MVVM screens in Jetpack Compose is using a Screen/Content split. The Screen layer bridges the ViewModel and navigation, while the Content composable remains stateless, previewable, and testable.

Should I use Channels or SharedFlow for one-shot events in Compose MVI architecture?

In Compose MVI architecture, you should avoid one-shot Channels or SharedFlow for events. Instead, model events as state using stable UiAction models to ensure UI updates are handled safely during recomposition.

Does this Compose architecture guidance apply to Compose Multiplatform or only Android?

This Compose architecture guidance applies to both Jetpack Compose and Compose Multiplatform. It specifically addresses lifecycle-aware state collection and stable UI modeling practices required for cross-platform production screens.

When should I hoist state in a Compose MVVM feature?

You should hoist state in a Compose MVVM feature to ensure the Content composable remains stateless and previewable. The Screen layer handles ViewModel scoping and state hoisting, reading collected StateFlow as low as possible in the tree.