Safe Database Migration Patterns
affaan-m/ECC
Rules and examples for safe, reversible schema changes in production: zero-downtime column and index changes, large data backfills and ORM migration workflows.
A skill your agent uses to migrate Compose UI from collectAsState() to collectAsStateWithLifecycle(), hoist Flow<T parameters out of composables, and apply .conflate() / .distinctUntilChanged() /…
$ npx skills add skydoves/compose-performance-skills --skill collecting-flows-safely -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install skydoves/compose-performance-skills collecting-flows-safely --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/skydoves/compose-performance-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/side-effects/collecting-flows-safely .claude/skills/collecting-flows-safely && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "collecting-flows-safely" agent skill from https://github.com/skydoves/compose-performance-skills/tree/main/side-effects/collecting-flows-safely into .claude/skills/collecting-flows-safely/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "collecting-flows-safely", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/skydoves/compose-performance-skills/tree/main/side-effects/collecting-flows-safelyType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add skydoves/compose-performance-skills --skill collecting-flows-safely -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install skydoves/compose-performance-skills collecting-flows-safely --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/skydoves/compose-performance-skills.git skills-src && mkdir -p .agents/skills && cp -r skills-src/side-effects/collecting-flows-safely .agents/skills/collecting-flows-safely && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "collecting-flows-safely" agent skill from https://github.com/skydoves/compose-performance-skills/tree/main/side-effects/collecting-flows-safely into .agents/skills/collecting-flows-safely/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "collecting-flows-safely", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add skydoves/compose-performance-skills --skill collecting-flows-safely -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install skydoves/compose-performance-skills collecting-flows-safely --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/skydoves/compose-performance-skills.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/side-effects/collecting-flows-safely .cursor/skills/collecting-flows-safely && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "collecting-flows-safely" agent skill from https://github.com/skydoves/compose-performance-skills/tree/main/side-effects/collecting-flows-safely into .cursor/skills/collecting-flows-safely/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "collecting-flows-safely", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/skydoves/compose-performance-skills.git --path side-effects/collecting-flows-safely--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add skydoves/compose-performance-skills --skill collecting-flows-safely -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install skydoves/compose-performance-skills collecting-flows-safely --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/skydoves/compose-performance-skills.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/side-effects/collecting-flows-safely .gemini/skills/collecting-flows-safely && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "collecting-flows-safely" agent skill from https://github.com/skydoves/compose-performance-skills/tree/main/side-effects/collecting-flows-safely into .gemini/skills/collecting-flows-safely/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "collecting-flows-safely", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install skydoves/compose-performance-skills collecting-flows-safelyInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add skydoves/compose-performance-skills --skill collecting-flows-safely -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/skydoves/compose-performance-skills.git skills-src && mkdir -p .github/skills && cp -r skills-src/side-effects/collecting-flows-safely .github/skills/collecting-flows-safely && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "collecting-flows-safely" agent skill from https://github.com/skydoves/compose-performance-skills/tree/main/side-effects/collecting-flows-safely into .github/skills/collecting-flows-safely/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "collecting-flows-safely", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add skydoves/compose-performance-skills --skill collecting-flows-safely -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install skydoves/compose-performance-skills collecting-flows-safely --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/skydoves/compose-performance-skills.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/side-effects/collecting-flows-safely .opencode/skills/collecting-flows-safely && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "collecting-flows-safely" agent skill from https://github.com/skydoves/compose-performance-skills/tree/main/side-effects/collecting-flows-safely into .opencode/skills/collecting-flows-safely/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "collecting-flows-safely", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
collecting-flows-safelyA skill your agent uses to migrate Compose UI from collectAsState() to collectAsStateWithLifecycle(), hoist Flow<T parameters out of composables, and apply .conflate() / .distinctUntilChanged() /…
Collecting Flows Safely is an agent skill from skydoves/compose-performance-skills. 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…
Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
The repository describes itself as: ⚡️ A curated library of Agent Skills focused on Jetpack Compose performance. The licence is Apache-2.0.
7 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit 1b32f81. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are kotlin).
From the folder's file list and the shell code blocks in SKILL.md.
Links to these hosts (documentation or services it may open):
medium.comdeveloper.android.comFrom URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Collecting Flows Safely loads about 3.1k tokens when it runs. Until then it costs about 186 tokens; SKILL.md has 913 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from skydoves/compose-performance-skills at commit 1b32f81, republished under its Apache-2.0 licence (© skydoves). 913 words, ~3,099 tokens.
.claude/skills/collecting-flows-safely/SKILL.md (or your agent's skills folder).collectAsState() keeps collecting whenever the composable is in composition, including while the app is backgrounded — that wastes CPU and battery. collectAsStateWithLifecycle() ties collection to a Lifecycle.State (default STARTED) so backgrounding pauses upstream work. For chatty flows, pair the consumer with .conflate() and .distinctUntilChanged() so Compose only sees meaningful changes. Skydoves hot take #4: a Flow<T> parameter on a composable is unstable and blocks skipping for the whole composable — collect at the caller and pass the resolved value.
ViewModel or Repository exposes StateFlow<T>, SharedFlow<T>, or a cold Flow<T> to a Compose screen.fun MyScreen(state: Flow<State>) (Flow-as-parameter antipattern).collectAsState vs collectAsStateWithLifecycle, or about Lifecycle.State.STARTED / RESUMED semantics.snapshotFlow.remember { ... } block — that is composition-internal state, prefer mutableStateOf directly. See ../using-efficient-effects/SKILL.md for choosing the right effect API.State<T> (e.g. mutableStateOf, Animatable.asState()) — do not wrap it in a flow just to call collectAsStateWithLifecycle().STOPPED. Move that work to a Service / WorkManager / repeatOnLifecycle in the Activity, not into Compose.androidx.lifecycle:lifecycle-runtime-compose (2.6+; the artifact that exposes collectAsStateWithLifecycle). Maven coordinates: androidx.lifecycle:lifecycle-runtime-compose:<version>.StateFlow, SharedFlow, conflate, distinctUntilChanged).../../recomposition/deferring-state-reads/SKILL.md if the high-frequency emissions are driving animation values — phase deferral may be a better fix than .conflate().collectAsState() call. Search the module for \.collectAsState\(. Replace each call with collectAsStateWithLifecycle() unless the producing flow is created inside the same composable scope.initialValue when the flow is not a StateFlow (cold Flow<T> or SharedFlow<T>). For StateFlow<T>, the overload reads .value — no initial value needed.minActiveState. Default STARTED matches the framework's repeatOnLifecycle default. Use RESUMED for widgets that should only collect while the Activity owns input focus (e.g. always-visible foreground HUD with an aggressive sensor source). Do not use CREATED — that defeats the purpose..conflate() upstream of collectAsStateWithLifecycle() so the consumer keeps only the latest value across a frame. If consecutive emissions can be value-equal, also add .distinctUntilChanged() — and ensure the emitted type has a correct equals().Flow<T> parameters out of composables. Replace fun Foo(prices: Flow<Price>) with fun Foo(price: Price). Collect at the caller. If the producer must stay private to the parent, expose a () -> Price lambda provider rather than the raw Flow.snapshotFlow { ... } inside a LaunchedEffect. That is the supported bridge from Compose's snapshot system to coroutine flows; combine with .distinctUntilChanged() to avoid spurious emissions.@TraceRecomposition (see ../../measurement/tracing-recompositions-at-runtime/SKILL.md) and a logcat sanity check with the app backgrounded — upstream emissions should stop.collectAsState with collectAsStateWithLifecycle// WRONG
import androidx.compose.runtime.collectAsState
@Composable
fun HomeScreen(viewModel: HomeViewModel) {
val state by viewModel.uiState.collectAsState()
HomeContent(state)
}
// WRONG because: collection continues while the app is backgrounded -> wasted CPU and battery,
// and any upstream operators (network polling, db queries) keep running.// RIGHT
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@Composable
fun HomeScreen(viewModel: HomeViewModel) {
val state by viewModel.uiState.collectAsStateWithLifecycle()
HomeContent(state)
}minActiveState for an always-visible widget// RIGHT
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@Composable
fun TopBar(viewModel: HomeViewModel) {
val state by viewModel.uiState.collectAsStateWithLifecycle(
minActiveState = Lifecycle.State.RESUMED,
)
TopBarContent(state)
}Flow<T> as a composable parameter (skydoves hot take #4)// WRONG
@Composable
fun PriceTicker(prices: Flow<Price>) {
val price by prices.collectAsState(initial = Price.ZERO)
Text(price.formatted)
}
// WRONG because: Flow is unstable -> blocks skipping for the whole composable; the collection
// lifecycle is also unclear (recreated on every recomposition unless the caller remembers it).// RIGHT
@Composable
fun PriceTicker(price: Price) {
Text(price.formatted)
}
// Caller collects once and passes the value:
@Composable
fun TickerScreen(viewModel: TickerViewModel) {
val price by viewModel.price.collectAsStateWithLifecycle()
PriceTicker(price)
}.conflate() + .distinctUntilChanged()// WRONG
@Composable
fun TiltIndicator(repository: SensorRepository) {
val tilt by repository.tilt.collectAsStateWithLifecycle(initialValue = 0f)
TiltUi(tilt)
}
// WRONG because: hundreds of emissions per second invalidate the consuming composable per emission;
// most are dropped frames worth of work.// RIGHT
@Composable
fun TiltIndicator(repository: SensorRepository) {
val flow = remember(repository) {
repository.tilt.conflate().distinctUntilChanged()
}
val tilt by flow.collectAsStateWithLifecycle(initialValue = 0f)
TiltUi(tilt)
}snapshotFlow// RIGHT
@Composable
fun FeedAnalytics(listState: LazyListState, analytics: Analytics) {
LaunchedEffect(listState, analytics) {
snapshotFlow { listState.firstVisibleItemIndex }
.distinctUntilChanged()
.collect { index -> analytics.logFirstVisibleIndex(index) }
}
}
// snapshotFlow bridges snapshot State to a cold Flow without paying the cost of recomposing
// every time firstVisibleItemIndex changes — the read happens inside the LaunchedEffect's coroutine,
// not in the composition phase.snapshotFlow over derivedStateOf for fire-and-forget reactions// LESS PREFERRED for an effect that only emits side effects
val isAtTop by remember { derivedStateOf { listState.firstVisibleItemIndex == 0 } }
LaunchedEffect(isAtTop) { if (isAtTop) reportTop() }// PREFERRED — no derived state slot in composition; reads happen in the coroutine
LaunchedEffect(listState) {
snapshotFlow { listState.firstVisibleItemIndex == 0 }
.distinctUntilChanged()
.filter { it }
.collect { reportTop() }
}collectAsStateWithLifecycle() (from androidx.lifecycle:lifecycle-runtime-compose) for any Flow that originates outside the composition (ViewModel, repository, sensor, network, websocket, location).Flow<T> as a composable parameter. Collect at the caller, pass the resolved T (or a () -> T lambda provider for very hot producers). Flow is unstable and blocks skipping for the entire composable..conflate() and/or .distinctUntilChanged() upstream of collectAsStateWithLifecycle() for any flow emitting more often than ~once per 100 ms. Ensure equals() is correct on the emitted type when using distinctUntilChanged.remember(key) when applying .conflate() / .distinctUntilChanged() inline, so a new chain is not created on every recomposition.Lifecycle.State.CREATED for minActiveState — it leaves collection running while the activity is invisible, defeating the migration.State<T> into a flow just to call collectAsStateWithLifecycle(). Keep the State direct.snapshotFlow { ... } over derivedStateOf { ... } when the only consumer is a fire-and-forget effect (analytics, logging, side-channel emit) instead of UI.grep -R "collectAsState(" src/ returns 0 hits, or each remaining hit collects a flow created inside the same composable.Repository log lines, sensor callbacks) stop within one frame and resume on foregrounding.@TraceRecomposition(traceStates = true) on the consuming composable shows one recomposition per meaningful emission, not per raw upstream emission. See ../../measurement/tracing-recompositions-at-runtime/SKILL.md.Flow<*> (grep -R ": Flow<" src/).minActiveState = RESUMED is used, the rationale (focus-required widget) is documented in code.repeatOnLifecycle): https://developer.android.com/topic/libraries/architecture/coroutinesandroidx.lifecycle:lifecycle-runtime-compose release notes: https://developer.android.com/jetpack/androidx/releases/lifecyclesnapshotFlow, LaunchedEffect): https://developer.android.com/develop/ui/compose/side-effects../using-efficient-effects/SKILL.md for LaunchedEffect / DisposableEffect / RememberedEffect selection.../../measurement/tracing-recompositions-at-runtime/SKILL.md for verifying emission counts at runtime.© skydoves, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in side-effects/collecting-flows-safely of skydoves/compose-performance-skills.
Open the folder on GitHubat commit 1b32f81
Collecting Flows Safely next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Collecting Flows Safely this skillskydoves/compose-performance-skills | 513 | — | ~3.1k | Automated safety check: Pass | Apache-2.0 | |
| Safe Database Migration Patternsaffaan-m/ECC | 276k | — | ~3.3k | Automated safety check: Pass | MIT | |
| Database Migrationsaffaan-m/ECC | 276k | 4 repos | ~3k | Automated safety check: Pass | MIT | |
| Reversible MigrationJuliusBrussee/caveman | 111k | 1 repos | ~196 | Automated safety check: Pass | Apache-2.0 | |
| Database Migrationsaffaan-m/ECC | 276k | 1 repos | ~2.4k | Automated safety check: Pass | MIT | |
| DB Migratesimstudioai/sim | 30k | — | ~2k | Automated safety check: Pass | Apache-2.0 |
affaan-m/ECC
Rules and examples for safe, reversible schema changes in production: zero-downtime column and index changes, large data backfills and ORM migration workflows.
affaan-m/ECC
Safe, reversible database migration patterns: forward-only production changes, expand-contract zero-downtime renames, concurrent indexes, batched backfills, and per-tool workflows for PostgreSQL…
JuliusBrussee/caveman
Implement reversible compatibility-safe transitions. Use for schema, data, API, protocol, configuration, or dependency migrations requiring rollback and…
affaan-m/ECC
Şema değişiklikleri, veri migration'ları, rollback'ler ve PostgreSQL, MySQL ve yaygın ORM'ler (Prisma, Drizzle, Django, TypeORM, golang-migrate) arasında sıfır kesinti deployment'ları için…
simstudioai/sim
Author or review a Drizzle DB migration for zero-downtime safety — expand/contract phasing, backward-compatibility with the deployed app version, and writing the -- migration-safe acknowledgment the…
lobehub/lobehub
Covers schema conventions and safe rollout for Drizzle database migrations: online indexes, backfills, idempotent SQL and fixing regeneration or rebase conflicts.
skydoves/compose-performance-skills
A skill your agent uses to decide when Jetpack Compose derivedStateOf is the right tool and when it is pure overhead.
A skill your agent uses to migrate Compose UI from collectAsState() to collectAsStateWithLifecycle(), hoist Flow<T parameters out of composables, and apply .conflate() / .distinctUntilChanged() /…. Collecting Flows Safely is an agent skill from skydoves/compose-performance-skills.distinctUntilChanged() / snapshotFlow so background CPU and battery stop draining and chatty flows stop invalidating the UI per emission.
Collecting Flows Safely fits situations like: migrate Compose UI from collectAsState() to collectAsStateWithLifecycle(); hoist Flow<T parameters out of composables; the user mentions collectAsState; collectAsStateWithLifecycle.
Run `npx skills add skydoves/compose-performance-skills --skill collecting-flows-safely -a claude-code`. Or copy the skill folder (side-effects/collecting-flows-safely in skydoves/compose-performance-skills) into .claude/skills/collecting-flows-safely in your project. Claude Code loads it when a task matches its description.
Run `npx skills add skydoves/compose-performance-skills --skill collecting-flows-safely -a codex`. Or copy the skill folder (side-effects/collecting-flows-safely in skydoves/compose-performance-skills) into .agents/skills/collecting-flows-safely in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add skydoves/compose-performance-skills --skill collecting-flows-safely -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/collecting-flows-safely, .gemini/skills/collecting-flows-safely, .github/skills/collecting-flows-safely and .opencode/skills/collecting-flows-safely in your project.
SKILL.md names no scripts, command-line tools or credentials: Collecting Flows Safely is instructions for the agent only.
SKILL.md names 2 domains. As links in the text: medium.com and developer.android.com. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Collecting Flows Safely is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.
About 3.1k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Collecting Flows Safely: Safe Database Migration Patterns (affaan-m/ECC, 276k stars), Database Migrations (affaan-m/ECC, 276k stars), Reversible Migration (JuliusBrussee/caveman, 111k stars) and Database Migrations (affaan-m/ECC, 276k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
skydoves (a GitHub user) maintains it in skydoves/compose-performance-skills, which has 513 GitHub stars. The repository holds 2 skills in this directory. The repository was last updated on June 16, 2026.
Source: skydoves/compose-performance-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.