Skip to main content
rule CX Codex

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

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add fcakyon/claude-codex-settings
/plugin install react-skills@claude-settings
Open on GitHub

What 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 switch branches
  • estimate cell size by item type

Example prompts for the agent

  • Update the LegendList feed so messages and images use separate recycling pools.
  • Refactor Feed to use header, message, and image item 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-settings

2Manually: put the files in place

.claude/rules/list-performance-item-types.md

The paths frontmatter field limits the files

Step 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

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set113

The whole set →
commit-staged commit-staged automates commit creation: checks staged diffs, runs /simplify on code edits, and writes conventional commits using session rationale. CX Codex +1 ★ 1,216repo stars shell-and-workflows The shell-and-workflows rule documents Docker commands for the project and explains where to run frontend and backend tests. Use it when managing services or checking a change. CX Codex +1 ★ 1,216repo stars js-request-idle-callback js-request-idle-callback — a rule that moves analytics, state saving and prefetching into idle browser time so the interface stops stuttering on every click. CX Codex +1 ★ 1,216repo stars pr-comment-resolver pr-comment-resolver inspects unresolved pull request reviews, applies necessary code updates, and drafts replies for reviewers. Ideal for clearing PR feedback without manual issue hunting. CX Codex ★ 1,216repo stars manage-instances manage-instances — a rule for running multiple isolated app stacks in separate worktrees, each with its own database, Redis index, and host ports. CX Codex +1 ★ 1,216repo stars test-audit The test-audit skill reviews new and changed tests, and helps spot duplicates or low-value checks. Use it when adding tests or auditing an existing suite. CX Codex +1 ★ 1,216repo stars webmcp-gen webmcp-gen turns a page workflow into a WebMCP tool and checks that the tool matches the behavior of the existing UI. CX Codex +1 ★ 1,216repo stars start-environment start-environment teaches the assistant how to spin up local development containers via dev docker up, wait for healthchecks, and inspect ports. CX Codex +1 ★ 1,216repo stars

Project sponsors

Companies that keep this analytics open