compose-ui
Skill17 starsChanged 9 months agoMITView on GitHub
Jetpack Compose UI best practices and patterns for Material 3. Use when: writing or reviewing Compose UI code, implementing state hoisting, using side effects (LaunchedEffect, DisposableEffect), setting up type-safe navigation, building responsive layouts with WindowSizeClass, implementing accessibility (content descriptions, touch targets, semantics), creating animations (AnimatedVisibility, animateXAsState), or designing reusable composable components.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- JetBrains/intellij-communitytheir own version, first seen Nov 8, 2026
- IntelliHelper/agent-skillstheir own version, first seen Oct 20, 2026
- r0adkll/Campfiretheir own version, first seen Oct 9, 2026
- maxrave-dev/SimpMusictheir own version, first seen Oct 8, 2026
- Meet-Miyani/compose-skilltheir own version, first seen Oct 1, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- JetBrains/intellij-community★ 21ksame name
- maxrave-dev/SimpMusic★ 13ksame name
- Meet-Miyani/compose-skill★ 303same name
- r0adkll/Campfire★ 151same name
- IntelliHelper/agent-skills★ 1same name
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 repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- architectureSkill
- kotlin-qualitySkill
- performanceSkill
- play-storeSkill
- privacy-auditSkill
- security-auditSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. 0 are common, 6 are distinctive, and 12 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
6
Distinctive
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
- Very specific: line 48
Use rememberSaveable for state that survives configuration changes.
- Very specific: line 50
ALWAYS use collectAsStateWithLifecycle() (NOT collectAsState()).
- Distinctive: line 51
Use sealed interface for UI state.
- Distinctive: line 58
NEVER launch coroutines directly in Composable body.
- Distinctive: line 61
Use type-safe navigation (Navigation Compose 2.8+).
- Distinctive: line 63
NEVER pass complex objects as navigation arguments.
- Distinctive: line 67
Use Material 3 tokens, NEVER hardcoded colors.
- Very specific: line 70
Use MaterialTheme.typography for text styles, NEVER hardcoded sizes.
- Distinctive: line 73
ALL interactive elements MUST have content descriptions.
- Very specific: line 77
Use Modifier.clearAndSetSemantics for custom announcements.
- Very specific: line 81
Use WindowSizeClass for adaptive layouts.
- Very specific: line 82
Use Modifier.fillMaxWidth() with constraints, not fixed widths.
- Very specific: line 83
Use BoxWithConstraints for constraint-dependent layouts.
- Very specific: line 86
Use animateXAsState for simple value animations.
- Very specific: line 87
Use AnimatedVisibility for enter/exit.
- Very specific: line 88
Use AnimatedContent for content transitions.
- Very specific: line 89
ALWAYS provide label parameter for animations.
- Very specific: line 90
Use Modifier.graphicsLayer for GPU-accelerated transforms.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Compose UI Best Practices
Provide guidance and review for Jetpack Compose UI code following Material 3 design patterns and modern Android conventions.
Review Process
Evaluate Compose code against ALL categories. Output findings as:
[COMPOSE-XXXXX] severity: CRITICAL | HIGH | MEDIUM | LOW
Finding: <what is wrong or can be improved>
Location: <file:line>
Fix: <concrete code fix>Reference Guide — Load on Demand
Each reference file contains full code examples and patterns. Read the relevant file when reviewing that area.
| # | Reference File | Content | When to Load |
| 1 | references/state-and-effects.md | State hoisting, rememberSaveable, collectAsStateWithLifecycle, LaunchedEffect, DisposableEffect, SideEffect | Reviewing state management or side effects |
| 2 | references/navigation.md | Type-safe navigation, back stack, navigation events | Reviewing navigation setup |
| 3 | references/theming.md | Material 3 tokens, dynamic colors, custom extensions | Reviewing theme or color usage |
| 4 | references/accessibility.md | Content descriptions, touch targets, semantics merging | Reviewing accessibility compliance |
| 5 | references/layout-and-animation.md | WindowSizeClass, responsive layout, AnimatedVisibility, animateXAsState | Reviewing layout or animation code |
Rules Summary
State Management
- State ownership: state hoisted to the lowest common ancestor.
- Use
rememberSaveablefor state that survives configuration changes. - Complex state belongs in ViewModel, exposed as
StateFlow. See architecture skill for ViewModel implementation patterns. - ALWAYS use
collectAsStateWithLifecycle()(NOTcollectAsState()). - Use sealed interface for UI state.
Side Effects
LaunchedEffectfor coroutine-based side effects.DisposableEffectfor cleanup-requiring side effects.SideEffectfor non-suspend side effects on every successful recomposition.rememberCoroutineScopefor event-triggered coroutines.- NEVER launch coroutines directly in Composable body.
Navigation
- Use type-safe navigation (Navigation Compose 2.8+).
- Navigate with
popUpToto avoid back stack buildup. - NEVER pass complex objects as navigation arguments. Pass IDs, fetch in destination.
- One-time navigation events via Channel/SharedFlow. See architecture skill for event channel pattern.
Theming & Material 3
- Use Material 3 tokens, NEVER hardcoded colors.
- Support dynamic colors (Android 12+).
- Define custom theme extensions via
CompositionLocal. - Use
MaterialTheme.typographyfor text styles, NEVER hardcoded sizes.
Accessibility
- ALL interactive elements MUST have content descriptions.
- Decorative elements use
nullcontentDescription. - Minimum touch target: 48dp x 48dp.
- Merge semantics for grouped content.
- Use
Modifier.clearAndSetSemanticsfor custom announcements. - State descriptions for toggles.
Responsive Layout
- Use
WindowSizeClassfor adaptive layouts. - Use
Modifier.fillMaxWidth()with constraints, not fixed widths. - Use
BoxWithConstraintsfor constraint-dependent layouts.
Animation
- Use
animateXAsStatefor simple value animations. - Use
AnimatedVisibilityfor enter/exit. - Use
AnimatedContentfor content transitions. - ALWAYS provide
labelparameter for animations. - Use
Modifier.graphicsLayerfor GPU-accelerated transforms.
Checklists
State Management
- UI state exposed as StateFlow from ViewModel
- collectAsStateWithLifecycle used (not collectAsState)
- Composable parameters are stable/immutable
- State hoisted to appropriate level
- rememberSaveable for user input that survives rotation
- Sealed interface for screen state
Side Effects
- No coroutine launches outside side effect handlers
- LaunchedEffect keys match the data they depend on
- DisposableEffect used when cleanup is needed
- rememberCoroutineScope for user-triggered actions
Navigation
- Type-safe navigation routes (Serializable objects)
- No complex objects passed as arguments
- Back stack managed properly (popUpTo where needed)
- One-time events use Channel, not StateFlow
Theming & Material 3
- No hardcoded colors (use colorScheme tokens)
- No hardcoded text sizes (use typography tokens)
- Dark theme supported
- Dynamic colors supported (Android 12+)
- Custom tokens use CompositionLocal
Accessibility
- All clickable elements have contentDescription
- Touch targets >= 48dp
- Semantics merged for logical groups
- Screen reader tested (TalkBack)
- Sufficient color contrast (4.5:1 for text)
Animation
- Animations use appropriate API (animateXAsState, AnimatedVisibility, etc.)
- All animations have label parameter
- No infinite animations without user control
- Animations respect
prefers-reduced-motionaccessibility setting - Complex animations use
Transitionfor coordination
Component Design Principles
Composable Function Signature Convention
@Composable
fun MyComponent(
// 1. Required data parameters
title: String,
items: ImmutableList<Item>,
// 2. Optional data parameters with defaults
subtitle: String = "",
// 3. Event callbacks
onClick: () -> Unit,
onItemSelected: (Item) -> Unit,
// 4. Modifier (always last with default)
modifier: Modifier = Modifier
) {
// Implementation
}Preview
@Preview(showBackground = true)
@Preview(showBackground = true, uiMode = UI_MODE_NIGHT_YES)
@Preview(showBackground = true, device = Devices.TABLET)
@Composable
private fun MyComponentPreview() {
AppTheme {
MyComponent(
title = "Preview Title",
items = persistentListOf(Item("1", "Sample")),
onClick = {},
onItemSelected = {}
)
}
}Component Checklist
- Modifier is last parameter with default
- Previews for light/dark/tablet
- Stateless where possible (state hoisted)
- Parameters are stable types
For ViewModel implementation patterns, see the architecture skill. For performance optimization of Compose recomposition, see the performance skill.
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.

