/personal-skills:compose-state-holder-ui-splitfrom personal-skills
Separates state-holder composable (ViewModel, effects, navigation) from UI composable (immutable state + callbacks) in Jetpack Compose. Improves previewability and testability.
Ships in personal-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.
None: SKILL.md is the whole skill.
Separate state-holder wiring from UI rendering. The state-holder composable talks to ViewModels, components, flows, navigation, and side effects. The UI composable takes plain immutable UI state plus callbacks and describes layout.
This keeps screens previewable, testable, and easier to reuse across Android, Desktop, TV, and KMP/CMP targets.
Use this when a Compose screen:
Use a small public state-holder composable:
@Composable
fun ProfileScreen(component: ProfileComponent, modifier: Modifier = Modifier) {
val state by component.state.collectAsStateWithLifecycle()
ProfileScreen(
state = state,
onNameChange = component::onNameChange,
onSaveClick = component::save,
onBackClick = component::back,
modifier = modifier,
)
}
Then put UI in a plain composable that knows nothing about the state holder:
@Composable
fun ProfileScreen(
state: ProfileUiState,
onNameChange: (String) -> Unit,
onSaveClick: () -> Unit,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
ProfileContent(
name = state.name,
isSaving = state.isSaving,
canSave = state.canSave,
onNameChange = onNameChange,
onSaveClick = onSaveClick,
onBackClick = onBackClick,
modifier = modifier,
)
}
Private content functions can break up layout:
@Composable
private fun ProfileContent(
name: String,
isSaving: Boolean,
canSave: Boolean,
onNameChange: (String) -> Unit,
onSaveClick: () -> Unit,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
// Layout only.
}
| Concern | State-holder composable | UI composable |
|---|---|---|
| Collect ViewModel/component state | Yes | No |
| Collect one-shot effects | Yes, or a tiny sibling effect handler | Usually no |
| Hold dependency-injected objects | Yes | No |
| Accept immutable UI state | Usually passes it through | Yes |
| Accept lambdas for user events | Wires them | Calls them |
| Own layout, modifiers, semantics, test tags | No/minimal | Yes |
| Own UI-local state like scroll, focus, text input, animation, interaction | Sometimes seeds it | Yes |
| Preview/screenshot friendly | Not necessarily | Yes |
The "no collection in UI composables" rule is about app/business state and side-effect streams. Plain UI composables can still own UI-local framework state: rememberScrollState, rememberLazyListState, FocusRequester, focus state, animation state, TextFieldState, MutableInteractionSource.collectIsPressedAsState(), and similar behavior that belongs to the rendered widget.
If that UI-local state grows into coordinated behavior with multiple related fields and operations, use compose-state-hoisting to decide whether it should become a plain state holder class remembered in composition.
Pass the smallest useful UI contract:
UiState/State object over many unrelated primitives when the screen has real state.onRetryClick, onItemSelected) over passing a whole component.compose-state-deferred-reads.compose-side-effects covers effect APIs (LaunchedEffect, DisposableEffect, SideEffect), keys, cleanup, and rememberUpdatedState.
Handle effects near the state holder, where the effect source and imperative target are both available:
@Composable
fun ProfileScreen(component: ProfileComponent, snackbarHostState: SnackbarHostState) {
val state by component.state.collectAsStateWithLifecycle()
LaunchedEffect(component) {
component.effects.collect { effect ->
when (effect) {
ProfileEffect.Saved -> snackbarHostState.showSnackbar("Saved")
}
}
}
ProfileScreen(state = state, onSaveClick = component::save)
}
If effect handling grows, extract ProfileEffects(component, snackbarHostState) rather than pushing the component into the UI composable.
| Mistake | Why it hurts | Fix |
|---|---|---|
fun Screen(viewModel: MyViewModel) contains all layout | Hard to preview/test without Android lifecycle and DI | Add a plain UI overload that takes state and callbacks |
Child composables take component | Dependencies leak through the tree | Pass only the state/callbacks that child needs |
| UI composable launches navigation | UI becomes coupled to app routing | Expose onBackClick, onItemClick, etc. |
| UI composable collects app/business flows | Collection lifecycle is hidden in layout | Collect near the state holder and pass values down |
| UI-local state is hoisted into the state holder for no reason | State holder starts owning layout mechanics | Keep scroll/focus/animation/text-field interaction state in the UI composable when it is only UI behavior |
| Every tiny composable gets a state-holder overload | Too much ceremony | Split at screen/section boundaries, not every Row |
Button, Card, or ListItem; those should expose slots and modifiers, not state holders.compose-ui-testing-patterns — testing plain state-driven UI composables without the full app graph.compose-state-hoisting — deciding where UI element state and UI logic should live, including plain state holder classes.kotlin-multiplatform-expect-actual — platform services, native views, and expect/interface boundaries when shared UI meets platform-specific leaves.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
compose, state-holder, ui-split, android-architecture, previewability
npx claudepluginhub w0lzard/wolzard-s-marketplace --plugin personal-skills57 skills in this plugin
/android-data-layerUse when implementing the data layer in Android — Repository pattern, Room local database, offline-first synchronization, and coordinating local and remote sources./android-debuggingUse when debugging Android or KMP issues — supplements superpowers:systematic-debugging with Android-specific techniques covering Logcat, ADB, ANR traces, R8 stack trace decoding, memory leaks, Gradle build failures, and Compose recomposition bugs.
/android-devUse this skill as the baseline for ALL Android and Kotlin Multiplatform (KMP) work — whenever the user mentions Android, Kotlin (in an Android context), KMP, CMP, commonMain, androidMain, iosMain, AndroidManifest, Gradle, build.gradle, Hilt, Dagger, Room, Retrofit, Ktor, ViewModel, LiveData, StateFlow, SharedFlow, Compose, Activity, Fragment, Intent, ADB, Logcat, MVVM, MVI, repository pattern, or any Android SDK / Jetpack / AndroidX API. Always load this skill alongside more specific skills (android-skills:compose, android-skills:kotlin-flows, android-skills:kmp-ktor, android-skills:android-retrofit, etc.) — it provides the architectural baseline, existing-pattern audit, and project-adaptability rules those skills defer to. Casual mentions like "fix this bug in my Android app," "refactor this ViewModel," "my KMP project," or any work inside an Android project directory should trigger this skill./android-gradle-logicUse when setting up or refactoring Android Gradle build logic — convention plugins, composite builds, version catalogs, and shared build configuration across modules./android-retrofitUse when setting up or working with Retrofit in Android — service interface definitions, coroutines integration, OkHttp configuration, Hilt module setup, and error handling in the repository layer./android-source-searchUse when needing to fetch Android source code — AOSP platform internals (@hide APIs, framework classes, system services) or AndroidX/Jetpack library source and samples. Also use when public docs are insufficient to complete a task and implementation details must be read directly from source.2 plugins ship this exact skill · first indexed Jun 4, 2026
Other plugins' skills for the same job