android-performance-profiler
Performance Profiler (Android)
Checklist
Recompositions
- Composables only recompose when state changes
- State properly scoped with
remember - Stable item keys in LazyColumn
- Annotate custom data classes with
@Stableor@Immutable - Defer state reads (wrap in lambdas where possible)
- Avoid backwards writes (never write to a state that was already read higher in the same composable)
Lists
- Use
LazyColumnnotColumn + verticalScrollfor large data - Stable keys via
key()parameter - Lightweight item composables
Memory
- No memory leaks (avoid Activity/View refs)
- Use Coil/Glide for image loading with caching
- Proper lifecycle management
Body Computation
- No heavy work in composable body
- Use
rememberfor expensive calculations - Use
derivedStateOffor derived state
Quick Wins
| Issue | Fix |
|---|---|
| Parent recomposes | Extract stable child composables |
| Expensive body | Use remember or derivedStateOf |
| Unstable IDs | Use stable keys in LazyColumn |
| Memory leak | Avoid storing Activity/View references |
| Broad recomposition | Narrow state scope |
| Unstable custom types causing broad recompositions | Add @Stable/@Immutable |
| Backwards write or immediate state read | Defer with lambda or derivedStateOf |
Debug
Use Layout Inspector → Recomposition Counts to visualize recompositions
Use Compose Compiler Metrics report (stability analysis)
Enable Composition Tracing in Layout Inspector
Severity
- 🔴 Critical: Visible lag, leaks
- 🟡 Moderate: Noticeable impact
- 🟢 Minor: Optimization opportunity
More from desquared/agents-rules-skills
shared-bug-investigation
Scientific method expert for systematic bug investigation and root cause analysis. Use when users report bugs, crashes, unexpected behavior, or debugging requests. Applies hypothesis-driven investigation, controlled experiments, and rigorous validation across any programming language or platform.
23ios-swiftui-architecture-review
Analyze SwiftUI view hierarchies and suggest MVVM or other architectural improvements. Use when **reviewing existing SwiftUI code**, creating new SwiftUI components, analyzing view structure, or when the user asks about SwiftUI architecture patterns. Best for code review and refactoring guidance.
13android-compose-architecture-review
Analyze Jetpack Compose UI hierarchies and suggest MVVM/MVI or other architectural improvements. Use when reviewing existing Compose code, creating new Compose components, analyzing composable structure, or when the user asks about Compose architecture patterns. Best for code review and refactoring guidance.
13android-accessibility-validator
Checks and suggests accessibility improvements for Jetpack Compose and Android Views including TalkBack labels, dynamic text support, and color contrast. Use when creating or modifying UI components, screens, or when the user asks about accessibility.
12android-kotlin-api-design-reviewer
Review function and class interfaces for Kotlin Coding Conventions compliance. Use when creating public APIs, reusable components, library interfaces, or when the user asks for API design review or Kotlin naming conventions.
11flutter-performance-optimizer
Use when Flutter UI has jank, slow scrolling, excessive rebuilds, or memory leaks. Also use when optimizing lists, animations, or complex widget trees, or when the user asks about Flutter rendering performance.
10