mcpbeat

Android Legacy State

hoangnguyen0403/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.

1k tokens
context cost
the whole folder, loaded on every use
3
files
instructions only
0
copies elsewhere
how many repositories repackaged it
536
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/HoangNguyen0403/agent-skills-standard --skill android-legacy-state

What comes with it

3 896 bytes besides the instruction
evals/evals.json
references/implementation.md

The instruction itself

7 sections, as written by the author

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

How to use it

Copy the folder

Take hoangnguyen0403/android-legacy-state from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.