compose-state-authoring

Enforce correct local UI state management in Jetpack Compose code reviews.

908|42|Updated May 12, 2026
One-click install
npx skills add https://github.com/chrisbanes/skills --skill compose-state-authoring-chrisbanes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: compose-state-authoring
Source: https://github.com/chrisbanes/skills/tree/main/skills/compose-state-authoring
Command: npx skills add https://github.com/chrisbanes/skills --skill compose-state-authoring-chrisbanes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Local UI state in Jetpack Compose is easy to mishandle when using bare vars; recomposition can reset values and mutating state must go through remembered state to trigger recompositions. This skill helps ensure memory of state across recompositions and gives guidance on when to use remember { mutableStateOf(...) }, mutableStateListOf/mutableStateMapOf, and @ReadOnlyComposable.

Core Features & Use Cases

  • Ensures state backing with remember and mutableStateOf for local composable state.
  • Guides on choosing mutableStateListOf / mutableStateMapOf for collections and using @ReadOnlyComposable when appropriate.
  • Provides practical patterns for refactoring plain var state to stable, recomposition-friendly state holders.

Quick Start

Identify a composable using a plain local var and refactor it to use remember with backed state or a dedicated state holder.

Frequently Asked Questions about compose-state-authoring

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

FAQPage Schema
Why does my Jetpack Compose state reset on recomposition?

Jetpack Compose state resets on recomposition when using bare local vars instead of remembered state holders. Wrapping your state with remember and mutableStateOf ensures values persist across recompositions and correctly trigger UI updates.

How do I manage mutable collections in Jetpack Compose?

To manage mutable collections in Jetpack Compose, use mutableStateListOf and mutableStateMapOf instead of standard Kotlin collections. These specialized state holders ensure that any modifications to the list or map are observed and trigger the necessary recomposition.

When should I use @ReadOnlyComposable in Jetpack Compose?

Use @ReadOnlyComposable in Jetpack Compose when a composable function strictly reads state without modifying it. Applying this annotation enforces a read-only contract and allows the Compose compiler to optimize the function by skipping unnecessary recompositions.

How do I refactor a plain var to state in Jetpack Compose?

Refactor a plain var to state in Jetpack Compose by replacing it with a dedicated state holder. Apply remember alongside mutableStateOf to back the local state, ensuring the mutable value survives recomposition and properly notifies the framework of structural changes.

What is the best way to enforce local state contracts in Compose?

The best way to enforce local state contracts in Compose is to systematically apply state backing rules during code reviews. Ensure mutable state is accessed through proper state holders and verify that read-only composables are correctly annotated with @ReadOnlyComposable.