# Configuring Lazy Prefetch

Use this skill to tune Jetpack Compose lazy-layout prefetch with LazyLayoutCacheWindow...

- Repository: https://github.com/skydoves/compose-performance-skills (524 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-06-16
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add skydoves/compose-performance-skills --skill configuring-lazy-prefetch -g -a claude-code -y`
Codex: `npx skills add skydoves/compose-performance-skills --skill configuring-lazy-prefetch -g -a codex -y`
Cursor: `npx skills add skydoves/compose-performance-skills --skill configuring-lazy-prefetch -g -a cursor -y`
Gemini CLI: `npx skills add skydoves/compose-performance-skills --skill configuring-lazy-prefetch -g -a gemini-cli -y`

## Description

Use this skill to tune Jetpack Compose lazy-layout prefetch with LazyLayoutCacheWindow (Compose Foundation 1.9+, @ExperimentalFoundationApi) and pausable composition in prefetch (Compose Foundation 1.10+, default on). Covers configurable Dp-based ahead/behind cache windows plumbed through rememberLazyListState(cacheWindow = ...), NestedPrefetchScope for items containing inner lazy layouts (HorizontalPager inside a LazyColumn row), version requirements, and the trade-off between memory pressure and idle-frame work. Use when the developer mentions dropped frames at high scroll velocity, prefetch window, ahead/behind extents, LazyLayoutCacheWindow, NestedPrefetchScope, pausable composition for prefetch, or wants composition retained for items briefly scrolled past. Item-level fixes (keys, contentType) live in a sibling skill.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Configuring Lazy Prefetch, Cache Window and Pausable Composition

Lazy layouts pre-compose items just outside the viewport so they're ready when the user scrolls. Compose Foundation 1.9 added `LazyLayoutCacheWindow` for configurable ahead/behind extents. Compose Foundation 1.10 made prefetch composition pausable by default, work spreads across multiple frames instead of one. Most apps still rely on legacy single-frame prefetch and unknowingly pay for it during heavy scrolling. This skill teaches Claude when (and only when) to widen the window or implement nested prefetch, and how to validate the change with Macrobenchmark.

## When to use this skill

- Macrobenchmark `FrameTimingMetric` shows dropped frames at high scroll velocity even though item composables are skippable.
- Items are content-heavy: large images, decoded videos, nested grids, or expensive measurement work.
- The developer wants composition retained for items the user scrolled past briefly (e.g. flick-back gesture).
- An outer lazy layout contains items with their own inner lazy layouts (e.g. `LazyColumn` rows that each host a `HorizontalPager` or inner `LazyRow`).
- The developer mentions `LazyLayoutCacheWindow`, `NestedPrefetchScope`, "prefetch window", "ahead extent", or "pausable composition for prefetch".

## When NOT to use this skill

The rest: https://github.com/skydoves/compose-performance-skills/blob/HEAD/lists/configuring-lazy-prefetch/SKILL.md
