Compose Best Practices Check
Perform a detailed check of Jetpack Compose code based on official best practices.
Checklist
1. State Management
- • State hoisting: Are Composables stateless (state passed from callers)?
- • Is
rememberused to cache expensive computations? - • Is
rememberSaveableused for state that must survive configuration changes? - • Is
derivedStateOfused to compute derived state efficiently? - • Is ViewModel state collected with
collectAsStateWithLifecycle()? - • Is UI State defined as an immutable
data class?
2. Recomposition Efficiency
- • No backwards writes: No state mutation during composition
- • Stable types:
@Stable/@Immutableannotations where needed - • Lambda stability: Event handler lambdas not recreated on every recomposition
- • Lazy layout keys:
items(key = { ... })provides stable unique keys - • Deferred state reads: Lambda-based modifiers (
Modifier.drawBehind {}) to defer reads to the draw phase - • No unnecessary recompositions triggered by parameter changes
3. Side Effects
Verify each Side Effect API is used correctly:
| API | Correct Usage |
|---|---|
LaunchedEffect(key) | Launches coroutine on key change. Is the key correct? |
DisposableEffect(key) | Register/unregister resources. Is onDispose cleaning up properly? |
rememberCoroutineScope | Launch coroutines from event handlers |
rememberUpdatedState | Reference latest value in long-lived effects |
SideEffect | Publish Compose state to non-Compose code after every successful recomposition |
produceState | Convert non-Compose state sources into Compose State |
snapshotFlow | Convert Compose State to Flow |
- •Are there any operations outside Composable scope inside side effects?
- •Is
LaunchedEffect(Unit)truly a one-time operation?
4. Navigation
- • Is
NavControllerNOT passed to child Composables (should use callback pattern)? - • Are routes defined as
@Serializabletype-safe classes? - • Is deep link handling correct?
5. Performance
- • No heavy work inside Composition (IO, network, DB)
- • Are
LazyColumn/LazyRowused appropriately for large lists? - • Is image loading optimized (Coil/Glide + caching)?
- • No unnecessary
Modifierchain recreation
6. Accessibility & Testing
- • Is
contentDescriptionset on interactive elements? - • Are
semanticsproperly configured? - • Are
@Previewfunctions provided (multiple state variations)? - • Are
testTagvalues set where needed for testing?
Output Format
code
### [Critical/Warning/Info] file:line-number **Check Item**: Applicable checklist item **Issue**: Specific problem description **Fix**: Code example
End with a Compose quality score (A/B/C/D) and prioritized improvement list.
Target
If $ARGUMENTS is specified, check that file/directory. If not specified, check all Composable files.