Skip to content
Back to skills

Legacy State

ASecurity

Standards for State integration with Views using Coroutines and Lifecycle

  • 666 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 9, 2026
documentation

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill legacy-state --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Legacy State?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Legacy State
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-legacy-state/badge)](https://www.skillsdirectory.com/skills/majiayu000-legacy-state)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: Android Legacy State
description: Standards for State integration with Views using Coroutines and Lifecycle
metadata:
  labels: [android, state, views, lifecycle]
  triggers:
    files: ['**/*Fragment.kt', '**/*Activity.kt']
    keywords: ['repeatOnLifecycle', 'launchWhenStarted']
---

# Android Legacy State Standards

## **Priority: P1**

## Implementation Guidelines

### Flow Consumption

- **Rule**: ALWAYS use `repeatOnLifecycle(Lifecycle.State.STARTED)` to collect flows in Views.
- **Why**: Prevents crashes (collecting while view is 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

- **launchWhenX**: `**Deprecated**: Use repeatOnLifecycle.`
- **observe(this)**: `**Leak Risk**: Use viewLifecycleOwner in Fragments.`

## References

- [Flow Consumption Template](references/implementation.md)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.