react-review
Use when reviewing React components, hooks, or route files for idiomatic React, when the user asks for refactor targets or a React cleanup pass, or types /react-review. Reports composition, colocation, state ownership, and repo-idiom findings ranked by hurt. It reports, it does not fix. External scanner counterpart is react-doctor.
- License 许可
- AGPL-3.0
- 最近更新
- 2026-11-15
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- react-review
- version
- 1.0.0
- description
- Use when reviewing React components, hooks, or route files for idiomatic React, when the user asks for refactor targets or a React cleanup pass, or types /react-review. Reports composition, colocation, state ownership, and repo-idiom findings ranked by hurt. It reports, it does not fix. External scanner counterpart is react-doctor.
02 资源文件 2
- 参考文档references/dimensions.md4.4 KB
- 参考文档references/triggers.md3.9 KB
03 SKILL.md 正文
React Review
A specialized review skill. It does one thing: judge React code against this repo's idioms and report what to refactor, ranked by how much it hurts. It does not build features or fix the code. Point it at a diff, a component, a hook, or a file.
This skill owns structure: composition, colocation, ownership, and idiom. When a finding is visual (spacing, motion, contrast), leave it for a UI review pass. When a finding is a known diagnostic with a scanner recipe, defer to react-doctor.
Operating posture
Review like the engineer who will maintain the file. Code that renders but resists change, hides its data flow, or duplicates what the framework owns is a regression, not a pass. Default to flagging. Approval is earned, not assumed.
Behavior first
Start from the user-observable behavior, not the code shape. No behavior change means no finding above a nit. Judge data shapes from the caller's side: the reader decides the shape, so a shape that serves no caller gets deleted and a shape two callers read differently gets split.
A refactor must lock current behavior before it moves code: a regression test that fails on the old shape and passes on the new one, or a recorded before/after run. Flag any restructure with no behavior lock, however clean it reads.
Every finding states the behavior at stake and its proof: the test output, the repro steps, or the spec line. Style without a behavioral consequence is a nit at most. If the intended behavior is not evident from the diff and its tests, grill for intent first instead of guessing (the grilling skill owns the interview); a review that invents intent manufactures findings.
What to review, in priority order
Read the target first, then judge it against these dimensions. The order is the triage order: a broken hook outranks an awkward prop. Expanded checklists with repo examples live in references/dimensions.md.
- Correctness of hooks and rendering: hooks called unconditionally and in stable order, stable
keyvalues, no state that duplicates derivable data, effects that clean up async work which can outlive unmount. Prefer derived values, maps, and explicit state models over effects that sync state step by step; effects that touch the world stay effects. Name the machine when two or more flags jointly decide one UI outcome: separate boot from op pending, never letundefinedmean a screen, type the union once and export it, and give every async transition one owner with a generation check so a late response cannot overwrite newer state. SeeuseCopyFeedback-style timers as the model: ref-held, cleared on retrigger and on unmount. - Composition over configuration: layout shells take
children, related pieces compose as compound components, call sites pass layout only. A pile of boolean props that switches between renders is a component begging to be split; a newshowHeaderorrenderActionsprop where the caller could pass children is the violation to name. Wrappers own styling; call sites never restyle. An abstraction earns its place only if deleting it would move meaningful complexity into its callers; a wrapper forwarding props unchanged with no logic gets inlined. - Colocation: logic lives next to its only consumers: helpers beside their single call site, tables beside the rows they render, maps beside the registry they index. A shared module with one importer is a file waiting to be inlined. Each concept keeps one defining home; reuse the existing component, token, validator, or query instead of making another version. Flag duplicated status literals, magic strings, and route paths; one validator or helper owns each.
- State ownership: props for one level of passing, context (read through
use(), neveruseContext) when it goes deeper. A component that renders from optional data owns its guard and returns null instead of pushing conditionals to its caller. Each component destructures only what it reads. When a module splits, every state transition keeps one owner; siblings never duplicate controlled state or callbacks. - Repo idioms: React Compiler owns memoization, so
useMemo,useCallback, andReact.memonever appear (ADR-0009). Preferfunctiondeclarations over arrow function expressions, except in-component handlers, inline callbacks, and one-liners. Layout shells type props asReact.ComponentProps<element>; data carriers keep explicit types. Multi-line event logic lives in namedhandle*functions; single-expression delegation stays inline. Props areReadonly, types beat interfaces, and nothing is ever cast. - Dead code: a prop with zero call sites gets deleted, an unused helper goes with it. Extraction waits for the third copy: the first duplication is a note, the second is a candidate, the third is the refactor.
Escalation triggers: flag on sight
These are almost always wrong. You do not need to deliberate. Wrong-to-right snippets for each trigger live in references/triggers.md.
useMemo,useCallback, orReact.memo.useContext(the repo reads context throughuse()).- An
ascast or a non-null assertion. Omitthat redeclares props just to re-add them, or a...restspread (the spread is named...props).childrenriding inside the spread instead of destructured and rendered.- Multi-line logic inline in
onClickor JSX instead of a named handler. - A prop drilled through an intermediary that never reads it (context instead).
- Nullable
useStatewhose value reaches render without narrowing through a union. - A
catchwhose body only swallows, with no state update. - Arrow function declarations for components or module helpers (in-component handlers, inline callbacks, and one-liners are exempt).
- Async
setStateafter anawaitwith no generation check, so a late response can overwrite newer state. - One boolean read two ways (boot versus op, page versus button).
- A nullable phase where
undefinedmeans a different screen instead of missing data.
Output format
Lead with the verdict, then the findings. Do not bury the one thing that matters under ten nits.
- Verdict: one line: Blocked, Approve with changes, or Ship it. Blocked means at least one finding breaks hooks, data flow, or the repo lint gate.
- Blocking: findings that must be fixed before the code lands. Each: what is wrong, where (
file:line), the behavior at stake plus its proof, why it hurts, and the fix with the repo rule it follows. - Should fix: real structural problems that are not blockers. Same shape.
- Nits: small polish, clearly labeled as optional.
Be specific and cite the exact code. "This component is hard to follow" is weak; "this page threads entry through four layers that never read it: provide it once through context and let each section read what it needs" is a review. Name the repo rule (an AGENTS.md row, a CODING_STANDARDS.md section, an ADR) so the fix is grounded, not invented.
What earns approval
A target ships when hooks are correct, pieces compose instead of configuring, logic sits next to its consumers, state has a clear owner, repo idioms hold, and nothing dead remains. Approval is the absence of findings, not the absence of effort. If you cannot find anything wrong, say so plainly.
04 同仓库更多 Skills
writing-for-agents
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.
wizard
Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.
wait-what
Stop. That last message did not land: re-pitch it.
to-questionnaire
Turn a decision you can't fully answer into a questionnaire for someone else to fill in.
retro
Conduct a retrospective on a coding session.
react-doctor
Use when finishing a feature, fixing a bug, before committing React code, or when the user types `/doctor`, asks to scan, triage, or clean up React diagnostics. Covers lint, accessibility, bundle size, architecture. Includes a regression check and a full local-triage workflow that fetches the canonical playbook.