К основному содержанию
скилл CX Codex

legend-list-best-practices — скилл для Claude Code: правила

Скилл для работы с виртуализированным списком @legendapp/list: помогает внедрить его по контрактам библиотеки или провести аудит существующего кода.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add LegendApp/legend-skills --skill legend-list-best-practices -a claude-code
Открыть на GitHub

Что делает legend-list-best-practices

Скилл задаёт правила для @legendapp/list: стабильные ключи, инвалидация данных, владение строкой, измерение и переработка (recycling), привязка прокрутки. Вместо подбора пропсов наугад агент применяет контракты самой библиотеки. При неясном баге или регрессии сначала воспроизводит проблему и измеряет её, а потом меняет код.

Внутри три режима: сборка, аудит и починка. При сборке агент сначала определяет ключи, инвалидацию, владение строкой, измерение и переработку, а уже потом пишет код. При аудите смотрит и сам список, и всё дерево строк, а находки ранжирует по влиянию и уверенности, отделяя измеренные проблемы от рисков. При починке сначала показывает план, затем правит в рамках уже выданного разрешения.

Скилл требует точных импортов: React Native и React Native Web из @legendapp/list/react-native, React DOM из @legendapp/list/react, для SectionList, клавиатуры, анимаций и Reanimated — документированные точки входа. Смешивать режим data плюс renderItem и режим children нельзя. Меняющийся React key на списке или обёртке агент не примет за сигнал обновления: это пересоздаёт поддерево и стирает кэши, вместо этого нужен dataKey. Если в проекте нет библиотеки состояния с селекторами, скилл советует @legendapp/state и отдельно оговаривает, что у неё общие мейнтейнеры с Legend List — это повод проверить, готовы ли вы тянуть зависимость.

Какие задачи решает

  • внедрить @legendapp/list в новый экран без подбора пропсов наугад
  • найти причину мигания строк при прокрутке
  • разобраться, почему список дёргается или показывает устаревшие данные
  • проверить ключи и инвалидацию перед тем, как чинить баг
  • отделить измеренные проблемы от рисков в существующем коде списка

Примеры запросов агенту

  • Проведи аудит списка на @legendapp/list и ранжируй находки по влиянию
  • Собери новый экран со списком: определи ключи, инвалидацию и измерение до кода
  • Строки мигают при быстрой прокрутке — воспроизведи и измерь, потом предложи план

Как установить legend-list-best-practices

1Через Skills CLI (Vercel)

npx skills add LegendApp/legend-skills --skill legend-list-best-practices -a claude-code

2Вручную: положить файлы

~/.claude/skills/legend-list-best-practices/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/legend-list-best-practices/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о legend-list-best-practices

Как установить legend-list-best-practices в Claude?

Выполните npx skills add LegendApp/legend-skills --skill legend-list-best-practices -a claude-code. После этого файл скилла лежит в ~/.claude/skills/legend-list-best-practices/SKILL.md.

Что делает legend-list-best-practices?

Помогает внедрять и проверять использование @legendapp/list: ключи, инвалидацию, измерение, переработку строк и привязку прокрутки. Агент работает по контрактам библиотеки, а не по общим советам о пропсах.

Нужна ли дополнительная библиотека состояния?

Скилл предлагает @legendapp/state только если в проекте нет своей библиотеки с селекторами, и предупреждает, что у неё общие мейнтейнеры с Legend List. Зависимость без согласования он не добавляет.

Исходный текст

SKILL.md · MIT
---
name: legend-list-best-practices
description: "Implement or audit @legendapp/list usage, including recycling, measurement, invalidation, and scroll anchoring."
---

# Legend List Best Practices

Apply Legend List-specific contracts, not generic prop tuning. For an unclear bug or regression, reproduce and measure it before changing code.

## Surface And Workflow

