Skip to main content
rule CX Codex

rerender-derived-state — Claude Code rule: what it does, install

The rerender-derived-state rule favors derived boolean state over continuously changing values, reducing React re-renders. It fits responsive UI logic.

no license ★ 1,064 updated 2026-01-21

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

What rerender-derived-state does

The rule guides an agent to subscribe to the result a component actually needs, such as a mobile-mode boolean, instead of tracking the window’s changing width. A media-query result can then choose between responsive layouts.

This keeps rendering tied to a state transition rather than every source-value update. Tracking width means a render can happen for each pixel change, so responsive navigation is where the distinction matters most.

What it helps with

  • reduce renders caused by window-width updates
  • switch responsive layouts from a media-query result
  • replace continuous state with a derived boolean
  • review a React component for unnecessary width subscriptions

Example prompts for the agent

  • Review this responsive navigation component and replace width tracking with derived boolean state.
  • Find renders caused by every window-width change and rewrite the logic around a media-query result.
  • Apply the rerender-derived-state rule to this React component.

How to install rerender-derived-state

Manually: put the files in place

.claude/rules/rerender-derived-state.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 rerender-derived-state

How do I install rerender-derived-state in Claude Code?

Add the rule file at .claude/rules/rerender-derived-state.md.

What does rerender-derived-state do?

It guides Claude Code toward subscribing to derived boolean state rather than a continuously changing value. This reduces unnecessary React re-renders.

Why is tracking window width a problem for responsive components?

Width can change on every pixel movement, while the component may only need to know which layout mode applies. A media-query result lets it respond when that mode changes.

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set20

The whole set →
rendering-activity rendering-activity — a Claude rule that tells the agent to keep costly React components inside <Activity> so hiding them does not throw away state. CX Codex +1 ★ 1,064repo stars rendering-svg-precision rendering-svg-precision — a rule for Claude Code that reduces SVG coordinate precision to one decimal place. Applies when creating icons or editing graphics. CX Codex +1 ★ 1,064repo stars _template _template — a rule-file scaffold with fields for its title and impact, plus sections for contrasting incorrect and correct code. CX Codex +1 ★ 1,064repo stars async-parallel async-parallel — a Claude rule that sends independent async calls through Promise.all() instead of awaiting them one by one. Useful when a handler piles up sequential awaits. CX Codex +1 ★ 1,064repo stars js-combine-iterations js-combine-iterations tells the Claude agent to replace several filter or map passes over the same array with one loop that fills the results as it goes. CX Codex +1 ★ 1,064repo stars bundle-dynamic-imports bundle-dynamic-imports guides Claude Code to lazy-load heavy components using next/dynamic with SSR disabled. Keeps your initial client bundle lean to protect TTI and LCP metrics. CX Codex +1 ★ 1,064repo stars rendering-content-visibility The rendering-content-visibility rule applies content-visibility: auto to long lists so off-screen items can wait before rendering. It fits message feeds and other scrollable collections. CX Codex +1 ★ 1,064repo stars rerender-dependencies rerender-dependencies — a Claude rule that keeps useEffect dependency arrays on primitives like user.id rather than whole objects, so an effect stops firing on every field change. CX Codex +1 ★ 1,064repo stars

Project sponsors

Companies that keep this analytics open