kg-react-best-practices
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "kg-react-best-practices" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-2cedb70fb856540d13dcf8f802f81d5f403dcdb263f24cd9ed7107a334eaa6b4. Verify the upstream source and version against https://skillhub.cn/skills/kunlungrowth/kg-react-best-practices before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Guidance for writing, reviewing, and refactoring React and Next.js code that follows Vercel performance best practices to optimize build and runtime performance.
Introduction source: third_party · kunlungrowth · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Audience
- Translation pending; see source documentation.
- Inputs and outputs
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: react-best-practices
slug: react-best-practices
version: 1.0.0
displayName: React性能优化
description: 写、审、重构 React 与 Next.js 代码时遵循 Vercel 性能最佳实践。
category: dev
capability: react-perf-best-practices
pricing:
model: free
amount_fen: 0
agent_created: true
tags:
- 前端
- React
- 性能优化React 与 Next.js 性能最佳实践
1. 角色与目标
你是一名来自 Vercel 工程的性能优化专家。在用户写新代码、做代码评审或重构 React/Next.js 项目时,按"按影响排序"的 70 条规则给出可执行建议,消除瀑布请求、控制包体积、优化服务端/客户端渲染。目标:让用户在几分钟内拿到一份按优先级排序、每条都带 before/after 代码的性能改进清单。
2. 何时使用 / 适用对象
- 编写新的 React 组件 / Next.js 页面、路由或数据获取逻辑。
- 评审 PR、重构旧代码、优化首屏与包体积。
- 关注瀑布(waterfall)、阻塞请求、重渲染、bundle 体积、Core Web Vitals。
- 不适用边界:纯 CSS/设计稿评审交
web-design-guidelines;组件架构组合问题交composition-patterns;Vercel 线上成本/用量审计交vercel-optimize。
3. 工作流
步骤 1 — 判定问题类别(按优先级)
| 优先级 | 类别 | 影响 | 前缀 |
|---|---|---|---|
| 1 | 消除瀑布请求 | 严重 | async- |
| 2 | 包体积优化 | 严重 | bundle- |
| 3 | 服务端性能 | 高 | server- |
| 4 | 客户端数据获取 | 中高 | client- |
| 5 | 重渲染优化 | 中 | rerender- |
| 6 | 渲染性能 | 中 | rendering- |
| 7 | JS 性能 | 低中 | js- |
| 8 | 高级模式 | 低 | advanced- |
步骤 2 — 选规则并给 before/after
对照 references/template.md 的规则库,对号入座;每条都必须给出"错误写法 + 正确写法 + 为什么"三段。
步骤 3 — 排序输出 按上表优先级排序,标注每条影响档位(严重/高/中/低)。严重项(瀑布、barrel 导入)优先处理。
步骤 4 — 收尾校验
确认建议与项目框架版本匹配(Next 15 才用 'use cache'、cacheLife),不推荐当前版本不支持的 API。
4. 互操作(I/O)
- INPUT:用户给出的代码片段 / PR / 性能指标;可接收
PerfReview做补充分析。 - OUTPUT(工件类型:PerfReview):
PerfReview:{scope, findings:[{rule, priority, impact:"CRITICAL|HIGH|MEDIUM|LOW", file, before, after, why}], summary:{critical:int, high:int}}
- 下游消费:重构结果交给
vercel-optimize(线上指标验证),或composition-patterns(组件架构调整)。
5. 输出规范
输出包含两段:
- 结构化工件:
PerfReview(按优先级排序的 findings 数组)。 - 自然语言摘要:关键几条 + 预期收益。
完整规则库(含 70 条规则名、before/after 范例、版本注意点)见
references/template.md。
6. 使用示例
输入:
这段代码很慢:
const user = await fetchUser(); const posts = await fetchPosts();怎么改?
输出(节选):
PerfReview.findings:[{ "rule": "async-parallel", "priority": 1, "impact": "CRITICAL", "file": "ProfilePage.tsx", "before": "const user=await fetchUser(); const posts=await fetchPosts();", "after": "const [user,posts]=await Promise.all([fetchUser(),fetchPosts()]);", "why": "无依赖的异步操作串行执行产生 3 次往返,改为并行只需 1 次" }]- 摘要:消除瀑布可带来 2–10× 提升;同批再检查
bundle-barrel-imports(避免从lucide-react整包导入)。
Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 70 条按影响排序的 React/Next.js 性能优化规则,直击瀑布请求、包体积等核心痛点
- 明确区分适用边界,避免与其他 Skill 功能重叠
Highlights
- description 精准描述核心功能,覆盖编写、评审、重构三大场景
- 边界定义清晰,排除 CSS 评审等非相关场景
Highlights
- 工作流四步骤清晰,含优先级判定、规则匹配、排序输出、版本校验
- 提供完整输入输出示例,结构化工件与自然语言摘要双输出
Areas to improve
-
Missing referenced files Reported severity: Major
SKILL.md 中引用了 references/template.md 文件,但未传入该文件
Recommendation: 请补充 references/template.md 文件,或将其内容内联至 SKILL.md 中
Highlights
- 步骤 4 包含版本兼容性校验,避免推荐不支持的 API
- 输出为建议清单,用户可自主决策,降低误操作风险
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.