Use this skill to migrate Compose UI from collectAsState() to collectAsStateWithLifecycle(), hoist Flow<T> parameters out of composables, and apply .conflate() / .distinctUntilChanged() / snapshotFlow so background CPU and battery stop draining and chatty flows stop invalidating the UI per emission. Covers ViewModel StateFlow/SharedFlow consumers, sensor and location streams, and the "Flow as composable parameter" antipattern. Trigger when the user mentions collectAsState, collectAsStateWithLifecycle, lifecycle-aware flow collection, Lifecycle.State.STARTED, background battery drain from a Compose screen, snapshotFlow, Flow parameter on a composable, conflate, or distinctUntilChanged.
$npx -y skills add skydoves/compose-performance-skills --skill collecting-flows-safelyInstalls into the current project.
Run `npx skills use "https://github.com/skydoves/compose-performance-skills" --skill "skydoves/compose-performance-skills/collecting-flows-safely"` and follow the generated skill instructions now. Read its complete output, redirecting it to a temporary file first if necessary. Resolve relative paths from the supporting-files directory it provides.
Use the skills in "https://github.com/skydoves/compose-performance-skills" that are relevant to the current task. Run `npx skills add "https://github.com/skydoves/compose-performance-skills"` and select the relevant skills, then follow their instructions.