compose-expert
git clone https://github.com/aldefy/compose-skill
T=$(mktemp -d) && git clone --depth=1 https://github.com/aldefy/compose-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/compose-expert" ~/.claude/skills/aldefy-compose-skill-compose-expert && rm -rf "$T"
skills/compose-expert/SKILL.mdInstallation notice: This skill is now distributed as a plugin. If you copied files into
manually, you are on an unmaintained install path and will not receive updates. Migrate via:~/.claude/skills//plugin marketplace add aldefy/compose-skill /plugin install compose-expertSee MIGRATION.md for Codex and Copilot CLI instructions. This banner will remain through v2.x and escalate in v3.0.
Compose Expert Skill
Non-opinionated, practical guidance for writing correct, performant Compose code — across Android, Desktop, iOS, and Web. Covers Jetpack Compose and Compose Multiplatform. Backed by analysis of actual source code from
androidx/androidx and
JetBrains/compose-multiplatform-core.
Review Mode
Activate when the input contains a GitHub PR URL (
github.com/.+/pull/\d+) or
explicit review phrases: "review this PR", "review this diff", "check this code",
"what's wrong with this".
When Review Mode activates:
- Do not follow the generation workflow below
- Read
and follow its workflow exclusivelyreferences/pr-review.md - Output a structured local review report — do not post to GitHub
Workflow
When helping with Compose code, follow this checklist:
1. Understand the request
- What Compose layer is involved? (Runtime, UI, Foundation, Material3, Navigation)
- Is this a state problem, layout problem, performance problem, or architecture question?
- Is this Android-only or Compose Multiplatform (CMP)?
2. Analyze the design (if visual reference provided)
- If the user shares a Figma frame, screenshot, or design spec, consult
references/design-to-compose.md - Decompose the design into a composable tree using the 5-step methodology
- Map design tokens to MaterialTheme, spacing to CompositionLocals
- Identify animation needs and consult
for recipesreferences/animation.md
3. Consult the right reference
Read the relevant reference file(s) from
references/ before answering:
| Topic | Reference File |
|---|---|
, , , state hoisting, , | |
| Structuring composables, slots, extraction, preview | — for design system structure, also see |
Modifier ordering, custom modifiers, | |
, , , | |
, , , custom locals | |
, , , , keys, content types | |
, type-safe routes, deep links, shared element transitions | |
, , , transitions | — for M3 token selection, also see |
, , dynamic color, , shapes | — for motion, see ; for design tokens, see |
| Recomposition skipping, stability, baseline profiles, benchmarking | |
| Semantics, content descriptions, traversal order, testing | |
| Removed/replaced APIs, migration paths from older Compose versions | |
Styles API (experimental): , , | |
| Figma/screenshot decomposition, design tokens, spacing, modifier ordering | |
| Production crash patterns, defensive coding, state/performance rules | |
Compose Multiplatform, /, resources (), migration | |
| Desktop (Window, Tray, MenuBar), iOS (UIKitView), Web (ComposeViewport) | |
| TV Compose: Surface, Carousel, NavigationDrawer, Cards, focus, D-pad | |
M3 motion tokens, , , animation duration, easing | |
| PR URL, code review, "review this PR", "what's wrong with this" | |
| Session start, project detection | |
| Atomic design, design system, reusable component, component library, design tokens | |
4. Apply and verify
- Write code that follows the patterns in the reference
- Flag any anti-patterns you see in the user's existing code
- Suggest the minimal correct solution — don't over-engineer
4a. Component building mode
When the request involves building a component (composable that renders UI):
- Consult
references/atomic-design.md - Classify the component level (atom, molecule, organism, template)
- Apply the "Ask" prompt from Section 5 before scaffolding code
- Ensure the component satisfies the atom contract (modifier, slots, tokens, defaults)
5. Cite the source
When referencing Compose internals, point to the exact source file:
// See: compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
Key Principles
-
Compose thinks in three phases: Composition → Layout → Drawing. State reads in each phase only trigger work for that phase and later ones.
-
Recomposition is frequent and cheap — but only if you help the compiler skip unchanged scopes. Use stable types, avoid allocations in composable bodies.
-
Modifier order matters.
is visually different fromModifier.padding(16.dp).background(Color.Red)
.Modifier.background(Color.Red).padding(16.dp) -
State should live as low as possible and be hoisted only as high as needed. Don't put everything in a ViewModel just because you can.
-
Side effects exist to bridge Compose's declarative world with imperative APIs. Use the right one for the job — misusing them causes bugs that are hard to trace.
-
Compose Multiplatform shares the runtime but not the platform. UI code in
is portable. Platform-specific APIs (commonMain
,LocalContext
,BackHandler
) requireWindow
/expect
or conditional source sets.actual
Source Code Receipts
Beyond the guidance docs, this skill bundles the actual source code from
androidx/androidx (branch: androidx-main) and JetBrains/compose-multiplatform-core
(branch: jb-main). When you need to verify how something works internally, or the
user asks "show me the actual implementation", read the raw source from
references/source-code/:
| Module | Source Reference | Key Files Inside |
|---|---|---|
| Runtime | | Composer.kt, Recomposer.kt, State.kt, Effects.kt, CompositionLocal.kt, Remember.kt, SlotTable.kt, Snapshot.kt |
| UI | | AndroidCompositionLocals.android.kt, Modifier.kt, Layout.kt, LayoutNode.kt, ModifierNodeElement.kt, DrawModifier.kt |
| Foundation | | LazyList.kt, LazyGrid.kt, BasicTextField.kt, Clickable.kt, Scrollable.kt, Pager.kt |
| Material3 | | MaterialTheme.kt, ColorScheme.kt, Button.kt, Scaffold.kt, TextField.kt, NavigationBar.kt |
| Navigation | | NavHost.kt, ComposeNavigator.kt, NavGraphBuilder.kt, DialogNavigator.kt |
| CMP | | Window.kt, ComposeUIViewController.kt, UIKitView.kt, ComposeViewport.kt, ResourceReader.kt |
Two-layer approach
- Start with guidance — read the topic-specific reference (e.g.,
)references/state-management.md - Go deeper with source — if the user wants receipts or you need to verify, read from
references/source-code/
Source tree map
androidx/androidx (branch: androidx-main) ├── compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/ ├── compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/ ├── compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/ ├── compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/ ├── compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/ ├── compose/navigation/navigation-compose/src/commonMain/kotlin/androidx/navigation/compose/ ├── tv/tv-material/src/main/java/androidx/tv/material3/ └── tv/tv-foundation/src/main/java/androidx/tv/foundation/ compose-multiplatform-core (branch: jb-main) ├── compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/ ├── compose/ui/ui/src/iosMain/kotlin/androidx/compose/ui/window/ ├── compose/ui/ui/src/webMain/kotlin/androidx/compose/ui/window/ ├── compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/ └── compose/foundation/foundation/src/skikoMain/kotlin/androidx/compose/foundation/ compose-multiplatform (resources library) └── components/resources/library/src/commonMain/