home / skills / hoangnguyen0403 / agent-skills-standard / compose
This skill helps you implement high-performance Jetpack Compose UI with proper state hoisting, theming, and lifecycle-safe patterns for fluid apps.
npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill composeReview the files below or copy the command above to add this skill to your agents.
---
name: Android Jetpack Compose
description: Standards for high-performance Declarative UI and State Hoisting.
metadata:
labels: [android, compose, ui]
triggers:
files: ['**/*.kt']
keywords: ['@Composable', 'Modifier', 'Column', 'Row']
---
# Jetpack Compose Expert
## **Priority: P0 (CRITICAL)**
**You are an Android UI Performance Expert.** Prioritize frame stability and state management.
## Implementation Guidelines
- **State Hoisting**: `Screen` (Stateful) -> `Content` (Stateless).
- **Events**: Pass lambdas down (`onItemClick: (Id) -> Unit`).
- **Dependencies**: NEVER pass ViewModel to stateless composables.
- **Theming**: Use `MaterialTheme.colorScheme`, no hardcoded hex.
## Performance Checklist (Mandatory)
- [ ] **Recomposition**: Are params `@Stable` or `@Immutable`?
- [ ] **Lists**: Is `key` used in `LazyColumn` items?
- [ ] **Modifiers**: Are they reused or static where possible?
- [ ] **Side Effects**: `LaunchedEffect` used correctly? (No limits).
- [ ] **Derived State**: `derivedStateOf` for frequent updates?
## Anti-Patterns
- **No Side Effects**: Use `LaunchedEffect`, not composition body.
- **No VM Deep Pass**: Hoist state; pass only data/callbacks.
- **No Heavy Comp**: Move complex calc to ViewModel or `remember`.
## References
- [Optimization Patterns](references/implementation.md)
This skill captures standards and best practices for building high-performance UIs with Android Jetpack Compose. It focuses on frame stability, correct state hoisting, and avoiding common performance anti-patterns. The guidance helps agents produce composables that are efficient, testable, and maintainable.
The skill inspects component boundaries, state flow, and event propagation to ensure stateful and stateless separation (Screen → Content). It checks that composables receive only data and callbacks rather than ViewModels, verifies use of derivedStateOf and LaunchedEffect for side effects, and enforces theming and modifier reuse. It also validates performance checklist items like stable/immutable params, Lazy list keys, and reused modifiers.
Why must ViewModels not be passed into stateless composables?
Passing ViewModels couples UI implementation to lifecycle-aware components and encourages pulling logic into composition. Pass plain data and callbacks so composables remain reusable and testable.
When should I use derivedStateOf?
Use derivedStateOf for expensive or frequently updated derived values so they only recompute when their inputs change, reducing unnecessary recompositions.