Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    react antipatterns review

    1

    Audit React components for architectural anti-patterns, hook misuses, and performance bottlenecks with a fix plan.

    Free

    Security scanned
    react antipatterns review

    react antipatterns review

    Example session with this skill installed

    Review my RequestForm.tsx component for any React anti-patterns. Just show the results here in the chat.

    • Read your context and instructions
    • Compiled the react antipatterns review
    • Generated the UI component

    React anti-pattern review

    Scope: client/src/pages/RequestForm.tsx · 4 findings (0 High · 2 Medium · 2 Low) · catalog v2
    Assumptions: React 19.2.7 (from client/package.json), no React Compiler (vite.config.ts uses plain @vitejs/plugin-react), web.

    No C1, D4, D7 or D8. FieldError is declared at module scope, every hook runs before the early returns, and every state update is immutable. handleSubmit reads values before its await, which is intended: it submits what was on screen at the click.

    client/src/pages/RequestForm.tsx

    F1 [MEDIUM] Hydrating form state from fetched data in an Effect — A2, D6 (lines 159, 167–172)

    What: hydrated state plus useEffect(() => { if (existing && !hydrated) { setValues(toFormValues(existing.values)); setHydrated(true); } }, [existing, hydrated]).

    Why it's flagged: values is seeded from existing, and an Effect copies it across after the render. When the fetch resolves, the first render passes every guard with values === EMPTY_VALUES. That render can paint an empty edit form before the Effect fills it in. It also re-renders twice: once for setValues and once for setHydrated. hydrated never appears in the JSX. It only gates the Effect, so it causes a re-render for a value nothing displays (D6).

    Fix: Split the component into a loader and a form. The loader fetches and runs the guards. The form takes the fetched values as a seed, the pattern the catalog allows, so hydrated and the Effect go away.

    // before
    const [values, setValues] = useState(EMPTY_VALUES);
    const [hydrated, setHydrated] = useState(!loadId);
    useEffect(() => { /* copy existing → values */ }, [existing, hydrated]);
    
    // after (loader renders this once data and guards pass)
    <RequestFormFields key={loadId ?? 'new'} initialValues={existing ? toFormValues(existing.values) : EMPTY_VALUES} ... />
    // inside: const [values, setValues] = useState(initialValues);
    

    For a smaller change, adjust state during render with a guard. Write if (existing && !hydrated) { setHydrated(true); setValues(...) } in the body, not in an Effect. React then re-renders before paint, so the empty frame never shows.

    F2 [MEDIUM] fieldErrors derived from values via an Effect — A1 (lines 164, 177–183)

    What: useEffect(() => { if (!submitAttempted) return; setFieldErrors(validate(values)); }, [values, submitAttempted]). setFieldErrors is also called from handleSubmit (lines 253, 258) and handleWriteError (line 226).

    Why it's flagged: Client-side errors are a pure function of values and submitAttempted, so they are derived state. Each keystroke after the first submit renders once with stale errors, then the Effect re-renders. handleSubmit also validates twice: once inline and again when the Effect reacts to setSubmitAttempted(true). Three writers share one state slot: the Effect, the submit handler and the server error handler. Which source wins depends on timing. The Effect also returns early when submitAttempted is false. So server fieldErrors from a failed Save Draft never clear while the user types.

    Fix: Compute client errors during render. Keep only server errors in state, and clear them in the change handler.

    const [serverErrors, setServerErrors] = useState<FieldErrors>({});
    const clientErrors = submitAttempted ? validate(values) : {};
    const fieldErrors = { ...clientErrors, ...serverErrors };
    
    function setField(key, value) {
      setValues((prev) => ({ ...prev, [key]: value }));
      setServerErrors({});
    }
    

    handleSubmit then calls validate(values) once, to decide whether to POST and which field to focus. It no longer writes errors to state.

    F3 [LOW] Two booleans for one write status — D9 (lines 161–162, 190)

    What: isSubmitting and isSaving, combined into busy.

    Why it's flagged: The two flags describe one mutually exclusive phase: idle, saving or submitting. The default severity is Medium. I lowered it to Low because both buttons are disabled when busy is true, so no UI path sets both flags at once.

    Fix: const [pending, setPending] = useState<'idle' | 'saving' | 'submitting'>('idle'); const busy = pending !== 'idle';

    F4 [LOW] Non-unique key on the error list — E1 (lines 443–447)

    What: unshownErrors.map((message) => <p key={message}>…).

    Why it's flagged: unshownErrors flattens messages from several fields. Two hidden fields can return the same message text, for example "Required". React then warns about duplicate keys and can drop or duplicate a row. The rows hold no state, so the impact is cosmetic.

    Fix: Keep the field name when flattening, and key on it plus the index: .flatMap(([field, msgs]) => msgs.map((m, i) => ({ key: `${field}-${i}`, m }))).

    Outside the catalog / worth a look

    • loadId and requestId are seeded from routeId (lines 150, 158). This matches the A12 signal, but it is an intentional seed, and the comment explains why. It is safe today only because no link goes directly from /requests/:id/edit to /requests/new or to another edit URL. Both routes render <RequestForm /> at the same position, so React Router reuses the mounted instance. If someone adds such a link later, for example in the header, the reused form keeps the old requestId and Save writes to the wrong request. A key={routeId} on the loader from F1, with the post-create navigate handled separately, would remove this dependency.
    • useApiQuery initialises loading to false (this is in api/useApiQuery.ts, not this file). On the first render of an edit URL, loading is false and existing is null. If currentUser is already set, the guard at line 274 passes and the empty form renders for one frame before the fetch starts. This makes the F1 flash worse. Starting with useState(path !== null) would fix it.

    Summary

    No High-severity bugs. The main theme is derived state kept in sync by Effects. The form values are copied in from the fetch (F1), and the validation errors are copied in from values (F2). Both cause extra renders and timing-dependent desync. Fix F2 first: it is small and contained. F1 is the bigger structural change, and it also covers the route-reuse note.

    Fix plan

    [ ] 1. Derive client validation errors during render; keep only server errors in state — fixes F2

    • Where: RequestForm: state at line 164, Effect at lines 177–183, setField, handleSubmit, handleWriteError
    • Effort: S
    • Check it worked: Submit an empty form, then type a valid amount. The amount error clears on that keystroke with no extra render. Force a server fieldErrors response; it appears, then clears on the next edit.

    [ ] 2. Split the component into a loader and a seeded form, and delete the hydrated Effect — fixes F1

    • Where: RequestForm: lines 150–172 plus the guards at lines 274–302
    • Effort: M
    • Check it worked: Throttle the network and open /requests/REQ-001/edit. The page shows "Loading request..." and then the filled form, with no empty frame between them. Save Draft on a new request still turns into a PATCH on retry.
    • Note: Do this after step 1, so the split moves the simpler error logic. Giving the loader a key also covers the route-reuse risk under "worth a look".

    Optional clean-up (Low)

    • Replace isSaving/isSubmitting with a single pending status — F3
    • Give the hidden-field error list unique keys — F4

    RequestForm.tsx

    TSX · React component

    Generated

    Example file from a real run - the skill writes it into your workspace.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    React Anti-Patterns Review

    An Agent Skill that reviews React / JSX / TSX code for known anti-patterns and hands you a prioritized fix plan. It is observe-only: it never edits your source files.

    Point it at a component, a pasted snippet, a diff or a PR, and you get a file-by-file walkthrough of numbered findings (each tied to a catalog ID, with the reasoning and a small before → after snippet), a short summary, and a checklist-style fix plan ordered by priority.

    Why observe-only?

    People usually want to know what's wrong and what to do about it before touching the code: a PR they're reviewing, a teammate's component, a file they can't change yet. So the skill explains and plans, and stops. If you want the fixes applied, ask for that as a separate step.

    What it checks

    The catalog (references/catalog.md, v2) covers 29 anti-patterns, each with a stable ID, a default severity, why it matters, how to fix it, and a list of legitimate uses so it doesn't flag false positives.

    GroupIDsExamples
    State & EffectsA1–A12Derived state, event logic in Effects, chained Effects, fetching without cleanup, prop copied into state
    MemoizationB1–B4useMemo/useCallback that feed nothing, memoizing cheap operations
    Component structureC1Component defined inside another component
    Hooks & state shapeD1–D9Missing deps, conditional hooks, stale closures, direct mutation, several booleans for one status
    Rendering, lists & contextE1–E3key={index}, && with a number, mega-contexts and unstable provider values

    It also adapts advice to your project when it can see it: React version (e.g. useEffectEvent only on 19.2+), whether React Compiler is on (memoization findings are skipped), React Native vs web, and which data-fetching library you already use.

    Usage

    You don't need to name the skill. Any React review or hook question triggers it:

    Review src/components/TodoList.tsx for anti-patterns
    
    Why does this component re-render so much? [paste code]
    
    Check the React changes in this PR before I merge
    

    Before reviewing, it asks one question: show the review and plan in the chat (default), or also save them as a Markdown file? Skip the question by saying it up front, e.g. "review this and save it to a file" or "just show me".

    Saved files are named react-review-<scope>-<YYYY-MM-DD>.md and placed in your project root. Existing files are never overwritten.

    Accepted input: files on disk or uploaded, pasted snippets, diffs and PRs, or a source file open in Chrome.

    Example output

    # React anti-pattern review
    
    Scope: TodoList.tsx · 3 findings (1 High · 1 Medium · 1 Low) · catalog v2
    Assumptions: React 18, no compiler
    
    ## src/components/TodoList.tsx
    
    ### F1 [HIGH] Rows keyed by index — E1 (line 42)
    **What:** `todos.map((t, i) => <TodoRow key={i} ... />)`
    **Why it's flagged:** rows can be deleted and each holds an input's state, so deleting row 1 shifts row 2's text into it.
    **Fix:** `key={t.id}`
    
    ...
    
    ## Fix plan
    
    ### [ ] 1. Key rows by `todo.id` — fixes F1
    - **Where:** TodoList
    - **Effort:** S
    - **Check it worked:** delete the first row; the second row's input keeps its text
    

    File structure

    FilePurpose
    SKILL.mdEntry point: workflow, scan checklist, rating rules
    references/catalog.mdEvery anti-pattern with ID, severity, fix and legitimate uses
    references/report-format.mdReport template, fix-plan template, file delivery rules

    Sources

    The catalog draws on:

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Code Quality & Review.

    Does not modify source code or provide inline annotations. Focuses on React-specific logic rather than general CSS, styling, or accessibility audits.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed today

    • Free with an Agensi account

    Software
    Claude CodeNode.jsGit

    Permissions

    Read Files
    Terminal / Shell
    Listedtoday

    What's inside

    Frequently Asked Questions

    Unlike generic LLM prompts, this skill uses a specialized 30-point React-specific catalog to identify 'silent' bugs like stale closures and unstable context values that general models often overlook.

    Yes, the skill is context-aware and automatically adjusts its auditing rules based on your project's version (React 16.8 through 19.2+) and whether you are using the new React Compiler.

    No, this skill is designed for non-destructive auditing; it provides detailed reports and before-and-after code snippets to guide your manual refactoring without altering your source files.

    The skill focuses on React-specific logic, including hooks, state management, and component architecture, rather than general CSS styling or accessibility (a11y) audits.

    The skill performs a deep scan of your components and produces a prioritized fix plan, which you can choose to receive as a direct chat response or a structured Markdown file for your records.

    New in Code Quality & Review

    Free