compose-agent
Skill373 starsChanged 7 months agoMITView on GitHub
Helps AI coding assistants write modern Jetpack Compose: correct state, side effects, performance-aware modifiers, Navigation 3, Paging 3 in Compose, coroutines on lifecycle, animations, UI tests, focus/keyboard navigation, Compose Multiplatform boundaries, idiomatic Kotlin, and well-shaped composable APIs. Targets the mistakes LLMs actually make in Compose code. Use when reading, writing, or reviewing Compose projects.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- hddq/restoidedited, first seen Nov 16, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- hddq/restoid★ 21298% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. About 0 are common, 9 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
If the repo pins older versions, match the repo — but call out what the modern path would look like in a one-line note.
- Very specific: line 27
Check for deprecated or soft-deprecated API using references/api.md.
- Distinctive: line 43
If doing a partial review, load only the relevant reference files — each references file is designed to be read in isolation.
- Very specific: line 48
Every composable that takes a Modifier names the parameter modifier, types it Modifier = Modifier, and applies it to the outermost layout …
- Very specific: line 52
Prefer rememberSaveable over remember for UI state that should survive configuration change or process death, unless the value is …
- Very specific: line 53
Use the typed state factories (mutableIntStateOf, mutableLongStateOf, mutableFloatStateOf, mutableDoubleStateOf) for primitive state.
- Very specific: line 55
Don't ship no-op "optimizations": remember(index) on a pure function, or remember-ing an already-auto-memoized callback under Strong …
- Very specific: line 56
Never put a lambda in a CompositionLocal.
- Very specific: line 57
Do not introduce third-party libraries without asking first.
- Very specific: line 58
When an element's background reads from MaterialTheme.colorScheme.* (directly or via a blend), its text and icon colors must read from the …
- Distinctive: line 137
When the agent is writing new code rather than reviewing, the same rules apply as guardrails.
- Very specific: line 141
If it renders a list, does it use a stable key =?
- Very specific: line 142
If it launches work, is that work in a LaunchedEffect, produceState, or the ViewModel — not in the composition body?
- Very specific: line 143
If it collects a Flow, is it collectAsStateWithLifecycle()?
- Distinctive: line 145
If it animates, is the API declarative first, remembered where needed, lifecycle-aware, and phase-correct?
- Very specific: line 147
If it pages, are keys stable, LoadState handled, and refresh/retry user-driven?
- Distinctive: line 148
If it needs focus, testing, or platform-specific behavior, did you load the focused reference before judging?
- Distinctive: line 150
If any answer is no and there is no deliberate reason, fix it before returning the code.
- Distinctive: line 161
If the user needs any of the above, narrow the scope and say so.
- Distinctive: line 187
Every rule in this skill traces back to one of:
- Distinctive: line 196
When a supplemental source (blog post, conference talk) disagrees with these, the primary sources win.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Compose Agent
Review, write, or modify Jetpack Compose code for correctness, modern API usage, and adherence to the official AndroidX guidelines. Report only genuine problems — do not nitpick or invent issues.
Target track (unless the repo says otherwise):
- Kotlin
2.0.20+with Compose Compiler1.5.4+(Strong Skipping Mode on by default). - Jetpack Compose BOM current, Material 3,
androidx.lifecyclewithcollectAsStateWithLifecycle(). - Navigation 3 (
androidx.navigation3) when the project can adopt it; otherwise Navigation 2.8+. - Coroutines + Flow as the async primitives. Do not reach for RxJava or blocking I/O.
If the repo pins older versions, match the repo — but call out what the modern path would look like in a one-line note.
Review Process
- Check for deprecated or soft-deprecated API using
references/api.md. - Validate state and data flow using
references/state.md. - Validate side-effect choice (
LaunchedEffect,DisposableEffect,produceState,snapshotFlow,rememberUpdatedState) usingreferences/effects.md. - Review composable performance — stability, lambda modifiers, lazy list keys, deferred reads, cross-phase back-writes — using
references/performance.md. - Review modifier usage — ordering, lambda-form,
Modifier.Nodeovercomposed { }— usingreferences/modifiers.md. - Review navigation using
references/navigation.md— start from its decision table (Nav3 vs Nav2 type-safe vs plain state) before touching call sites. - Review coroutines and lifecycle collection using
references/concurrency.md. - Review Flow operators and StateFlow / SharedFlow shape (
stateIn,shareIn,flatMapvariants,combine, error handling, backpressure,asStateFlow()) usingreferences/flows.md. - Review composable API shape (parameter order, slots, naming, defaults) using
references/component-api.md. - Review UI testing patterns using
references/testing.mdwhen tests, semantics, screenshots, previews, or fake UI dependencies are in scope. - Review focus and keyboard / D-pad navigation using
references/focus.mdwhen the UI uses focus APIs, keyboard input, TV, desktop, ChromeOS, or accessibility focus behavior. - Review Compose Multiplatform / KMP boundaries using
references/kmp.mdwhen common code,expect/actual, platform services, native views, or shared UI targets are in scope. - Review animation API choice and lifecycle — declarative vs imperative,
rememberedAnimatable, target-driven launches,springovertween, deferred animated reads,AnimatedContentkeys — usingreferences/animation.mdwhen anyanimate*,Animatable,Transition,AnimatedVisibility,AnimatedContent, or infinite-transition API is in scope. - Review Paging 3 in Compose —
collectAsLazyPagingItems(the paging differ — notcollectAsStateWithLifecycle, which does not apply toPagingData), stableitemKey,LoadStatebranches, user-drivenrefresh()/retry()— usingreferences/paging.mdwhenLazyPagingItems,PagingData, orcollectAsLazyPagingItemsis in scope. - Final Kotlin style pass using
references/kotlin.md.
If doing a partial review, load only the relevant reference files — each references file is designed to be read in isolation.
Core Instructions
- Keep composables side-effect free in composition. All I/O, state mutation outside remembered objects, analytics, etc. belong in
LaunchedEffect,DisposableEffect,produceState, the ViewModel, or — for event/gesture-driven work only —rememberCoroutineScope().launchinside a handler. Target-driven animation belongs inLaunchedEffector declarativeanimate*AsState/updateTransition, not inscope.launchfrom the composition body. Seereferences/animation.mdandreferences/effects.md. - Every composable that takes a
Modifiernames the parametermodifier, types itModifier = Modifier, and applies it to the outermost layout only. Never create amodifierparameter you do not forward. - Parameter order for a component: required data →
modifier: Modifier = Modifier→ other optional parameters with defaults → trailingcontent: @Composable () -> Unitslots last. Onemodifierparameter per component. - For stateful APIs, expose a stateless overload plus a stateful convenience that hoists
remember. Seereferences/component-api.md. - Collect Flows with
collectAsStateWithLifecycle()in UI code. PlaincollectAsState()keeps collecting when the screen is not visible and burns battery and bandwidth. Exception:Flow<PagingData<T>>is collected withcollectAsLazyPagingItems(), nevercollectAsStateWithLifecycle()— seereferences/paging.md. - Prefer
rememberSaveableoverrememberfor UI state that should survive configuration change or process death, unless the value is unserializable or derivable. - Use the typed state factories (
mutableIntStateOf,mutableLongStateOf,mutableFloatStateOf,mutableDoubleStateOf) for primitive state. RawmutableStateOf<Int>(...)boxes. - Never write state a phase has already read. A layout callback (
onSizeChanged/onGloballyPositioned/onPlaced) must not write state a sibling reads in composition (a cross-phase back-write, a measure → recompose loop), and never mutate amutableStateListOf/mutableStateMapOfinside a composable body that also reads it (composition-phase self-invalidation, a mutate → recompose loop). Consume measured values in layout/draw, or mutate snapshot state from an event /LaunchedEffect/ state holder. Seereferences/performance.md. - Don't ship no-op "optimizations":
remember(index)on a pure function, orremember-ing an already-auto-memoized callback under Strong Skipping (SSM memoizes lambdas even with unstable captures). Prove a recomposition win with Layout Inspector counts or compiler reports, not the presence of a pattern. Seereferences/performance.md. - Never put a lambda in a
CompositionLocal. Use explicit parameters. - Do not introduce third-party libraries without asking first. The Accompanist libraries covering pager, swipe-refresh, flow layout, and system UI controller are deprecated — the functionality is in AndroidX now (
HorizontalPager,PullToRefreshBox,FlowRow/FlowColumn,enableEdgeToEdge()). - When an element's background reads from
MaterialTheme.colorScheme.*(directly or via a blend), its text and icon colors must read from the same theming source. Hard-codedColor.Black/Color.White/ raw ARGB literals over theme-driven backgrounds are dark-mode regressions. Seereferences/component-api.md. - Animate declaratively first. Use
animate*AsStatefor single state-driven values andupdateTransitionfor synchronized ones; reach forAnimatableonly when you need imperative control (gesture, fling, sequence). AlwaysrememberanAnimatable, launch target-driven animations fromLaunchedEffect(neverscope.launchin composition to react to state), preferspring()overtweenfor interruptible motion, and read animated values in the layout/draw phase (lambda modifiers /graphicsLayer) so the animation does not recompose every frame. Seereferences/animation.md. - For paged feeds, use
collectAsLazyPagingItems(), render withitems(count = …, key = …)and stable domain ids, branch onloadStatefor loading/empty/error/append, and keeprefresh()/retry()on user actions — not in the composition body. Seereferences/paging.md.
Output Format (review mode)
Organize findings by file. For each issue:
- State the file and relevant line(s).
- Name the rule being violated (e.g., "Use
collectAsStateWithLifecycle()instead ofcollectAsState()"). - Show a brief before/after code fix.
- Link the official source (
developer.android.com/...or AndroidX component guidelines).
Skip files with no issues. End with a prioritized summary — three items max, highest impact first.
Example Output
feature/profile/ProfileScreen.kt
Line 34: Use collectAsStateWithLifecycle() — UI Flows must stop collecting when the screen is not STARTED.
// Before
val user by viewModel.user.collectAsState()
// After
val user by viewModel.user.collectAsStateWithLifecycle()https://developer.android.com/topic/architecture/ui-layer/state-production#continuous-vs-discrete
Line 58: Pass modifier to the outermost layout, not to inner content.
// Before
@Composable
fun UserCard(user: User, modifier: Modifier = Modifier) {
Column {
Text(user.name, modifier = modifier) // modifier swallowed here
Text(user.email)
}
}
// After
@Composable
fun UserCard(user: User, modifier: Modifier = Modifier) {
Column(modifier = modifier) {
Text(user.name)
Text(user.email)
}
}https://developer.android.com/develop/ui/compose/api-guidelines#naming-modifiers
Line 72: Defer the animated offset read to the layout phase using the lambda form.
// Before
val dx by animateDpAsState(targetValue = if (expanded) 0.dp else (-200).dp, label = "drawerOffset")
Box(modifier = Modifier.offset(x = dx))
// After — layout-phase read, skips recomposition on every frame
val dx by animateDpAsState(targetValue = if (expanded) 0.dp else (-200).dp, label = "drawerOffset")
Box(modifier = Modifier.offset { IntOffset(dx.roundToPx(), 0) })Summary
- Performance (high): Non-deferred animated reads on
ProfileScreen.kt:72,HomeScreen.kt:110,DetailScreen.kt:88recompose every frame. Switch to lambda-form modifiers. - Lifecycle (high): Three screens use
collectAsState()— replace withcollectAsStateWithLifecycle()to avoid collecting in the background. - API shape (medium):
UserCardswallows itsmodifierparameter. Forward it to the outermost layout.
End of example.
Authoring Mode
When the agent is writing new code rather than reviewing, the same rules apply as guardrails. Before generating a composable, silently check:
- Does it take
modifier: Modifier = Modifier? - Is state hoisted, or is there a clear reason to own it here?
- If it renders a list, does it use a stable
key =? - If it launches work, is that work in a
LaunchedEffect,produceState, or the ViewModel — not in the composition body? - If it collects a Flow, is it
collectAsStateWithLifecycle()? (AFlow<PagingData<T>>is the exception — it usescollectAsLazyPagingItems().) - Is the parameter order: data → modifier → other → content slot last?
- If it animates, is the API declarative first, remembered where needed, lifecycle-aware, and phase-correct?
- Does any layout callback or snapshot-collection mutation write state read back in composition (a cross-phase / self-invalidation loop)?
- If it pages, are keys stable,
LoadStatehandled, and refresh/retry user-driven? - If it needs focus, testing, or platform-specific behavior, did you load the focused reference before judging?
If any answer is no and there is no deliberate reason, fix it before returning the code.
What This Skill Does Not Cover
Out of scope in v1 — delegate elsewhere or scope down explicitly:
- Material 3 compliance, theming, and design tokens — use the
material-3skill. - Scoring an existing codebase with numeric grades — use the sibling
jetpack-compose-auditskill in the same repo. - Wear OS / TV / Auto / Glance deep platform review — this skill now covers focus and keyboard/D-pad basics, but not full platform certification.
- Accessibility deep review — we flag obvious gaps (missing
contentDescription, icon-only buttons without labels, touch targets under 48dp) but do not grade.
If the user needs any of the above, narrow the scope and say so.
References
references/api.md— deprecated and soft-deprecated Compose APIs and their modern replacements.references/state.md— hoisting,remembervsrememberSaveable, ViewModel boundaries,derivedStateOf.references/effects.md—LaunchedEffect,DisposableEffect,SideEffect,produceState,snapshotFlow,rememberUpdatedState.references/performance.md— stability, Strong Skipping Mode, lambda modifiers, lazy keys, typed state factories, deferred reads.references/modifiers.md— modifier ordering, lambda form,Modifier.Nodeovercomposed { }.references/navigation.md— decision table (Nav3 vs Nav2 type-safe vs plain state), Navigation 3, and what to replace from Navigation 2.references/concurrency.md— coroutines, Flow,collectAsStateWithLifecycle,repeatOnLifecycle, scope choice.references/flows.md— operator selection:StateFlowvsSharedFlowvs coldFlow,stateIn(WhileSubscribed),shareIn,flatMapvariants,combine/merge/zip, error handling, backpressure,asStateFlow()exposure.references/component-api.md— composable API guidelines: parameter order, slots, naming, defaults, state hoisting shape.references/testing.md— Compose UI tests, semantics assertions, screenshot tests, fake image/platform services, previews.references/focus.md—FocusRequester, focus restoration, keyboard / D-pad input, key handlers, and focus tests.references/kmp.md— Kotlin Multiplatform and Compose Multiplatform boundaries,expect/actual, interfaces, platform leaf composables.references/animation.md— animation API selection (animate*AsStatevsupdateTransitionvsAnimatable),remembered animation state, target-driven launches, gesture-drivensnapTo/animateDecay,spring/tween/keyframes, reduced motion, deferred animated reads,AnimatedContent/AnimatedVisibility,animateItem(), off-screen infinite transitions.references/paging.md— Paging 3 in Compose: when to page vs plain lists,collectAsLazyPagingItems, stableitemKey,LoadStateUI, pull-to-refresh, anti-patterns for paginated lazy lists.references/kotlin.md— Kotlin coding conventions and Android Kotlin style the LLM keeps missing.
Acceptance Evals
evals/evals.json holds write-mode acceptance cases — prompts that ask this skill to write Compose, plus the expectations the produced code must satisfy. Cases 0–2 mirror the jetpack-compose-audit scoring rules 1:1 (cross-phase back-writes, Strong Skipping false leads, snapshot self-invalidation) — bin/ci keeps them in lockstep so the authoring path can't drift from the audit path; cases 3–4 add foundational phase-correct reads and lifecycle-aware Flow collection. Run a model with this skill loaded against each prompt and check every expectation.
Primary Sources
Every rule in this skill traces back to one of:
https://developer.android.com/develop/ui/composeand its subpageshttps://developer.android.com/kotlin/style-guidehttps://kotlinlang.org/docs/coding-conventions.htmlhttps://www.jetbrains.com/help/kotlin-multiplatform-dev/https://android.googlesource.com/platform/frameworks/support/+/androidx-main/compose/docs/compose-api-guidelines.mdhttps://android.googlesource.com/platform/frameworks/support/+/androidx-main/compose/docs/compose-component-api-guidelines.md
When a supplemental source (blog post, conference talk) disagrees with these, the primary sources win.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

