compose-state-authoring
Compose state authoring
Not every remember { … } belongs here. This skill covers local UI state (remember { mutableStateOf(…) }, mutableStateListOf / mutableStateMapOf) and @ReadOnlyComposable. Other remembered APIs live in focused skills:
rememberCoroutineScope/rememberUpdatedState→compose-side-effectsrememberLazyListState/rememberScrollStateused for frame-rate reads →compose-state-deferred-reads- Focus navigation, focus state,
FocusRequesterownership, behavior →compose-focus-navigation
Core principle
A @Composable is a function the runtime re-runs whenever its inputs change. Writing local state correctly comes down to two questions:
- Mutable local state — does my
varsurvive recomposition and trigger it? If not, it silently resets on every recompose and writes are invisible. - What kind of composable is this? — do I mutate composition (place layout nodes, allocate slots,
remember) or only read it? If only read,@ReadOnlyComposablelets the runtime skip work.
Get either wrong and the symptoms are subtle: state that vanishes or optimizations that don't apply.
When to use this skill
More from chrisbanes/skills
kotlin-coroutines-structured-concurrency
Use when writing or reviewing Kotlin code that stores CoroutineScope, launches from init/non-suspending APIs, calls runBlocking, or catches broad exceptions around suspend calls.
182compose-side-effects
Use when writing or reviewing Jetpack Compose code with LaunchedEffect, DisposableEffect, SideEffect, rememberCoroutineScope, rememberUpdatedState, snapshotFlow, snackbar, navigation, focus requests, analytics, or event Flow collection.
181compose-modifier-and-layout-style
Use when writing or reviewing Jetpack Compose layout APIs, modifier parameters, modifier chain construction, hardcoded root layout decisions, or layout wrappers around a single conditional.
181compose-ui-testing-patterns
Use when writing or reviewing Jetpack Compose UI tests, screenshot tests, previews, semantics assertions, fake image loading, keyboard input, focus assertions, interaction state (hover/pressed/focused), or tests for plain state-driven UI composables.
181compose-state-deferred-reads
Use when Jetpack Compose code reads scroll, animation, gesture, or other frame-rate State in composition, passes changing values across composable boundaries, or uses value-form layout/draw modifiers.
179kotlin-flow-state-event-modeling
Use when writing or reviewing Kotlin Flow state and event APIs with StateFlow, MutableStateFlow.update, SharedFlow, Channel, stateIn, SharingStarted, .value, receiveAsFlow, one-shot events, or sentinel initial values.
179