
compose-performance-audit
Audit and improve Jetpack Compose runtime performance from code review and architecture. Use when asked to diagnose slow rendering, janky scrolling, excessive recompositions, or performance issues in Compose UI.
- Installs
- 571
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/new-silvermoon/awesome-android-agent-skills --skill compose-performance-audit- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads compose-performance-audit automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Compose Performance Audit
Overview
Audit Jetpack Compose view performance end-to-end, from instrumentation and baselining to root-cause analysis and concrete remediation steps.
Workflow Decision Tree
- If the user provides code, start with "Code-First Review."
- If the user only describes symptoms, ask for minimal code/context, then do "Code-First Review."
- If code review is inconclusive, go to "Guide the User to Profile" and ask for Layout Inspector output or Perfetto traces.
1. Code-First Review
Collect:
- Target Composable code.
- Data flow: state, remember, derived state, ViewModel connections.
- Symptoms and reproduction steps.
Focus on:
- Recomposition storms from unstable parameters or broad state changes.
- Unstable keys in
LazyColumn/LazyRow(keychurn, missing keys). - Heavy work in composition (formatting, sorting, filtering, object allocation).
- Unnecessary recompositions (missing
remember, unstable classes, lambdas). - Large images without proper sizing or async loading.
- Layout thrash (deep nesting, intrinsic measurements,
SubcomposeLayoutmisuse).
Provide:
- Likely root causes with code references.
- Suggested fixes and refactors.
- If needed, a minimal repro or instrumentation suggestion.
2. Guide the User to Profile
Explain how to collect data:
- Use Layout Inspector in Android Studio to see recomposition counts.
- Enable Recomposition Highlights in Compose tooling.
- Use Perfetto or System Trace for frame timing analysis.
- Check Macrobenchmark results for startup/scroll metrics.
Ask for:
- Layout Inspector screenshot showing recomposition counts.
- Perfetto trace or System Trace export.
- Device/OS/build configuration (debug vs release).
Important: Ensure profiling is done on a release build with R8 enabled. Debug builds have significant overhead.
3. Analyze and Diagnose
Prioritize likely Compose culprits:
- Recomposition storms from unstable parameters or broad state changes.
- Unstable keys in lazy lists (
keychurn, index-based keys). - Heavy work in composition (formatting, sorting, object allocation).
- Missing
remembercausing recreations on every recomposition. - Large images without
Modifier.size()constraints. - Unnecessary state reads in wrong composition phases.
Summarize findings with evidence from traces/Layout Inspector.
4. Remediate
Apply targeted fixes:
- Stabilize parameters: Use
@Stableor@Immutableannotations on data classes. - Stabilize keys: Use stable, unique IDs for
LazyColumn/LazyRowitems. - Defer state reads: Use
derivedStateOf, lambda-based modifiers, orModifier.drawBehind. - Remember expensive computations: Wrap in
remember { }orremember(key) { }. - Skip recomposition: Extract stable composables, use
key()to control identity. - Async image loading: Use Coil/Glide with proper sizing constraints.
- Reduce layout complexity: Flatten hierarchies, avoid deep nesting.
Common Code Smells (and Fixes)
Unstable lambda captures
// BAD: New lambda instance every recomposition
Button(onClick = { viewModel.doSomething(item) }) { ... }
// GOOD: Use remember or method reference
val onClick = remember(item) { { viewModel.doSomething(item) } }
Button(onClick = onClick) { ... }
Expensive work in composition
// BAD: Sorting on every recomposition
@Composable
fun ItemList(items: List<Item>) {
val sorted = items.sortedBy { it.name } // Runs every recomposition
LazyColumn { items(sorted) { ... } }
}
// GOOD: Use remember with key
@Composable
fun ItemList(items: List<Item>) {
val sorted = remember(items) { items.sortedBy { it.name } }
LazyColumn { items(sorted) { ... } }
}
Missing keys in LazyColumn
// BAD: Index-based identity (causes recomposition on list changes)
LazyColumn {
items(items) { item -> ItemRow(item) }
}
// GOOD: Stable key-based identity
LazyColumn {
items(items, key = { it.id }) { item -> ItemRow(item) }
}
Unstable data classes
// BAD: Unstable (contains List, which is not stable)
data class UiState(
val items: List<Item>,
val isLoading: Boolean
)
// GOOD: Mark as Immutable if truly immutable
@Immutable
data class UiState(
val items: ImmutableList<Item>, // kotlinx.collections.immutable
val isLoading: Boolean
)
Reading state too early
// BAD: State read during composition (recomposes whole tree)
@Composable
fun AnimatedBox(scrollState: ScrollState) {
val offset = scrollState.value // Recomposes on every scroll
Box(modifier = Modifier.offset(y = offset.dp)) { ... }
}
// GOOD: Defer state read to layout/draw phase
@Composable
fun AnimatedBox(scrollState: ScrollState) {
Box(modifier = Modifier.offset {
IntOffset(0, scrollState.value) // Read in layout phase
}) { ... }
}
Object allocation in composition
// BAD: Creates new Modifier chain every recomposition
Box(modifier = Modifier.padding(16.dp).background(Color.Red))
// GOOD for dynamic modifiers: Remember the modifier
val modifier = remember { Modifier.padding(16.dp).background(Color.Red) }
Box(modifier = modifier)
Stability Checklist
| Type | Stable by Default? | Fix |
|---|---|---|
Primitives (Int, String, Boolean) | Yes | N/A |
data class with stable fields | Yes* | Ensure all fields are stable |
List, Map, Set | No | Use ImmutableList from kotlinx |
Classes with var properties | No | Use @Stable if externally stable |
| Lambdas | No | Use remember { } |
5. Verify
Ask the user to:
- Re-run Layout Inspector and compare recomposition counts.
- Run Macrobenchmark and compare frame timing.
- Test on a real device with release build.
Summarize the delta (recomposition count, frame drops, jank) if provided.
Outputs
Provide:
- A short metrics table (before/after if available).
- Top issues (ordered by impact).
- Proposed fixes with estimated effort.
References
FAQ
What does the compose-performance-audit skill do?
Audit and improve Jetpack Compose runtime performance from code review and architecture. Use when asked to diagnose slow rendering, janky scrolling, excessive recompositions, or performance issues in Compose UI.
How do I install compose-performance-audit?
Run npx skills add https://github.com/new-silvermoon/awesome-android-agent-skills --skill compose-performance-audit in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/compose-performance-audit/ (personal) or .claude/skills/compose-performance-audit/ (project).
Which AI agents can use compose-performance-audit?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is compose-performance-audit safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains compose-performance-audit?
It is published by new-silvermoon in new-silvermoon/awesome-android-agent-skills. It has 571 recorded installs.
More from new-silvermoon/awesome-android-agent-skills
android-testing
new-silvermoon/awesome-android-agent-skills
Comprehensive testing strategy involving Unit, Integration, Hilt, and Screenshot tests.
gradle-build-performance
new-silvermoon/awesome-android-agent-skills
Debug and optimize Android/Gradle build performance. Use when builds are slow, investigating CI/CD performance, analyzing build scans, or identifying compilation bottlenecks.
compose-ui
new-silvermoon/awesome-android-agent-skills
Best practices for building UI with Jetpack Compose, focusing on state hoisting, detailed performance optimizations, and theming. Use this when writing or refactoring Composable functions.
android-gradle-logic
new-silvermoon/awesome-android-agent-skills
Expert guidance on setting up scalable Gradle build logic using Convention Plugins and Version Catalogs.
android-architecture
new-silvermoon/awesome-android-agent-skills
Expert guidance on setting up and maintaining a modern Android application architecture using Clean Architecture and Hilt. Use this when asked about project structure, module setup, or dependency injection.
kotlin-concurrency-expert
new-silvermoon/awesome-android-agent-skills
Kotlin Coroutines review and remediation for Android. Use when asked to review concurrency usage, fix coroutine-related bugs, improve thread safety, or resolve lifecycle issues in Kotlin/Android code.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.