rcosteira79/android-skills

compose

Compose and Compose Multiplatform expert for UI development across Android, Desktop, iOS, and Web.

Vedi sorgente

Come usare

  1. Copia il comando e controlla il pacchetto prima di installarlo nel tuo ambiente agente.
  2. Controlla strumenti, credenziali e ambienti richiesti nel documento originale.
  3. Descrivi input e risultato desiderato; confronta l’output con le fonti.
npx skills add https://github.com/rcosteira79/android-skills --skill compose

Prima di iniziare

  • L’installazione non include abbonamenti, quote API o accesso ai file.
  • Stelle e installazioni indicano attività, non un test indipendente di qualità o sicurezza.
Documento Skill originale

Contenuto dal repository con titoli, esempi, codice, tabelle, link e immagini preservati.

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.

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
  • Transcribe, don't adapt — copy, casing, punctuation and number format come across exactly; resolve each value to the token that matches it exactly, and add a token the theme lacks rather than substituting the nearest (references/design-to-compose.md)
  • Map design tokens to MaterialTheme, spacing to CompositionLocals
  • Identify animation needs — references/animation.md (contentKey, phase rule, M3 motion tokens), references/animation-recipes.md (shimmer/loading-crossfade + choreography), or references/animation-advanced.md (shared-element, predictive back, drawBehind-for-color)

3. Consult the right reference

Read the relevant reference file(s) from references/ before answering:

TopicReference File
State-hoisting boundary (UI-value-drives-business-logic), derivedStateOf-capture trap, cross-phase back-writing, durable-state-over-events, @ReadOnlyComposablereferences/state-management.md
Slot / content-API authoring — receiver scopes (RowScope), optional (nullable) slots, XxxDefaults, slot-vs-boolean-flagreferences/view-composition.md
Screen/content split (private content composable), framework-state-stays-in-UI (not hoisted to the ViewModel)references/screen-structure.md
Modifier-as-API-contract rules (no hardcoded placement on a reusable root, caller-modifier-first) + chain orderingreferences/modifiers.md
Effects (LaunchedEffect/DisposableEffect/SideEffect), lifecycle effects (LifecycleResumeEffect), effect anti-patternsreferences/side-effects.md
compositionLocalOf vs staticCompositionLocalOf (recomposition scope), custom locals, no-mutable-State-in-a-localreferences/composition-locals.md
LazyList perf traps — indexOf()-O(n²), no-new-objects-in-key, animateItem, ReportDrawnWhen, infinite-scroll triggerreferences/lists-scrolling.md
Navigation 3 (NavDisplay, back-stack-as-state, compose-shape guardrails); type-safe @Serializable routesreferences/navigation.md
AnimatedContent contentKey-on-shape, defer-reads-to-latest-phase (lambda modifiers), M3 motion/easing tokensreferences/animation.md
Animation recipes (shimmer/loading-crossfade), sequential/parallel/staggered choreographyreferences/animation-recipes.md
Shared-element transitions (sharedBounds/sharedElement/skipToLookaheadSize), drawBehind-for-animated-color, predictive backreferences/animation-advanced.md
Extending the theme beyond M3's three slots — custom design tokens via CompositionLocalreferences/theming-material3.md
Touch targets, spacing, canonical layouts, foldables, M3 compliance auditandroid-skills:android-ux
Recomposition skipping, stability, baseline profiles, benchmarkingreferences/performance.md
Traversal order (traversalIndex / isTraversalGroup), live-region mode (Polite vs Assertive)references/accessibility.md
FocusRequester, focusable(), focusProperties, key events, D-pad, TV, keyboard, focus restorationreferences/focus-navigation.md
Removed/replaced APIs, migration paths from older Compose versionsreferences/deprecated-patterns.md
Styles API (experimental): Style {}, MutableStyleState, Modifier.styleable()references/styles-experimental.md
Transcribing a design — exact copy/casing/number format, exact-token-vs-near-neighbour, missing-token-added-not-substituted, export-over-render as source of truth; Figma dropShadow/innerShadow (1.9+, chain placement), spacing/elevation design-token CompositionLocalreferences/design-to-compose.md
Production crash patterns, defensive coding, state/performance rulesreferences/production-crash-playbook.md
CMP gotchas (collectAsState-in-commonMain, commonMain @Preview package, Lottie→Kottie, compiler-stability-non-JVM) + Android-only→CMP migrationreferences/multiplatform.md
Desktop (Window, Tray, MenuBar), iOS (UIKitView), Web (ComposeViewport)references/platform-specifics.md

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

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

  1. Compose thinks in three phases: Composition → Layout → Drawing. State reads in each

