understanding-stability-inference

Explains Compose compiler's 4-class stability inference algorithm and $stable field.

472|16|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/skydoves/compose-performance-skills --skill understanding-stability-inference
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: understanding-stability-inference
Source: https://github.com/skydoves/compose-performance-skills/tree/main/stability/understanding-stability-inference
Command: npx skills add https://github.com/skydoves/compose-performance-skills --skill understanding-stability-inference

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Explain why the Compose compiler classifies a class or composable parameter as stable, runtime, unknown, or unstable. It covers the 12-phase inference algorithm, the five stability types (Certain, Runtime, Unknown, Parameter, Combined), the bitmask encoding, and how runtime checks via the $stable field work across modules.

Core Features & Use Cases

  • Explain the 12-phase stability inference algorithm and how each phase impacts the verdict.
  • Decode the Known Stable Constructs registry (e.g., ImmutableList, Pair, Lazy) and bitmask semantics.
  • Diagnose cross-module stability with @StabilityInferred and runtime checks, including how to read $stable.
  • Provide guidance on common patterns that trigger Unknown, Runtime, or Combined classifications, and how to communicate results to developers.

Quick Start

Explain why a given type is classified as stable, runtime, unknown, or unstable by the Compose stability inference algorithm.

Frequently Asked Questions about understanding-stability-inference

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

FAQPage Schema
Why does the Compose compiler classify my class as unstable instead of stable?

The Compose compiler classifies a class as unstable when its properties are mutable or when cross-module types lack sufficient stability inference metadata. The 12-phase algorithm evaluates generics, known stable constructs, and recursive structures to determine the final verdict.

How does Compose stability inference handle generics and cross-module types?

Compose stability inference handles generics and cross-module types using runtime checks via the `$stable` field and `@StabilityInferred` annotations. This separate compilation mechanism ensures types from external modules are evaluated correctly during recomposition.

What is the `$stable` field in Jetpack Compose and how does it affect runtime decisions?

The `$stable` field is a bitmask-encoded marker generated by the Compose compiler to communicate stability across modules. It enables runtime stability checks, allowing the compiler to make accurate recomposition decisions for types compiled in separate modules.

How do I diagnose a composable parameter marked as Runtime or Unknown in Compose?

Diagnose a composable parameter marked as Runtime or Unknown by tracing it through the 12-phase stability inference algorithm. Check the Known Stable Constructs registry and decode the bitmask semantics to identify why the type triggered a non-stable classification.

What are the limitations of Compose stability inference for recursive structures and value classes?

Compose stability inference faces limitations with recursive structures and value classes because they trigger edge cases in the 12-phase algorithm. These types often result in Unknown or Combined classifications, requiring manual annotations or runtime checks to resolve.