React Router 代码审查
react-router-code-review
审查 React Router 代码的数据加载、变更操作、错误处理与导航模式是否正确。适用于审查 React Router v6.4+ 代码、loader、action 或导航逻辑。
- License 许可
- MIT
- 最近更新
- 2026-08-03
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- 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.
02 资源文件 23
- 脚本optional-ref.ts4.3 KB
- 参考文档references/data-loading.md7.3 KB
- 参考文档references/error-handling.md10.1 KB
- 参考文档references/mutations.md10.6 KB
- 参考文档references/navigation.md11.0 KB
- 脚本tools/checkpoint/handler.test.ts4.8 KB
- 脚本tools/checkpoint/handler.ts5.3 KB
- 参考文档tools/checkpoint/tool.json1.1 KB
- 脚本tools/plan/handler.test.ts16.7 KB
- 脚本tools/plan/handler.ts11.1 KB
- 参考文档tools/plan/tool.json1.1 KB
- 脚本tools/task-complete/handler.test.ts7.9 KB
- 脚本tools/task-complete/handler.ts3.2 KB
- 参考文档tools/task-complete/tool.json655 B
- 脚本tools/task-create/handler.test.ts26.8 KB
- 脚本tools/task-create/handler.ts14.1 KB
- 参考文档tools/task-create/tool.json2.2 KB
- 脚本tools/task-list/handler.test.ts6.8 KB
- 脚本tools/task-list/handler.ts4.5 KB
- 参考文档tools/task-list/tool.json800 B
- 脚本tools/task-update/handler.test.ts22.6 KB
- 脚本tools/task-update/handler.ts12.6 KB
- 参考文档tools/task-update/tool.json1.2 KB
03 SKILL.md 正文
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
- [ ] Data loaded via
loadernotuseEffect - [ ] Route params accessed type-safely with validation
- [ ] Using
defer()for parallel data fetching when appropriate - [ ] Mutations use
<Form>oruseFetchernot manual fetch - [ ] Actions handle both success and error cases
- [ ] Error boundaries with
errorElementon routes - [ ] Using
isRouteErrorResponse()to check error types - [ ] Navigation uses
<Link>overnavigate()where possible - [ ] Pending states shown via
useNavigation()orfetcher.state - [ ] No navigation in render (only in effects or handlers)
Valid Patterns (Do NOT Flag)
These patterns are correct React Router usage - do not report as issues:
- useEffect for client-only data - Loaders run server-side; localStorage, window dimensions, and browser APIs must use useEffect
- navigate() in event handlers - Link is for declarative navigation; navigate() is correct for imperative navigation in callbacks/handlers
- Type annotation on loader data -
useLoaderData<typeof loader>()is a type annotation, not a type assertion - Empty errorElement at route level - Route may intentionally rely on parent error boundary
- Form without action prop - Posts to current URL by convention; explicit action is optional
- loader returning null - Valid when data may not exist; null is a legitimate loader return value
- Using fetcher.data without checking fetcher.state - May be intentional when stale data is acceptable during revalidation
Context-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 |
When to Load References
- Reviewing data fetching code → data-loading.md
- Reviewing forms or mutations → mutations.md
- Reviewing error handling → error-handling.md
- Reviewing navigation logic → navigation.md
Review Questions
- Is data loaded in loaders instead of effects?
- Are mutations using Form/action patterns?
- Are there error boundaries at appropriate route levels?
- Is navigation declarative with Link components?
- Are pending states properly handled?
Before Submitting Findings
Load and follow review-verification-protocol before reporting any issue.
04 同仓库更多 Skills
next-workflow-step
Use this skill when the user wants to transition to the next workflow step, wrap up a session cleanly, prepare a handoff, or says things like "next step", "continue the workflow", "wrap up", "hand off", "move to the next phase", "what's next in embrace", or "prepare for /clear". Also triggers when the current octo:embrace phase appears complete and no explicit next action is set.
source-discovery
This skill should be used when the user asks to "find sources", "discover URLs", "catalog a source", "classify a URL", "search for libraries", "check what exists", or mentions source discovery, URL cataloging, source classification, or research source management.
review-synthesis
This skill should be used when the user asks to "summarize review findings", "prioritize fixes", "rank review issues", "combine reviewer feedback", "create action items from review", or mentions review synthesis, finding prioritization, severity ranking, or review result summarization.
research-scoring
This skill should be used when the user asks to "score research", "check research quality", "evaluate coverage", "measure improvement", "assess research completeness", or mentions research scoring, quality metrics, coverage gaps, improvement baseline, or research pipeline status.
notebooklm-integration
This skill should be used when the user asks to "ingest into NotebookLM", "query NotebookLM", "add sources to notebook", "cross-source synthesis", "check stale sources", or mentions NotebookLM, notebook integration, source ingestion, or knowledge consolidation.
evidence-synthesis
This skill should be used when the user asks to "synthesize findings", "combine research", "cross-reference sources", "summarize evidence", "write a deep review", or mentions evidence synthesis, finding consolidation, cross-source analysis, or research summarization.