phase only trigger work for that phase and later ones.

  1. Recomposition is frequent and cheap — but only if you help the compiler skip unchanged

scopes. Use stable types, avoid allocations in composable bodies.

  1. Modifier order matters. Modifier.padding(16.dp).background(Color.Red) is visually

different from Modifier.background(Color.Red).padding(16.dp).

  1. 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.

  1. 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.

  1. Compose Multiplatform shares the runtime but not the platform. UI code in

commonMain is portable. Platform-specific APIs (LocalContext, BackHandler, Window) require expect/actual or conditional source sets.

Source Code Verification

Always verify against live source code — never rely on training data alone.

Tier 1 (Preferred): android-sources MCP server

When available, use the MCP tools for fast, precise lookups:

lookup_class(className: "LazyListState")
lookup_method(className: "Composer", methodName: "startRestartGroup")
search_in_source(query: "fun rememberLazyListState")
list_class_members(className: "Modifier")
get_class_hierarchy(className: "LazyListState")
find_references(className: "SnapshotState", methodName: "value")

Tier 2 (Fallback): Raw GitHub URLs

If the MCP server is unavailable, fetch source directly:

  • AndroidX: https://raw.githubusercontent.com/androidx/androidx/androidx-main/{path}
  • Directory listing: gh api repos/androidx/androidx/contents/{path}
  • CMP: https://raw.githubusercontent.com/JetBrains/compose-multiplatform-core/jb-main/{path}
  • AOSP platform: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/{path}?format=TEXT (base64)

Two-layer approach

  1. Start with guidance — read the topic-specific reference (e.g., references/state-management.md)
  2. Verify against live source — use MCP tools or raw GitHub to confirm behavior

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/

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/

Authoritative Docs

For guidance, best practices, or migration guides — things source code alone can't answer — prefer Google's Android Knowledge Base over web search:

bash
android docs search "LazyColumn performance"              # ranked kb:// URLs + summaries
android docs fetch kb://android/develop/ui/compose/lists  # full content of a result

4800+ curated docs across Android, Wear, TV, KMP, and Glance. Use this when the internal files in references/ don't cover your question; use source code lookups (above) when you need implementation details rather than guidance.

Correlati per attività

dallo stesso repository

Altri Skills

Tutti gli Skills
rcosteira79
Community

android-data-layer

Use when implementing the data layer in Android or KMP — the Repository pattern's layered error-propagation model (repository as the error boundary, sealed DataError, Result placement with and without a domain layer) and Room in commonMain (@ConstructedBy, BundledSQLiteDriver, per-target KSP).

installazioni
1
GitHub Stars
155
Aggiornato
19 set
rcosteira79
Community

android-debugging

Use when debugging Android or KMP issues — Android-specific techniques covering Logcat, ADB, ANR traces, R8 stack trace decoding, memory leaks, Gradle build failures, and Compose recomposition bugs, on a root-cause-first foundation.

installazioni
1
GitHub Stars
155
Aggiornato
19 set
rcosteira79
Community

android-dev

Use this skill as the baseline for ALL Android and Kotlin Multiplatform (KMP) work — whenever the user mentions Android, Kotlin (in an Android context), KMP, CMP, commonMain, androidMain, iosMain, AndroidManifest, Gradle, build.gradle, Hilt, Dagger, Room, Retrofit, Ktor, ViewModel, LiveData, StateFlow, SharedFlow, Compose, Activity, Fragment, Intent, ADB, Logcat, MVVM, MVI, repository pattern, or any Android SDK / Jetpack / AndroidX API. Always load this skill alongside the more specific skills

installazioni
1
GitHub Stars
155
Aggiornato
19 set
rcosteira79
Community

android-ux

Use when designing or reviewing Android UI — applies Material Design 3 UX principles covering touch targets, spacing, navigation patterns, accessibility, animation timing, and platform conventions. Includes an M3 compliance audit that scores screens across 10 categories. Complements the compose skill with design-level decisions.

installazioni
1
GitHub Stars
155
Aggiornato
19 set