Skip to main content
rule CX Codex

server-dedup-props — Claude Code rule: what it does, how to install

server-dedup-props — a rule for Claude Code about React Server Components: RSC-to-client serialization deduplicates by reference, not value. Server-side transforms like toSorted or filter create new references and double the payload.

MIT ★ 7,191 updated 2026-10-24

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/server-dedup-props.md
Open on GitHub

What server-dedup-props does

RSC serialization tracks object references. One reference means one entry in the payload; a new reference means the data ships twice. The rule says: transform arrays on the client, pass originals from the server. Sending both usernames and usernames.toSorted() to a client component means the array content travels twice.

Nested deduplication works recursively, but impact depends on data type. For string[], number[], boolean[], both the array and every primitive get fully duplicated. For object[], only the array structure duplicates — nested objects stay deduplicated by reference. So the same .toSorted() trick on a string array doubles every string in transit, while on an object array it just adds an extra wrapper.

Operations that break deduplication by creating new references: .toSorted(), .filter(), .map(), .slice(), spread [...arr], {...obj}, Object.assign(), structuredClone(). The rule has one exception: pass derived data when the transformation is expensive or the client doesn't need the original.

What it helps with

  • Stop passing duplicate data in client component props
  • Move array transforms from server to client component
  • Avoid double serialization of primitives in RSC
  • Identify which operations create new references

Example prompts for the agent

  • Check RSC props for duplicate serialization
  • Move .toSorted() from the server component to the client
  • Replace users and users.filter(u => u.active) with a single prop

How to install server-dedup-props

Manually: put the files in place

.claude/rules/server-dedup-props.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 server-dedup-props

How do I install server-dedup-props in Claude Code?

Copy the rule file to .claude/rules/server-dedup-props.md in your project root. Claude Code picks it up automatically.

What does server-dedup-props do?

It tells the agent not to pass transformed data as separate props to client components. RSC serialization deduplicates by reference, so .toSorted() produces a new array that gets serialized again.

When does duplicate payload matter most?

For arrays of primitives (string[], number[], boolean[]), the entire array and every element get duplicated. For object arrays, only the array wrapper duplicates — nested objects stay by reference.

Source text

server-dedup-props.md · MIT
---
title: Avoid Duplicate Serialization in RSC Props
impact: LOW
impactDescription: reduces network payload by avoiding duplicate serialization
tags: server, rsc, serialization, props, client-components
---

## Avoid Duplicate Serialization in RSC Props

**Impact: LOW (reduces network payload by avoiding duplicate serialization)**

RSC→client serialization deduplicates by object reference, not value. Same reference = serialized once; new reference = serialized again. Do transformations (`.toSorted()`, `.filter()`, `.map()`) in client, not server.

**Incorrect (duplicates array):**

```tsx
// RSC: sends 6 strings (2 arrays × 3 items)
<ClientList usernames={usernames} usernamesOrdered={usernames.toSorted()} />
```

**Correct (sends 3 strings):**

```tsx
// RSC: send once
<ClientList usernames={usernames} />

// Client: transform there
'use client'
const sorted = useMemo(() => [...usernames].sort(), [usernames])
```

**Nested deduplication behavior:**

Deduplication works recursively. Impact varies by data type:

- `string[]`, `number[]`, `boolean[]`: **HIGH impact** - array + all primitives fully duplicated
- `object[]`: **LOW impact** - array duplicated, but nested objects deduplicated by reference

```tsx
// string[] - duplicates everything
usernames={['a','b']} sorted={usernames.toSorted()} // sends 4 strings

// object[] - duplicates array structure only
users={[{id:1},{id:2}]} sorted={users.toSorted()} // sends 2 arrays + 2 unique objects (not 4)
```

**Operations breaking deduplication (create new references):**

- Arrays: `.toSorted()`, `.filter()`, `.map()`, `.slice()`, `[...arr]`
- Objects: `{...obj}`, `Object.assign()`, `structuredClone()`, `JSON.parse(JSON.stringify())`

**More examples:**

```tsx
// ❌ Bad
<C users={users} active={users.filter(u => u.active)} />
<C product={product} productName={product.name} />

// ✅ Good
<C users={users} />
<C product={product} />
// Do filtering/destructuring in client
```

**Exception:** Pass derived data when transformation is expensive or client doesn't need original.

© tech-leads-club · MIT · tech-leads-club/agent-skills

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set130

The whole set →
client-event-listeners client-event-listeners — a Claude rule that keeps a single keydown listener on window no matter how many components call the shortcut hook. CX Codex +1 ★ 7,191repo stars server-after-nonblocking server-after-nonblocking instructs the agent to schedule logging, analytics, and cleanup with Next.js after(). This sends responses right away without waiting for background work. CX Codex +1 ★ 7,191repo stars rerender-lazy-state-init The rerender-lazy-state-init rule recommends lazy useState initialization for costly starting values. It helps when a React component reads stored settings or builds a data structure. CX Codex +1 ★ 7,191repo stars async-defer-await async-defer-await — a rule that moves await operations into code branches where they're actually needed, preventing blockage of execution paths that may exit early. CX Codex +1 ★ 7,191repo stars rendering-usetransition-loading rendering-usetransition-loading — a rule that swaps hand-rolled loading flags in React components for useTransition. Useful when a spinner runs on its own useState. CX Codex +1 ★ 7,191repo stars server-cache-react server-cache-react instructs the assistant to deduplicate server-side operations with React.cache() and prevent cache misses from inline object arguments. CX Codex +1 ★ 7,191repo stars architecture-avoid-boolean-props The architecture-avoid-boolean-props rule keeps component variants out of boolean props and moves them into composition. Use it when conditional UI branches start spreading across a component. CX Codex +1 ★ 7,191repo stars rendering-hydration-no-flicker rendering-hydration-no-flicker prevents server render failures and interface flickering when displaying content tied to browser storage. CX Codex +1 ★ 7,191repo stars

Project sponsors

Companies that keep this analytics open