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
.claude/rules/server-dedup-props.mdWhat 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
usersandusers.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.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/server-dedup-props.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/server-dedup-props.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/server-dedup-props.mdManually: put the files in place
.clinerules/server-dedup-props.mdStep 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