Skip to content
Development
Skill

/android-legacy-state

Integrate ViewModel state with XML Views using Coroutines and Lifecycle on Android. Use when managing state with repeatOnLifecycle or lifecycle-aware coroutines in Fragment/Activity; defer Compose state and generic Flow design to their specific skills.

From plugin
agent-skills-standard
538200 skills1 MCP
Install
$ npx -y skills add hoangnguyen0403/agent-skills-standard --skill android-legacy-state --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/android-legacy-state

Context preview

The summary Claude sees to decide when to auto-load this skill.

Integrate ViewModel state with XML Views using Coroutines and Lifecycle on Android. Use when managing state with repeatOnLifecycle or lifecycle-aware coroutines in Fragment/Activity; defer Compose state and generic Flow design to their specific skills.

SKILL.md

android-legacy-state.SKILL.md
name: android-legacy-state
description: Integrate ViewModel state with XML Views using Coroutines and Lifecycle on Android. Use when managing state with repeatOnLifecycle or lifecycle-aware coroutines in Fragment/Activity; defer Compose state and generic Flow design to their specific skills.
metadata:
  triggers:
    files:
    - '**/*Fragment.kt'
    - '**/*Activity.kt'
    keywords:
    - repeatOnLifecycle
    - launchWhenStarted

Android Legacy State Standards

**Priority: P1 (HIGH)**

Implementation Guidelines

Flow Consumption

  • **Rule**: ALWAYS use `repeatOnLifecycle(Lifecycle.State.STARTED)` to collect flows in Views.
  • **Why**: Prevents crashes (collecting while view destroyed) and saves resources (stops collecting in background).

LiveData vs Flow

  • **New Code**: Use `StateFlow` exclusively.
  • **Legacy**: If using LiveData, observe with `viewLifecycleOwner` (Fragment), NOT `this`.

Anti-Patterns

  • **No launchWhenStarted/Resumed**: Deprecated. Use repeatOnLifecycle instead.
  • **No observe(this) in Fragments**: Use viewLifecycleOwner to prevent lifecycle leaks.

References

  • [Flow Consumption Template](references/implementation.md)
Ships withagent-skills-standard

The portable SDLC standards layer for AI coding agents. Sync once, then work in your own runtime.

Get the whole plugin

Other skills on agent-skills-standard.