compose-recomposition-optimizer

Diagnose and fix unnecessary recompositions in Jetpack Compose UIs.

Updated Jan 2, 2024
One-click install
npx skills add https://github.com/Mithrandir21/game-deals-app --skill compose-recomposition-optimizer-mithrandir21
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: compose-recomposition-optimizer
Source: https://github.com/Mithrandir21/game-deals-app/tree/main/.claude/skills/compose-recomposition-optimizer
Command: npx skills add https://github.com/Mithrandir21/game-deals-app --skill compose-recomposition-optimizer-mithrandir21

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Jetpack Compose screens that drop frames, feel janky, or recompose too often are usually caused by a small set of root causes — unstable parameters, captured lambdas, and over-broad state reads. This Skill provides a structured, measurement-first process to find and fix them instead of guessing. ## Core Features & Use Cases - Compiler metrics analysis: Configure Compose compiler metrics and reports, then interpret unstable class and non-skippable composable findings. - Root-cause fixes: Remediate unstable parameter types with @Stable/@Immutable or ImmutableList, stabilize captured lambdas with remember or method references, and defer state reads with lambda parameters. - Ongoing regression prevention: Set up Macrobenchmark frame timing tests, Layout Inspector recomposition counts, and CI compiler metrics tracking. - Use Case: A developer notices a LazyColumn stutters while scrolling. The Skill walks them through confirming the problem with Layout Inspector, generating compiler metrics, adding stable keys to list items, and deferring state reads so only affected items recompose. ## Quick Start Analyze my Compose screen for unnecessary recompositions and tell me which composables have unstable parameters and how to fix them.

Frequently Asked Questions about compose-recomposition-optimizer

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

FAQPage Schema
How do I fix unnecessary recompositions in Jetpack Compose?▼

Fix unnecessary recompositions by making parameter types stable with @Immutable or @Stable annotations, using ImmutableList instead of List, remembering captured lambdas, and deferring state reads with lambda parameters. Measure first with Layout Inspector or compiler metrics before changing code.

How to generate Compose compiler metrics reports?▼

Add metricsDestination and reportsDestination to the composeCompiler block in your module's build.gradle.kts, then run assembleRelease. The output includes classes and composables reports showing which classes are unstable and which composables are not skippable.

Why is my LazyColumn recomposing every item when the list changes?▼

LazyColumn recomposes all items when items lack stable keys. Provide a unique, stable key parameter for each item so Compose can track identity across list changes and skip unchanged items.

Does Strong Skipping Mode fix unstable parameters automatically?▼

Strong Skipping Mode in Kotlin 2.0+ skips composables based on equality even with unstable types, but only when the composable does not capture unstable lambdas. Verify it is enabled in compiler options and still fix genuinely unstable types.

When should I use derivedStateOf in Compose?▼

Use derivedStateOf only when the input state changes more often than the output, such as deriving a boolean from scroll position. For simple one-to-one transforms it adds overhead without reducing recompositions.

When should I not optimize Compose recomposition?▼

Do not optimize without measurement evidence such as frame drops, Layout Inspector recomposition counts, or profiler data. Compose performance intuition is often wrong, and premature optimization wastes effort on screens that already render fine.