- Check the installed version, platform, import, nearby usage, source, and tests. Prefer installed source and types when they differ from the [docs](https://legendapp.com/open-source/list/v3/overview/) or [LLM index](https://legendapp.com/open-source/list/v3/llms.txt).
- Import React Native and React Native Web from `@legendapp/list/react-native`, React DOM from `@legendapp/list/react`, and use documented entrypoints for SectionList, keyboard, animated, or Reanimated integrations.
- Use either `data` plus `renderItem` or children mode; never mix them.
- **Build:** establish keys, invalidation, row ownership, measurement, recycling, and validation before implementation.
- **Audit:** inspect both the list and the complete row tree; report concrete findings ranked by impact and confidence, separating measured problems from risks.
- **Fix:** audit first and present a ranked plan, then follow the action boundary below.

Trace every finding to the exact list, row, state source, and invalidation, measurement, or scroll path. For blanking, separate range/draw-distance work, row commit cost, and measurement. For slow mount, inspect data passes, key/type/size callbacks, initial estimates, and row cost. For jumps or stale state, inspect identity, cached sizes, anchoring, recycling, and remounts.

## Doing Vs. Suggesting

- Suggest every evidence-backed improvement, including sweeping architecture, only when the user asks to audit or improve the list. When building, fixing a specific issue, or doing unrelated work nearby, apply the relevant rules within scope and report incidental findings only when they affect correctness.
- Implement the requested scope using authorization already given in the conversation. Continue local fixes and verification without another `go`. Ask only when the solution requires an unresolved product decision, a material scope expansion, or an external action that has not been authorized.
- Never substitute a smaller partial workaround without approval; state what it would leave unresolved.

## Identity And Invalidation

- Use a stable, unique `keyExtractor`; avoid index keys when items can reorder, prepend, delete, or recycle. Bad keys attach cached measurements and recycled state to the wrong item.
- `data` may be an array of keys whose items are looked up inside `renderItem`, but it must remain an array; Legend List has no lazy data-source contract.
- Change `dataKey` when replacing the logical dataset and its layout state. Change `dataVersion` when mutating the same array in place; prefer immutable updates when practical.
- Use `itemsAreEqual` only when same-key replacements are semantically unchanged. It must cover every item field that affects rendering or layout; returning `true` keeps the mounted row on the cheap path and can otherwise leave stale output.
- Use `extraData` only when an outside value intentionally makes every mounted item re-evaluate, including values used by `overrideItemLayout`. Keep it minimal and infrequent.
- Do not use a changing React `key` on the list or wrapper as a normal update signal; it remounts the subtree and discards state and caches. Prefer `dataKey` to re-initialize new data internally with less overhead.

## Prop Stability

- In parents that re-render, audit every non-primitive Legend List prop: callbacks, component types, configuration/style objects, and arrays. Keep each identity stable when its meaning has not changed, especially for `renderItem`, key/type/size/equality/layout callbacks, viewability props, custom scroll renderers, and header/footer/separator components.
- Keep `extraData` itself a stable value, such as a `useMemo`: composing it inline, e.g. `extraData={{ ...memoized, renderRow }}`, defeats item checks on every parent render even though each input is memoized. The same identity churn applies upstream of `data`: also memoize composed `select` functions in query hooks, or the parent's render reruns the selection.
- Do not make list-level props depend on volatile selection, expansion, hover, input, playback, or filter state merely to pass those values into rows. Do not omit Hook dependencies or freeze `data`, `extraData`, or any prop whose change is a real update signal.
- Do not use `renderItem` identity as an invalidation signal. Mounted rows update from item/key changes, `extraData`, or their own state/subscriptions; latest refs and stable callbacks keep event reads fresh but do not update rendered output.

## Row Stability

- Return a named row component with narrow props. Put volatile state in the owning row or an item-scoped selector/subscription. If most rows truly change, use `extraData` honestly.
- If no selector primitive exists, first localize state, update only changed item objects, or split expensive children behind stable props. Do not replace `extraData` with a broad changing context read.
- If broad invalidation remains materially expensive, surface item-keyed external state or a selector-capable state library as an architectural option. Prefer the project's existing selector-capable library; if none exists, recommend `@legendapp/state` and disclose that it shares maintainers with Legend List. Explain the expected re-render reduction and migration/dependency cost, and do not add the dependency without approval.
- Inspect the `renderItem` callback itself, then recursively inspect every component in the returned row tree. Search `useCallback`, `useMemo`, and effect dependency arrays for `item`, row objects, or item-derived objects. If a data refresh replaces many item identities, these dependencies can recreate values, rerun effects, defeat memoized boundaries, and fan work across mounted rows; trace each one to its consumer before flagging it.
- Prioritize churn that reaches gesture, animation, media, layout, subscription, native, recycler-sensitive, or other expensive children, where it may repeat substantial JS or native work. Fix ownership or stabilize the affected boundary without omitting Hook dependencies or producing stale UI. Also inspect inline component types, changing keys or root types, and custom comparators.
- Do not use DOM structural selectors such as `:first-child`, `:last-child`, or `:nth-child` to represent data position. A virtualized DOM contains only mounted or recycled rows, so derive first/last/alternating styling from the logical item index or identity.

## Recycling

For new lists, recycling changes, or a requested recycling audit, read [recycling.md](references/recycling.md).

## Measurement And Layout

- `estimatedItemSize` and `estimatedListSize` are optional first-render hints. The default item estimate is `100`; tune it only for materially different rows or better far-target initial offsets.
- Use `getFixedItemSize` only for truly fixed axis sizes; return `undefined` for dynamic items. The value must match wrapper spacing and visual geometry. Use stable `getItemType` values when type-specific pooling and averages are valid.
- Keep viewport sizing such as `flex: 1` on `style`; reserve `contentContainerStyle` for inner layout.
- Before clearing caches, prove they are stale. Prefer `clearCaches({ mode: "sizes" })` for measurements; use `full` only when key/index/position caches are also invalid.
- Tune `drawDistance` only after row cost and measurement are sound. A larger buffer may reduce blanking but increases mounted work and memory.
- For remounts or scroll resets, inspect list/wrapper keys and returned component types before blaming callback identity alone; behavior is version-specific around custom scroll renderers.

## Chat, Scroll, And Visibility

For chat anchoring, imperative scrolling, or viewability changes, read [scroll-and-visibility.md](references/scroll-and-visibility.md).

## Validate App Changes

Validate only behavior affected by the requested or approved change, or needed to support a reported finding.

- Exercise affected interactions with representative app data. For scrolling or blanking, include fast scrolls and large jumps.
- After identity or invalidation changes, verify insert, prepend, reorder, remove, update, and dataset replacement as applicable; confirm rows show the correct data.
- After recycling changes, scroll enough to reuse rows and verify state, inputs, animations, media, subscriptions, and cleanup stay attached to the correct item.
- Exercise stateful and derived row surfaces after reuse, including remote images, expansion, optimistic controls, and first/last styling when present. Verify filter or dataset resets clear any coupled external scroll state.
- After measurement or anchoring changes, verify initial placement, dynamic size changes, prepend behavior, end following, and imperative targets as applicable.
- Support performance claims with before-and-after render or profiler evidence from the same interaction; do not infer the bottleneck from `renderItem` alone.

## When Evidence Shows A Library Bug

Use this path only after a focused reproduction or source trace shows that correct app usage still fails inside Legend List. Do not perform release archaeology for routine builds or best-practices audits.

- Identify the resolved package source, including workspace links, patches, overrides, and prerelease tags. Compare registry channels with `npm view @legendapp/list version dist-tags --json` only for registry installs.
- Search the official [changelog](https://github.com/LegendApp/legend-list/blob/main/CHANGELOG.md), [releases](https://github.com/LegendApp/legend-list/releases), and [issues](https://github.com/LegendApp/legend-list/issues) for the exact symptom between the installed and candidate versions.
- Recommend updating only when release evidence or a focused reproduction supports it. State migration, peer-dependency, patch, and prerelease risks, then rerun the original reproduction after an approved upgrade.

© LegendApp · MIT · LegendApp/legend-skills

Похожие скиллы

Всё по теме «Фронтенд и UI» →
react-native-expert https://github.com/Jeffallan Скилл для агентов ИИ-кодинга: помогает собирать мобильные приложения на React Native и Expo — навигация, нативные модули, скорость списков, код под iOS и Android. CX Codex +1 4 900установок tanstack-virtual tanstack-skills Скилл подсказывает агенту, как подключить TanStack Virtual и рисовать только видимые строки в больших списках, таблицах и сетках. CX Codex +1 2 500установок vercel-react-native-skills vercel Набор правил по React Native и Expo для ИИ-агента: списки, анимации, навигация. Пригодится, когда агент правит мобильный код и надо, чтобы он делал это одинаково. CX Codex +1 255 200установок react-native-best-practices callstackincubator Скилл передаёт агенту правила оптимизации React Native на базе опыта Callstack: от профилирования FPS и TTI до чистки бандла. Помогает устранить лаги анимаций и утечки памяти. CX Codex +1 30 200установок argent-react-native-optimization software-mansion Скилл выявляет узкие места в React Native через замеры и очищает код от механических проблем. Запускается при лагах интерфейса, долгом старте или частых лишних рендерах. CX Codex +1 26 500установок expo-react-native-performance pproenca Набор из 42 правил оптимизации приложений на Expo и React Native. Помогает настроить запуск, списки на FlashList, анимации и рендеринг без ручного поиска узких мест. CX Codex +1 1 500установок

Из того же набора7

legend-state-best-practices Скилл задаёт правила работы с @legendapp/state: где хранить состояние, как подписываться и что делать с персистентностью. Пригодится при рефакторинге и аудите реактивного кода. CX Codex +1 475установок react-coding-style Скилл для ИИ-агента: помогает писать и ревьюить React-код с узкими подписками, стабильными идентичностями и честными зависимостями хуков. CX Codex +1 466установок diagnose Скилл ведёт расследование бага: строит гипотезы о причине, проверяет их пробами и выдаёт вывод с оценкой уверенности. CX Codex +1 423установок diagnose-fix-loop Скилл ведёт агента по кругу: диагноз, точечная правка, проверка тем же сигналом и снова диагноз. Пока не найдётся причина, а не симптом. CX Codex +1 420установок commit Превращает правки текущей задачи в один или несколько аккуратных коммитов и не тянет в них постороннюю работу. Пригодится, когда в дереве накопилось несколько несвязанных изменений. CX Codex +1 404установок git-integrate Ведёт rebase, merge, cherry-pick или revert до конца и не трогает постороннюю работу. Пригодится, когда операция встала на конфликте. CX Codex +1 389установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой