android-state
Standards for ViewModel, StateFlow, and UI State Patterns. Use whenever someone works with ViewModel files, asks about UiState sealed classes, MutableStateFlow vs LiveData, collectAsStateWithLifecycle, viewModelScope, or exposing state from Android ViewModels — even indirectly. (triggers: **/*ViewModel.kt, **/*UiState.kt, viewmodel, stateflow, livedata, uistate, MutableStateFlow, collectAsState, viewModelScope, UiState)
Best use case
android-state is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Standards for ViewModel, StateFlow, and UI State Patterns. Use whenever someone works with ViewModel files, asks about UiState sealed classes, MutableStateFlow vs LiveData, collectAsStateWithLifecycle, viewModelScope, or exposing state from Android ViewModels — even indirectly. (triggers: **/*ViewModel.kt, **/*UiState.kt, viewmodel, stateflow, livedata, uistate, MutableStateFlow, collectAsState, viewModelScope, UiState)
Teams using android-state should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/android-state/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How android-state Compares
| Feature / Agent | android-state | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Standards for ViewModel, StateFlow, and UI State Patterns. Use whenever someone works with ViewModel files, asks about UiState sealed classes, MutableStateFlow vs LiveData, collectAsStateWithLifecycle, viewModelScope, or exposing state from Android ViewModels — even indirectly. (triggers: **/*ViewModel.kt, **/*UiState.kt, viewmodel, stateflow, livedata, uistate, MutableStateFlow, collectAsState, viewModelScope, UiState)
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Android State Management ## **Priority: P0** ## Implementation Guidelines ### ViewModel Pattern - **Exposure**: Expose ONE `StateFlow<UiState>` via `.asStateFlow()`. - **Scope**: Use `viewModelScope` for all coroutines. - **Initialization**: Trigger initial load in `init` or `LaunchedEffect` (once). ### UI State (LCE) - **Type**: sealed interface `UiState` (Loading, Content, Error). - **Immutability**: Data classes inside should be `@Immutable`. ### Flow Lifecycle - **Collection**: Use `collectAsStateWithLifecycle()` in Compose. - **Hot Flows**: 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. ## References - [Templates](references/implementation.md)
Related Skills
terraform-state-manager
Terraform State Manager - Auto-activating skill for DevOps Advanced. Triggers on: terraform state manager, terraform state manager Part of the DevOps Advanced skill category.
mermaid-state-diagram-creator
Mermaid State Diagram Creator - Auto-activating skill for Visual Content. Triggers on: mermaid state diagram creator, mermaid state diagram creator Part of the Visual Content skill category.
mobile-android-design
Master Material Design 3 and Jetpack Compose patterns for building native Android apps. Use when designing Android interfaces, implementing Compose UI, or following Google's Material Design guidelines.
android-jetpack-compose-expert
Expert guidance for building modern Android UIs with Jetpack Compose, covering state management, navigation, performance, and Material Design 3.
bdi-mental-states
This skill should be used when the user asks to "model agent mental states", "implement BDI architecture", "create belief-desire-intention models", "transform RDF to beliefs", "build cognitive agent", or mentions BDI ontology, mental state modeling, rational agency, or neuro-symbolic AI integration.
rn-state-flows
Complex multi-step operations in React Native. Use when implementing flows with multiple async steps, state machine patterns, or debugging flow ordering issues.
react-state-flows
Complex multi-step operations in React. Use when implementing flows with multiple async steps, state machine patterns, or debugging flow ordering issues. Works for both React web and React Native.
state-management
TanStack Query + Zustand patterns.
analyzing-financial-statements
This skill calculates key financial ratios and metrics from financial statement data for investment analysis
android-clean-architecture
Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns.
XState
## Overview
Restate
## Overview