list-performance-item-types — Claude Code rule for lists
list-performance-item-types is a Claude Code rule for lists with mixed layouts. It guides the agent to assign item types and keep unlike cells in separate recycling pools.
MIT ★ 1,216 updated 2026-10-24
/plugin marketplace add fcakyon/claude-codex-settings
/plugin install react-skills@claude-settingsWhat list-performance-item-types does
The rule recommends adding a type field to each item and passing that value to LegendList through getItemType. Headers, messages, and images can then use separate components. Cells of one type share a recycling pool, so a header is not reused as an image cell.
The TypeScript example combines the item shapes in FeedItem and selects a component with switch. A getEstimatedItemSize callback can return a different size estimate for each itemType. The pattern is specifically for LegendList and relies on a type field in the list data.
What it helps with
- separate recycling pools for cells with different layouts
- prevent a header cell from being reused for an image
- narrow item types in TypeScript
switchbranches - estimate cell size by item type
Example prompts for the agent
- Update the
LegendListfeed so messages and images use separate recycling pools. - Refactor
Feedto useheader,message, andimageitem types. - Add per-type size estimates with
getEstimatedItemSize.
How to install list-performance-item-types
1Plugin marketplace
/plugin marketplace add fcakyon/claude-codex-settings/plugin install react-skills@claude-settings2Manually: put the files in place
.claude/rules/list-performance-item-types.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/list-performance-item-types.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/list-performance-item-types.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/list-performance-item-types.mdManually: put the files in place
.clinerules/list-performance-item-types.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about list-performance-item-types
How do I install list-performance-item-types in Claude Code?
Run /plugin marketplace add fcakyon/claude-codex-settings, then /plugin install react-skills@claude-settings. The rule file is also available at .claude/rules/list-performance-item-types.md.
What does list-performance-item-types do?
It explains how to assign types to items in a mixed-layout list and pass them to getItemType. LegendList then keeps different item types in separate recycling pools.
How can I estimate sizes for different item types?
Provide a getEstimatedItemSize callback and return an estimate based on itemType, such as separate estimates for headers, messages, and images.
Source text
list-performance-item-types.md · MIT
---
title: Use Item Types for Heterogeneous Lists
impact: HIGH
impactDescription: efficient recycling, less layout thrashing
tags: list, performance, recycling, heterogeneous, LegendList
---
## Use Item Types for Heterogeneous Lists
When a list has different item layouts (messages, images, headers, etc.), use a
`type` field on each item and provide `getItemType` to the list. This puts items
into separate recycling pools so a message component never gets recycled into an
image component.
**Incorrect (single component with conditionals):**
```tsx
type Item = { id: string; text?: string; imageUrl?: string; isHeader?: boolean }
function ListItem({ item }: { item: Item }) {
if (item.isHeader) {
return <HeaderItem title={item.text} />
}
if (item.imageUrl) {
return <ImageItem url={item.imageUrl} />
}
return <MessageItem text={item.text} />
}
function Feed({ items }: { items: Item[] }) {
return (
<LegendList
data={items}
renderItem={({ item }) => <ListItem item={item} />}
recycleItems
/>
)
}
```
**Correct (typed items with separate components):**
```tsx
type HeaderItem = { id: string; type: 'header'; title: string }
type MessageItem = { id: string; type: 'message'; text: string }
type ImageItem = { id: string; type: 'image'; url: string }
type FeedItem = HeaderItem | MessageItem | ImageItem
function Feed({ items }: { items: FeedItem[] }) {
return (
<LegendList
data={items}
keyExtractor={(item) => item.id}
getItemType={(item) => item.type}
renderItem={({ item }) => {
switch (item.type) {
case 'header':
return <SectionHeader title={item.title} />
case 'message':
return <MessageRow text={item.text} />
case 'image':
return <ImageRow url={item.url} />
}
}}
recycleItems
/>
)
}
```
**Why this matters:**
- **Recycling efficiency**: Items with the same type share a recycling pool
- **No layout thrashing**: A header never recycles into an image cell
- **Type safety**: TypeScript can narrow the item type in each branch
- **Better size estimation**: Use `getEstimatedItemSize` with `itemType` for
accurate estimates per type
```tsx
<LegendList
data={items}
keyExtractor={(item) => item.id}
getItemType={(item) => item.type}
getEstimatedItemSize={(index, item, itemType) => {
switch (itemType) {
case 'header':
return 48
case 'message':
return 72
case 'image':
return 300
default:
return 72
}
}}
renderItem={({ item }) => {
/* ... */
}}
recycleItems
/>
```
Reference:
[LegendList getItemType](https://legendapp.com/open-source/list/api/props/#getitemtype-v2)
© fcakyon · MIT · fcakyon/claude-codex-settings