npx skills add ...
npx skills add vitorpamplona/amethyst --skill compose-expert
Advanced Compose Multiplatform UI patterns for shared composables. Use when working with visual UI components, state management patterns (remember, derivedStateOf, produceState), recomposition optimization (@Stable/@Immutable visual usage), Material3 theming, custom ImageVector icons, or determining whether to share UI in commonMain vs keep platform-specific. Delegates navigation to android-expert/desktop-expert. Complements kotlin-expert (handles Kotlin language aspects of state/annotations).
npx skills add vitorpamplona/amethyst --skill compose-expert
Visual UI patterns for sharing composables across Android and Desktop.
commonMain or keep platform-specificDelegate to other skills:
android-expert, desktop-expertkotlin-expertgradle-expertDefault to commonsUI/commonMain (shared composables live in :commonsUI, the Compose half of the shared layer; headless state/ViewModels stay in :commons) unless platform experts indicate otherwise.
commonMaincommonMainandroid-expert or desktop-expertIf uncertain, default to sharing - easier to split later than merge.
Pattern: State down, events up
modifier parameter = layout controlWhy this works on all platforms:
Visual pattern: Toggle button → state changes → UI expands/collapses Use for: Simple UI state (toggles, counters, text input)
Visual pattern: Scroll position (0, 1, 2...) → boolean (show/hide) → Button visibility Use for: Input changes frequently, derived result changes rarely Performance: Prevents recomposition on every scroll event
Visual pattern: Async operation → state updates → UI reflects changes Use for: Convert Flow, LiveData, callbacks into Compose state Lifecycle: Coroutine cancelled when composable leaves composition
For Kotlin-specific state patterns (StateFlow, sealed classes), see kotlin-expert.
Move state up to make composables reusable:
Principle: State up, events down
query: String (read-only parameter)onQueryChange: (String) -> Unit (callback parameter)Use @Immutable on data classes passed to composables:
Visual effect: Prevents recomposition when parent recomposes with same data
Pattern: Mark parameter data classes as @Immutable
Note: For Kotlin language details on @Immutable, see kotlin-expert
For @Stable annotation details, see kotlin-expert.
All shared composables use Material3 for consistency:
Principles:
MaterialTheme.colorScheme.*MaterialTheme.typography.*MaterialTheme.shapes.*Amethyst uses ImageVector for multiplatform icons.
Why ImageVector?
For detailed icon patterns, see references/icon-assets.md.
Components (all in commonsUI/commonMain):
LoadingState - Progress indicator + messageEmptyState - Empty message + optional refresh buttonErrorState - Error message + optional retry buttonVisual mapping:
Pattern: Generic composable + specific wrappers with preset text
Key principle: Use key parameter for stable item identity
RichTextParser, UrlParser, GalleryParser, Patterns, MediaContentModels; NIP-92 imeta enrichment| Task | Pattern | Location |
|---|---|---|
| Reusable UI | State hoisting | commonsUI/commonMain |
| Simple state | remember { mutableStateOf() } | Composable scope |
| Derived state | derivedStateOf { } | remember block |
| Async → state | produceState { } | Composable function |
| Custom icons | roboBuilder + PathData | commonsUI/icons |
| Loading/Error | LoadingState, ErrorState | commonsUI/ui/components |
| Theme colors | MaterialTheme.colorScheme | Any @Composable |
| Navigation | Delegate to platform expert | amethyst/, desktopApp/ |
commonsUI/src/commonMain/kotlin/.../ui/components/amethyst/ or desktopApp/commonsUI/commonMain with hoisted stateFor navigation patterns:
android-expertdesktop-expertdesktop-expert