Code-quality patterns and anti-patterns for TypeScript apps using React, TanStack Query, Zustand, Next.js / RSC. Use when writing new components or pages, reviewing existing code, setting up a new project, debugging re-renders, structuring data fetching, deciding between server and client components, designing UI states, choosing between WebSocket and HTTP, or anytime an `any` or `useEffect` is about to be added.
Installation
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Code-quality patterns and anti-patterns for TypeScript apps using React, TanStack Query, Zustand, Next.js / RSC. Use when writing new components or pages, reviewing existing code, setting up a new project, debugging re-renders, structuring data fetching, deciding between server and client components, designing UI states, choosing between WebSocket and HTTP, or anytime an `any` or `useEffect` is about to be added.
typescript-code-quality
When to invoke this skill
Invoke whenever any of the following are true:
A new component, hook, page, or route is being written.
An existing component is being refactored or has a bug related to state, re-renders, or fetching.
A code review is requested ("review this", "audit this PR", "is this pattern correct?").
A new project is being scaffolded.
About to add useEffect, any, as, a setState chain, or a wrapper component.
About to install an icon library, UI library, or any package adding many components.
A websocket, polling, or live-data feature is involved.
Choosing between server components and client components.
A user-visible state (loading / empty / error / success) is being designed.
Animation or navigation feels janky.
How this skill is organised
This SKILL.md is a table of contents. Each linked file is a focused, agent-readable rule set with Incorrect → Correct examples. Read the relevant file before writing or reviewing code in its area. Multiple files frequently apply at once.
Part 1 — Project setup and deep review
For new projects, big refactors, or whole-codebase audits.
Global non-negotiables (apply to every file Claude writes or edits)
These override anything inferred from existing code in the repo. If existing code violates them, prefer fixing it (small, in-scope) over copying the bad pattern.
No any. Use unknown + narrowing, or generics. See typescript/any-and-inference.md.
No useEffect for transformations, derivations, prop-syncing, parent-notification, or chains. Read React's You Might Not Need an Effect. See react/useeffect-discipline.md.
No useEffect chains (effect that sets state that triggers another effect that sets state). Compute during render.
react-hooks/exhaustive-deps is error, not warn. Never silence it without a comment justifying why.
Server state lives in TanStack Query (or RSC), not useState + useEffect.
One source of truth for any piece of state. Don't duplicate server state into Zustand or useState. Derive instead.
UI states are discrete branches with a shared <Layout>, not condA ? … : condB ? … : … inside JSX.
Don't wrap a primitive component just to set props. A Button with style variants does not need HomepageButtonCTAAnimated. See 02-feature-review/new-component-checklist.md.
Never import * as Icons from 'lucide-react' or equivalent. Import specific symbols. See 01-project-and-review/component-inventory-control.md.
Always use the framework's <Link> (Next, TanStack Router, React Router) for in-app nav. Never <a> or window.location.
Refactor only with measurable user or maintainer impact. Cosmetic refactors are rejected.
Prefer browser-native behaviour. A real <form> over onClick on a div. A real <button type="submit"> over a custom div with role="button".
Reading order recommendation when first invoked
If unsure which file to read, default to:
This file (you are here).
react/useeffect-discipline.md — most pattern violations land here.
The Part-2 file matching the task (new-component-checklist, ui-states, or data-flow-and-state-shape).
The library file matching what's imported (tanstack-query/*, state-management/*, server-components/*).
Authoritative sources this skill is built on
Cited per file. Primary:
React docs — You Might Not Need an Effect, Thinking in React, Rules of Hooks
TkDodo's blog (Dominik Dorfmeister, TanStack Query maintainer) — entire React Query series, Zustand series, useEffect series
TanStack docs — Query, Router type-safety guide
Vercel agent-skills/react-best-practices — same audience, complementary rules
Mark Erikson — A (Mostly) Complete Guide to React Rendering Behavior