$npx -y skills add skydoves/compose-performance-skills --skill debugging-recompositionsUse this skill to find which Jetpack Compose composables are recomposing and why, using Android Studio Layout Inspector recomposition counts and skip counts, the per-parameter Argument Change Reasons (Changed / Unchanged / Uncertain / Static / Unknown) introduced in Android Studi
| 1 | # Debugging Recompositions — make the invisible visible, then map status to action |
| 2 | |
| 3 | Recomposition is invisible by default. A composable that re-runs sixty times a second to redraw an animation looks identical in source to one that should re-run zero times when its parent ticks. Three layers of instrumentation make it visible: **Layout Inspector** recomposition counts and skip counts (Android Studio, debug build), Layout Inspector **Argument Change Reasons** (Hedgehog and later, per-parameter Changed / Unchanged / Uncertain / Static / Unknown classifications), and runtime **`@TraceRecomposition`** from `compose-stability-analyzer` for release / R8 / real-device measurement. |
| 4 | |
| 5 | This skill is the diagnostic layer. It does not fix recompositions; it tells the developer which composable is recomposing and which parameter is responsible. Once the param is named, the fix lives in a sibling skill — stability for unstable types, strong skipping for lambda capture, or phase deferral for state reads in the wrong phase. |
| 6 | |
| 7 | ## When to use this skill |
| 8 | |
| 9 | - The developer says "this should be skipping but it's not" or "this re-runs every time the parent ticks". |
| 10 | - The developer wants to count recompositions of a specific composable to confirm a fix worked. |
| 11 | - The developer asks what "Uncertain", "Unknown", "Static", or "Unchanged" means in the Layout Inspector recomposition reasons panel. |
| 12 | - A PR claims a stability or strong-skipping fix; the reviewer needs to confirm the recomposition actually went away in release. |
| 13 | - The user mentions "recomposition count", "Layout Inspector", "Argument Change Reasons", "Hedgehog", "@TraceRecomposition", or "why is this recomposing". |
| 14 | |
| 15 | ## When NOT to use this skill |
| 16 | |
| 17 | - The composable is recomposing because of an unstable type — once this skill names the offender, the actual fix is in `../../stability/diagnosing-compose-stability/SKILL.md` and `../../stability/stabilizing-compose-types/SKILL.md`. |
| 18 | - The composable is recomposing because of a lambda capture or non-skippable scope — fix work lives in `../using-strong-skipping-correctly/SKILL.md`. |
| 19 | - The composable is recomposing because a state read happened in the wrong phase (Composition vs Layout vs Draw) — fix work lives in `../deferring-state-reads/SKILL.md`. |
| 20 | - The team needs a CI gate against future regressions — use `../../stability/enforcing-stability-in-ci/SKILL.md`. |
| 21 | |
| 22 | ## Prerequisites |
| 23 | |
| 24 | - Android Studio **Hedgehog (2023.1.1)** or later for Argument Change Reasons. Earlier Studio versions have recomposition counts but not the per-parameter reason panel. |
| 25 | - A **debug** build for Layout Inspector (Layout Inspector requires debug). Read counts as **directional** signal only; debug builds run interpreted with Live Literals which inflate recomposition counts. |
| 26 | - `androidx.lifecycle:lifecycle-runtime-compose` available so `collectAsStateWithLifecycle` can replace plain `collectAsState` when a flow turns out to be the offender. |
| 27 | - For release-mode confirmation: the runtime tracing setup from `../../measurement/tracing-recompositions-at-runtime/SKILL.md` (the `compose-stability-analyzer` runtime + `ComposeStabilityAnalyzer.setEnabled(true)` in `Application.onCreate`). |
| 28 | - Familiarity with the Compose Compiler reports format (see `../../stability/diagnosing-compose-stability/SKILL.md`) — Layout Inspector classifications mirror the same stability vocabulary. |
| 29 | |
| 30 | ## Workflow |
| 31 | |
| 32 | ### 1. Enable recomposition counts in Layout Inspector |
| 33 | |
| 34 | Run the app on a connected device or emulator in **debug**. Open Android Studio → **Tools** → **Layout Inspector**. In the Layout Inspector toolbar, toggle: |
| 35 | |
| 36 | - **Show recomposition counts** — adds a "Recompositions" column to the component tree and overlays a count badge on the rendered tree. |
| 37 | - **Show recomposition skip counts** — adds a sibling column showing how many times the composable's skip guard fired (i.e. it was invoked |