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
.claude/rules/rerender-derived-state.mdWhat 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-staterule to this React component.
How to install rerender-derived-state
Manually: put the files in place
.claude/rules/rerender-derived-state.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/rerender-derived-state.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/rerender-derived-state.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/rerender-derived-state.mdManually: put the files in place
.clinerules/rerender-derived-state.mdStep 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.