android-state
Configure ViewModel state emission with StateFlow, SharedFlow, and sealed UiState classes in Android. Use for state modeling and sharing policies; defer generic lifecycle collection, navigation-event plumbing, Hilt injection, test code, and configuration-change recipes to their specific skills.
- 0
- Installs
- —
- Rating
- —
- Success rate
- 3
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 c5174f51c7903dba… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
Android State Management
Priority: P0 (CRITICAL)
1. Structure ViewModel
- Expose ONE
StateFlow<UiState>via.asStateFlow(). - Use
viewModelScopefor all coroutines. - Trigger initial load in
initblock.
See templates for ViewModel and UiState examples.
2. Define UI State (LCE Pattern)
- Use sealed interface with Loading, Content, Error variants.
- Mark data classes
@Immutable.
See templates for sealed UiState pattern.
3. Collect State Lifecycle-Safely
- Use
collectAsStateWithLifecycle()in Compose. - Use
SharingStarted.WhileSubscribed(5000)for shared resources.
Anti-Patterns
- No LiveData for New Code: Use StateFlow — lifecycle-safe and Compose-compatible.
- No Public MutableStateFlow: Expose only
.asStateFlow()to consumers. - No Context in ViewModel: Leaks Activity. Use Application context if truly needed.
Verification
- Each ViewModel exposes exactly one
StateFlow<UiState>. - UiState is a sealed interface with Loading, Content, Error variants.
- UI collects with
collectAsStateWithLifecycle(). -
./gradlew testpasses for ViewModel tests.
References
Files
3- SKILL.md
03d18ac7ea1.8 KB - evals/evals.json
e65a8c84583.1 KB - references/implementation.md
313eea1dd81.8 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from HoangNguyen0403/agent-skills-standard8
Upgrade an Android project to Android Gradle Plugin (AGP) 9. Use when migrating to AGP 9, updating Gradle build files, migrating to built-in Kotlin, or adopting the new AGP DSL.
Apply Clean Architecture layering, modularization, and Unidirectional Data Flow in Android projects. Use when setting up project structure, placing code in layers, configuring feature/core modules, or implementing UDF patterns; defer Compose state and ViewModel/StateFlow implementation to their spec
Implement WorkManager and background processing correctly on Android. Use when creating Worker classes, scheduling tasks, choosing between WorkManager and Foreground Services, or setting up Hilt in workers; defer FCM and notification delivery to android-notifications.
Build high-performance declarative UI with Jetpack Compose. Use when writing Composable functions, optimizing recomposition, hoisting state, or working with LazyColumn and side effects; defer deep-link and navigation routing to android-navigation.
Migrate an Android XML View to Jetpack Compose following a structured 10-step workflow. Use when converting XML layouts to Compose, setting up Compose in an existing View-based project, or incrementally adopting Compose.
Write correct coroutine scopes, lifecycle collection, and dispatcher injection in Android production code. Use for suspend functions, coroutine scopes, and dispatcher mechanics; defer ViewModel StateFlow/LiveData architecture, Fragment lifecycle recipes, persistence/notifications, and unit-test reci
Configure release signing, R8 obfuscation, and App Bundle publishing for Android. Use when setting up signing configs, enabling minification, adding ProGuard keep rules, or preparing for Play Store submission.
Enforce Material Design 3 theming and design token usage in Jetpack Compose. Use when implementing M3 components, color schemes, typography, or design tokens.
Related mobile skillsscan passed
JetBrains Exposed ORM patterns including DSL queries, DAO pattern, transactions, HikariCP connection pooling, Flyway migrations, and repository pattern. Use when working with the Exposed ORM — DSL or DAO queries, transactions, pooling, or migrations.
Autonomous iOS bug fixer. (gstack)
Test iOS apps in a simulator with XcodeBuildMCP. Use when iOS changes need simulator evidence before handoff.
PostHog integration for Swift iOS and macOS applications
Manages Firebase Remote Config templates, feature flags, loading strategies, and SDKs (Android, iOS). Use when downloading/deploying remoteconfig JSON templates, managing version history/feature flags, setting in-app defaults, fetchAndActivate(), real-time listeners, or SDK setup. Don't use for Fire
AWS SDK for Swift development patterns. Use when writing Swift code that uses AWS services via aws-sdk-swift package.