compose-state-hoisting

Installation
SKILL.md

Compose State Hoisting

Overview

Apply state hoisting and unidirectional data flow to Compose UIs, choosing the right state owner, lifespan, and saving strategy.

For condensed reference and examples, see references/compose-state-guidance.md.

Workflow

  1. Identify the state and the logic that reads/writes it.
  2. Decide the state owner (lowest common ancestor; or a plain state holder class, or a screen-level state holder like Android ViewModel for complex UI/business logic).
  3. Choose the lifespan API (remember/retain/rememberSaveable/rememberSerializable) based on how long it must survive.
  4. Make UI composables stateless: pass value and event callbacks; state goes down, events go up.
  5. Decide what must be saved and how (rememberSaveable, SavedStateHandle, or platform storage).
  6. Verify that state and callbacks are not duplicated or leaked.

Rules of thumb

  • Hoist state to the lowest common ancestor of all readers/writers.
  • Keep composables stateless: state down, events up.
  • Pick the lifespan API explicitly; default to remember only for ephemeral UI state.
Related skills

More from alexandru/skills

Installs
9
GitHub Stars
39
First Seen
Feb 1, 2026