Verified against Claude Code · 2026-07-21
Audit a component for wasted re-renders before adding memo everywhere
A diagnosis-first performance audit that finds the actual re-render trigger and only recommends useMemo, useCallback, or memo where profiling evidence supports it.
The prompt
Ready to copy — highlighted parts are example details you can swap.
<role> You are auditing a React component for unnecessary re-renders. You diagnose before you prescribe — you do not wrap everything in memo, useMemo, and useCallback as a reflex. </role> <component> A ProductList component wrapped in React.memo that still re-renders on every keystroke in a sibling SearchBox, because it receives an onSelect callback recreated inline in the parent on every render. </component> <profiling_context> Profiler flame graph shows ProductList re-rendering 1:1 with every SearchBox keystroke, even though ProductList props (besides onSelect) are unchanged. </profiling_context> <react_compiler_status> React Compiler is: no </react_compiler_status> <diagnostic_steps> 1. If React Compiler is enabled, most manual useMemo/useCallback/memo in this file is redundant — flag any hand-written memoization the compiler already handles, and recommend removing it rather than adding more. 2. If React Compiler is not enabled, identify the actual re-render trigger for each suspected problem area: a new object/array/function literal created on every render and passed as a prop, a parent re-rendering for unrelated reasons, or a genuinely expensive computation running on every render. 3. Only recommend useMemo for computations you can name as expensive (not "might be slow" — name the actual work: sorting a large array, a regex over long text, a derived object built from several props). 4. Only recommend useCallback where the function is passed to a memoized child or used as an effect dependency — a useCallback with no memoized consumer is nearly always dead weight, not a fix. 5. If the real problem is architectural (state that's too high in the tree, a context value that changes too often), say so instead of reaching for memoization to paper over it. </diagnostic_steps> <output_format> A table: Location | Suspected issue | Root cause | Recommendation | Confidence (high/medium/low). Then a one-paragraph summary of the single highest-impact fix. </output_format>
Customize the highlighted detailsoptional — the prompt above already works
Why this works
React Compiler auto-memoizes components and values that are safe to memoize, so once it's enabled, hand-written useMemo/useCallback/memo calls are usually redundant and occasionally a correctness risk if their dependency arrays drift out of sync with what the compiler now assumes — which is why the prompt branches the entire recommendation set on compiler status instead of giving one generic answer. The requirement to name the actual expensive computation, rather than accept "might be slow," mirrors the React team's own documented caution that memoization has a real cost (extra comparisons, extra memory) and shouldn't be applied speculatively. The useCallback-needs-a-memoized-consumer rule targets the single most common mistake in AI-generated performance audits: recommending useCallback reflexively on every handler without checking whether anything downstream is actually memoized to benefit from a stable reference.
What you get back
Location | Suspected issue | Root cause | Recommendation | Confidence ProductList | Re-renders every keystroke | onSelect prop is a new arrow function on every SearchBox render | Wrap onSelect in useCallback in the parent (ProductList's memo is already correct) | high SearchBox | none flagged | — | — | — Summary: the highest-impact fix is a single useCallback in the parent around onSelect — ProductList's own React.memo is working as intended, it's being defeated by an unstable prop reference one level up.
Verified against
Claude Code Sonnet 4.6 · 2026-07-21
ChatGPT GPT-5.1 · 2026-07-25
Changelog
- 2026-07-21 — Initial publish, verified against Claude Code (Sonnet 4.6) and ChatGPT (GPT-5.1).
Need this built into your business?
If a prompt isn't enough — custom software, built and maintained for you — that's Scult's day job.
EXPLORE CUSTOM SOFTWARE

