Android state management

From krutikJain/android-agent-skills · View interactive version

Android state management is an AI agent skill from the GitHub repository krutikJain/android-agent-skills. Model screen state, events, reducers, and side effects for Android UIs with predictable lifecycle-aware ownership.

How to use this skill

Skill file

Android State Management

When To Use

Workflow

  1. Confirm the user-visible journey, target device behavior, and failure states that matter.
  2. Identify the owning screens, activities, destinations, and state holders for the flow.
  3. Implement the flow with explicit loading, success, empty, and error handling.
  4. Validate accessibility, configuration changes, and back-stack behavior in the showcase apps.
  5. Escalate data, architecture, or release concerns to the specialized skills called out in the handoff notes.

Guardrails

Anti-Patterns

Remediation Examples

Keep one immutable UI state surface

data class TaskBoardState(
    val tasks: List<TaskUiModel> = emptyList(),
    val isLoading: Boolean = false,
    val errorMessage: String? = null,
)

Separate persistent state from one-off events

private val _uiState = MutableStateFlow(TaskBoardState())
val uiState: StateFlow<TaskBoardState> = _uiState.asStateFlow()

private val _events = MutableSharedFlow<TaskBoardEvent>(replay = 0)
val events: SharedFlow<TaskBoardEvent> = _events

Reduce state updates instead of mutating UI directly

_uiState.update { state ->
    state.copy(isLoading = false, tasks = refreshedTasks, errorMessage = null)
}

Examples

Happy path

Edge case

Failure recovery

Done Checklist

Official References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.