/alexandru-skills:compose-state-hoistingfrom alexandru-skills
Guides state hoisting and unidirectional data flow in Kotlin Compose UIs. Helps choose state ownership, lifespan APIs (remember/retain/rememberSaveable/rememberSerializable), and design stateless composables with event callbacks.
Ships in alexandru-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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.
value and event callbacks; state goes down, events go up.remember only for ephemeral UI state.retain or rememberSaveable and document why.rememberSaveable/SavedStateHandle.remember and retain for the same object.value: T and onValueChange: (T) -> Unit (or more specific event lambdas).CompositionLocal to avoid passing parameters through many layers. Use sparingly; prefer explicit parameter passing when practical.remember: survives recomposition only; same instance. Use for composition-scoped objects and small internal UI state. Do not use for user input that must be preserved.retain: survives recomposition + window/configuration changes (Android: activity recreation), not process death. Use for non-serializable objects (players, caches, flows, lambdas). Do not retain platform-specific lifecycle objects (Android: Activity, View, Fragment, ViewModel, Context, Lifecycle). Do not retain objects that were already created with remember by the caller—retain and remember are mutually exclusive for the same object.rememberSaveable / rememberSerializable: survives recomposition + configuration changes + process death (Android) by saving to the platform's saved state mechanism (Android: Bundle; other platforms may vary). Use for user input or UI state that cannot be reloaded from another source. Restored objects are equal but not the same instance.Remember Keys: Control when state resets by passing keys to remember(key1, key2) { }. State recreates when any key changes. Omit keys only when state should survive all recompositions.
rememberSaveable for UI state hoisted in composables or plain state holders; save only minimal, small data.SavedStateHandle in a ViewModel for UI element state that must survive process death; keep it small and session-scoped (not persistent app data).State<T> before reading in composables.Flow: use collectAsState (platform-agnostic, always collects) or collectAsStateWithLifecycle (Android only, lifecycle-aware, pauses collection when UI is not visible).LiveData (Android): use observeAsState.State<T> via produceState.onRemembered / onRetained, not in constructors or remember/retain lambdas.onForgotten / onRetired; handle onAbandoned for canceled compositions.rememberX() to avoid misuse.State<T> to another remember call—this creates unnecessary nested observability.State or use snapshot state collections (mutableStateListOf, mutableStateMapOf).rememberSaveable/SavedStateHandle (Android); save IDs and rehydrate instead.derivedStateOf, causing unnecessary recompositions.value + callbacks.references/compose-state-guidance.md for decision trees, tables, and code examples.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub alexandru/skills --plugin alexandru-skills18 skills in this plugin
/akka-streamsScala reactive streaming with Akka Streams and Pekko Streams. Use for dataflow and reactive programming patterns, testing stream components, and understanding when NOT to use streams (prefer plain functions for transformations and I/O)./arrow-resourceKotlin + Arrow Resource lifecycle discipline with `Resource`, `ResourceScope`, `resourceScope`, and context parameters. Use for safe acquisition/release of files, streams, DB pools/connections, HTTP clients, background scopes, or multipart parts; preventing resource leaks and use-after-close bugs; designing companion `Resource` builders; using `arrow-autoclose` when only synchronous `AutoCloseable` cleanup is possible; composing resources with typed errors, cancellation, or parallel acquisition./arrow-typed-errorsModels Kotlin logical failures with Arrow's context-parameter Raise DSL and wrappers such as Either, nullable, Option, and Ior. Use when implementing or simplifying typed-error flows, translating error types, replacing verbose Either handling, validating input with accumulation, or selecting an error wrapper./cats-effect-ioHelps agents write and review Scala Cats Effect IO code. Use for suspending side effects and non-determinism in IO or F[_], choosing Sync/Async/Temporal/Concurrent/Clock/Random, handling blocking I/O, testing with TestControl, and composing resources, fibers, races, and structured concurrency safely./cats-effect-resourceHelps agents write and review Scala Cats Effect Resource code. Use for preventing resource leaks and use-after-release bugs, modeling disposable values with Resource, designing Resource-returning factories and constructor-injected services, wrapping Java AutoCloseable values, composing resources, and handling cancellation-safe release./cats-mtl-typed-errorsScala typed errors with Cats MTL Raise/Handle and allow/rescue. Use for designing custom domain error types without EitherT, while keeping Cats Effect and ecosystem composition. Covers Scala 2/3 syntax and IO-only or F[_] usage.Other plugins' skills for the same job