Review or generate Jetpack Compose code for correctness, modern API usage,
and adherence to Android best practices. Report only genuine issues — do not
nitpick style unless it contradicts a clear rule.
Review / Generation Process
When reviewing existing code, follow these steps in order:
- Check for deprecated or outdated APIs →
references/api.md
- Review composable structure and composition patterns →
references/composables.md
- Validate state management and data flow →
references/state.md
- Validate side-effect usage →
references/effects.md
- Check recomposition stability →
references/recomposition.md
- Validate navigation implementation →
references/navigation.md
- Check Material 3 / Expressive design compliance →
references/design.md
- Validate accessibility →
references/accessibility.md
- Check performance →
references/performance.md
- Quick Kotlin code review →
references/kotlin.md
- Final code hygiene check →
references/hygiene.md
When generating new code, load the relevant reference files for the feature
being built before writing any code, so output is idiomatic from the start.
For partial reviews or targeted generation, load only the relevant reference files.
Core Instructions
- Target Compose BOM 2024.x by default. Note where BOM 2025.x (Material Expressive)
introduces new components or APIs.
- Use Material 3. Do not use Material 2 unless the project already uses it.
- Architecture: MVVM with unidirectional data flow (UDF). ViewModel + StateFlow
for screen state. Compose UI observes state, emits events.
- Target Kotlin with modern language features (sealed interfaces, coroutines, Flow).
- Do not introduce third-party libraries without asking first.
- Each composable should live in its own file for non-trivial components.
- Organize by feature, not by technical layer (screens/home/, screens/settings/, etc.).
Output Format
Organize findings by file. For each issue:
- State the file and relevant line(s).
- Name the rule being violated.
- Show a brief before/after Kotlin snippet.
Skip files with no issues. End with a prioritized summary of the most impactful
changes to make first.
Example output:
HomeScreen.kt
Line 14: Use collectAsStateWithLifecycle() instead of collectAsState().
// Before
val uiState by viewModel.uiState.collectAsState()
// After
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
Line 42: Provide key in LazyColumn for stable item identity.
// Before
LazyColumn {
items(books) { book ->
BookItem(book)
}
}
// After
LazyColumn {
items(books, key = { it.id }) { book ->
BookItem(book)
}
}
Line 67: Image missing contentDescription — required for accessibility.
// Before
Image(painter = painterResource(R.drawable.cover), contentDescription = null)
// After — if decorative:
Image(painter = painterResource(R.drawable.cover), contentDescription = null) // OK if truly decorative
// After — if meaningful:
Image(
painter = painterResource(R.drawable.cover),
contentDescription = stringResource(R.string.book_cover_description)
)
Summary
- State (high):
collectAsState() on line 14 does not respect lifecycle — replace with collectAsStateWithLifecycle().
- Performance (medium): Missing
key in LazyColumn on line 42 causes unnecessary recomposition.
- Accessibility (medium): Image on line 67 needs a meaningful
contentDescription.
References
references/api.md — deprecated APIs and their modern replacements.
references/composables.md — composable structure, naming, and composition patterns.
references/state.md — state management, ViewModel, StateFlow, and data flow.
references/effects.md — side effects: LaunchedEffect, DisposableEffect, SideEffect.
references/recomposition.md — recomposition stability, @Stable/@Immutable, derivedStateOf.
references/navigation.md — Navigation Compose, type-safe nav, nested graphs.
references/design.md — Material 3 / Expressive theming, adaptive layouts.
references/accessibility.md — TalkBack, semantics, content descriptions, touch targets.
references/performance.md — LazyList optimization, remember, scope of state reads.
references/kotlin.md — modern Kotlin patterns for Android.
references/hygiene.md — code hygiene, testing, lint.
1---2name: modern-jetpack-compose3description: Guides writing, reviewing, and reasoning about modern Android UI code using Jetpack Compose. Covers best practices for state management, side effects, recomposition, navigation, Material 3 design, accessibility, and performance. Use when reading, writing, or reviewing any Jetpack Compose project.4license: MIT5---6
7Review or generate Jetpack Compose code for correctness, modern API usage,
8and adherence to Android best practices. Report only genuine issues — do not
9nitpick style unless it contradicts a clear rule.
10
11## Review / Generation Process
12
13When reviewing existing code, follow these steps in order:
14
151. Check for deprecated or outdated APIs → `references/api.md`
162. Review composable structure and composition patterns → `references/composables.md`
173. Validate state management and data flow → `references/state.md`
184. Validate side-effect usage → `references/effects.md`
195. Check recomposition stability → `references/recomposition.md`
206. Validate navigation implementation → `references/navigation.md`
217. Check Material 3 / Expressive design compliance → `references/design.md`
228. Validate accessibility → `references/accessibility.md`
239. Check performance → `references/performance.md`
2410. Quick Kotlin code review → `references/kotlin.md`
2511. Final code hygiene check → `references/hygiene.md`
26
27When **generating** new code, load the relevant reference files for the feature
28being built before writing any code, so output is idiomatic from the start.
29
30For partial reviews or targeted generation, load only the relevant reference files.
31
32
33## Core Instructions
34
35- Target Compose BOM 2024.x by default. Note where BOM 2025.x (Material Expressive)
36 introduces new components or APIs.
37- Use Material 3. Do not use Material 2 unless the project already uses it.
38- Architecture: MVVM with unidirectional data flow (UDF). ViewModel + StateFlow
39 for screen state. Compose UI observes state, emits events.
40- Target Kotlin with modern language features (sealed interfaces, coroutines, Flow).
41- Do not introduce third-party libraries without asking first.
42- Each composable should live in its own file for non-trivial components.
43- Organize by feature, not by technical layer (screens/home/, screens/settings/, etc.).
44
45
46## Output Format
47
48Organize findings by file. For each issue:
49
501. State the file and relevant line(s).
512. Name the rule being violated.
523. Show a brief before/after Kotlin snippet.
53
54Skip files with no issues. End with a prioritized summary of the most impactful
55changes to make first.
56
57**Example output:**
58
59### HomeScreen.kt
60
61**Line 14: Use `collectAsStateWithLifecycle()` instead of `collectAsState()`.**
62
63```kotlin
64// Before
65val uiState by viewModel.uiState.collectAsState()
66
67// After
68val uiState by viewModel.uiState.collectAsStateWithLifecycle()
69```
70
71**Line 42: Provide `key` in LazyColumn for stable item identity.**
72
73```kotlin
74// Before
75LazyColumn {
76 items(books) { book ->
77 BookItem(book)
78 }
79}
80
81// After
82LazyColumn {
83 items(books, key = { it.id }) { book ->
84 BookItem(book)
85 }
86}
87```
88
89**Line 67: Image missing contentDescription — required for accessibility.**
90
91```kotlin
92// Before
93Image(painter = painterResource(R.drawable.cover), contentDescription = null)
94
95// After — if decorative:
96Image(painter = painterResource(R.drawable.cover), contentDescription = null) // OK if truly decorative
97
98// After — if meaningful:
99Image(
100 painter = painterResource(R.drawable.cover),
101 contentDescription = stringResource(R.string.book_cover_description)
102)
103```
104
105### Summary
106
1071. **State (high):** `collectAsState()` on line 14 does not respect lifecycle — replace with `collectAsStateWithLifecycle()`.
1082. **Performance (medium):** Missing `key` in `LazyColumn` on line 42 causes unnecessary recomposition.
1093. **Accessibility (medium):** Image on line 67 needs a meaningful `contentDescription`.
110
111---
112
113## References
114
115- `references/api.md` — deprecated APIs and their modern replacements.
116- `references/composables.md` — composable structure, naming, and composition patterns.
117- `references/state.md` — state management, ViewModel, StateFlow, and data flow.
118- `references/effects.md` — side effects: LaunchedEffect, DisposableEffect, SideEffect.
119- `references/recomposition.md` — recomposition stability, @Stable/@Immutable, derivedStateOf.
120- `references/navigation.md` — Navigation Compose, type-safe nav, nested graphs.
121- `references/design.md` — Material 3 / Expressive theming, adaptive layouts.
122- `references/accessibility.md` — TalkBack, semantics, content descriptions, touch targets.
123- `references/performance.md` — LazyList optimization, remember, scope of state reads.
124- `references/kotlin.md` — modern Kotlin patterns for Android.
125- `references/hygiene.md` — code hygiene, testing, lint.