Skip to main content
rule CX Codex

rerender-dependencies — Claude Code rule for useEffect deps

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.

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-dependencies.md
Open on GitHub

What rerender-dependencies does

The rule file ships two tsx snippets, one wrong and one right. The first depends on user.id instead of the user object, so the effect reruns only when the id moves. The second lifts a derived flag out of the effect: compute isMobile = width < 768 first, then list that boolean. Raw width as a dependency fires at 767, 766, 765 and so on.

This is a style rule, and the author tags it low impact. Fewer effect reruns help a little. Components that don't use React hooks have nothing to gain from it.

Drop the markdown at .claude/rules/rerender-dependencies.md inside your project.

What it helps with

  • stop an effect from rerunning when an unrelated user field changes
  • swap an object dependency for a primitive id
  • move derived state out of a useEffect body
  • replace a pixel-width dependency with a boolean flag
  • defend user.id in a dependency array during code review

Example prompts for the agent

  • Check the useEffect deps in Profile.tsx and keep only primitives there
  • Move the isMobile calculation out of the effect and depend on the boolean
  • Find effects that rerun whenever the window width changes

How to install rerender-dependencies

Manually: put the files in place

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

How do I install rerender-dependencies in Claude Code?

Place the rule file in your project at .claude/rules/rerender-dependencies.md.

What does rerender-dependencies do?

It pushes the agent toward primitive dependencies in useEffect and toward computing derived state before the effect runs.

Why depend on user.id instead of user?

Any edit to the object gives it a new identity, while the id changes only when the id itself changes. The primitive keeps the effect quiet.

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set20

The whole set →
rerender-derived-state The rerender-derived-state rule favors derived boolean state over continuously changing values, reducing React re-renders. It fits responsive UI logic. 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 testing The testing rule sets conventions for TypeScript test files and the __tests__ directory. Use it to guide checks for success cases, failures, and edge conditions. CX Codex +1 ★ 1,064repo stars forge The forge rule configures Foundry workflows for Abstract and tells Claude Code to use the ZKsync mode for Solidity projects. CX Codex +1 ★ 1,064repo stars js-batch-dom-css js-batch-dom-css — a Claude rule that keeps the agent from writing styles one property at a time and pushes it toward a class or a single cssText string. CX Codex +1 ★ 1,064repo stars codebase-search codebase-search finds where a feature lives in your repo and hands back absolute paths plus a short explanation of the flow. CX Codex ★ 1,064repo stars

Project sponsors

Companies that keep this analytics open