React Router Code Review
by @anderskev
Reviews React Router code for proper data loading, mutations, error handling, and navigation patterns. Use when reviewing React Router v6.4+ code, loaders, a...
clawhub install react-router-code-reviewπ About This Skill
name: react-router-code-review description: Reviews React Router code for proper data loading, mutations, error handling, and navigation patterns. Use when reviewing React Router v6.4+ code, loaders, actions, or navigation logic.
React Router Code Review
Quick Reference
| Issue Type | Reference | |------------|-----------| | useEffect for data, missing loaders, params | references/data-loading.md | | Form vs useFetcher, action patterns | references/mutations.md | | Missing error boundaries, errorElement | references/error-handling.md | | navigate() vs Link, pending states | references/navigation.md |
Review Checklist
loader not useEffectdefer() for parallel data fetching when appropriate or useFetcher not manual fetcherrorElement on routesisRouteErrorResponse() to check error types over navigate() where possibleuseNavigation() or fetcher.stateValid Patterns (Do NOT Flag)
These patterns are correct React Router usage - do not report as issues:
useLoaderData() is a type annotation, not a type assertionContext-Sensitive Rules
Only flag these issues when the specific context applies:
| Issue | Flag ONLY IF | |-------|--------------| | Missing loader | Data is available server-side (not client-only) | | useEffect for data fetching | Data is NOT client-only (localStorage, browser APIs, window size) | | Missing errorElement | No parent route in the hierarchy has an error boundary | | navigate() instead of Link | Navigation is NOT triggered by an event handler or conditional logic |
Gates (before reporting any finding)
Run in order. Pass each gate with evidence (paths, line refs, or a one-line quote from code)βnot intuition alone.
Gate 1 β Scope the route surface
Pass when: You have repo path(s) to the route module, routes config entry, or layout that owns the behavior under review (write them in your notes before flagging).
Gate 2 β Context-sensitive match
Pass when: For every issue that maps to Context-Sensitive Rules, the Flag ONLY IF condition is satisfied with a one-line rationale tied to the code; for other checklist items, you have a concrete code citation (path + line or short excerpt).
Gate 3 β Non-issue patterns
Pass when: The behavior is not covered by Valid Patterns (Do NOT Flag) for that category.
Gate 4 β Verification protocol
Load and follow review-verification-protocol. Pass when: Its pre-report checklist (and any issue-type subsection that applies) is complete for each finding you will output.
When to Load References
Review Questions
1. Is data loaded in loaders instead of effects? 2. Are mutations using Form/action patterns? 3. Are there error boundaries at appropriate route levels? 4. Is navigation declarative with Link components? 5. Are pending states properly handled?