Android Viewmodel
Best-practice guide for Android ViewModels using Kotlin explicit backing fields, StateFlow state, and SharedFlow events.
- CCM score
- 63 of 100
- skills.sh installs
- 602
- GitHub stars
- 1K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers UI state modeling, updating, and collection in both Compose and the XML/View system
- Includes a StateFlow pattern for persistent screen state and a SharedFlow pattern for transient events like navigation and snackbars
- Enforces immutable exposed APIs,
update {}for state changes, and noStateFlowfor navigation events - Designed for Kotlin 2.4+ projects, with a fallback note for Kotlin 2.3 experimental explicit backing fields
Install
$ npx -y skills add new-silvermoon/awesome-android-agent-skills --skill android-viewmodel -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Android ViewModel & State Management
Instructions
Use ViewModel to own UI state and business logic. It should survive configuration changes and expose immutable APIs.
Kotlin 2.3+
Prefer Explicit Backing Fields instead of the traditional
_state/statebacking property pattern.
- Kotlin 2.3: Experimental (
-Xexplicit-backing-fields)- Kotlin 2.4+: Stable (recommended)
Avoid creating duplicate backing properties unless targeting older Kotlin versions.
1. UI State (StateFlow)
Purpose
Represents the persistent UI state.
Examples:
- Loading
- Success(data)
- Error(message)
- Empty
Declaration
Use an explicit backing field.
val uiState: StateFlow<UiState>
field = MutableStateFlow(UiState.Loading)
The backing field is mutable (MutableStateFlow) while consumers only see StateFlow.
Updating State
Prefer update { } for atomic updates.
_uiState.update { old ->
old.copy(isLoading = false)
}
With explicit backing fields:
uiState.update {
it.copy(isLoading = false)
}
You may also assign directly when appropriate.
Details
- Repository
- github.com/new-silvermoon/awesome-android-agent-skills
- Category
- Mobile Apps
- First seen
- Jun 3, 2026
Questions
What does the android-viewmodel skill do?
The android-viewmodel skill gives an AI coding agent best practices for building Android ViewModels with Kotlin 2.3+ Explicit Backing Fields, StateFlow for UI state, and SharedFlow for one-off events. It guides the agent to keep business logic out of Composables and to expose only immutable APIs.
How do I install the android-viewmodel skill?
Run npx -y skills add new-silvermoon/awesome-android-agent-skills --skill android-viewmodel -y in your project. After that, android-viewmodel lets your agent follow these ViewModel and state management patterns when it works on Android code.
Which skills does android-viewmodel sit alongside in Mobile Apps?
android-viewmodel is listed under Mobile Apps on Claude Marketplaces, next to vercel-react-native-skills and animate-expo. Where android-viewmodel differs is its focus on Android ViewModel state handling with StateFlow and SharedFlow rather than cross-platform or Swift work.
Who is android-viewmodel for?
android-viewmodel is for Android developers who want an agent to structure ViewModels around a single immutable UI state object. It also suits teams that collect one-off events like navigation or snackbars in Jetpack Compose or the XML view system.
More from new-silvermoon/awesome-android-agent-skills
All 17- Android Coroutines600
- Android Data Layer553
- Android Retrofit517
- Coil Compose488
- Xml To Compose Migration468
- Compose Navigation436
- Rxjava To Coroutines Migration364
- Android Testing898
- Gradle Build Performance835
- Compose Ui796
- Android Gradle Logic763
- Android Architecture732
- Kotlin Concurrency Expert709
- Compose Performance Audit624
- Android Accessibility607
- Android Emulator Skill606
Similar to Android Viewmodel
More Mobile Appsandroid-developmentmindrally/skills843 installsOpinionated Kotlin guidelines for Android apps covering clean architecture, MVI state handling, and Material 3 UI.
android-kotlinalinaqi/maggy3.4K installsKotlin Android development guide covering Coroutines, Jetpack Compose, Hilt, Room, and MockK testing patterns.
compose-uinew-silvermoon/awesome-android-agent-skills796 installsBest practices for Jetpack Compose UI covering state hoisting, recomposition performance, and theming.
android-kotlin-developmentaj-geddes/useful-ai-prompts1.5K installsNative Android app guidance in Kotlin covering MVVM with Jetpack, Compose UI, and Retrofit and Room integration.
android-jetpack-composethebushidocollective/han2.3K installsGuidance for building declarative Android UIs with Jetpack Compose and state management.
compose-multiplatform-patternsaffaan-m/ecc12.2K installsPatterns for shared Compose UI covering state, navigation, theming, and recomposition performance.