@adonis0123/react-best-practices 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +91 -103
- package/install-skill.js +0 -0
- package/package.json +9 -9
- package/uninstall-skill.js +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agent Skill NPM Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,123 +1,111 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
A structured repository for creating and maintaining React Best Practices optimized for agents and LLMs.
|
|
4
|
-
|
|
5
|
-
## Structure
|
|
6
|
-
|
|
7
|
-
- `rules/` - Individual rule files (one per rule)
|
|
8
|
-
- `_sections.md` - Section metadata (titles, impacts, descriptions)
|
|
9
|
-
- `_template.md` - Template for creating new rules
|
|
10
|
-
- `area-description.md` - Individual rule files
|
|
11
|
-
- `src/` - Build scripts and utilities
|
|
12
|
-
- `metadata.json` - Document metadata (version, organization, abstract)
|
|
13
|
-
- __`AGENTS.md`__ - Compiled output (generated)
|
|
14
|
-
- __`test-cases.json`__ - Test cases for LLM evaluation (generated)
|
|
15
|
-
|
|
16
|
-
## Getting Started
|
|
17
|
-
|
|
18
|
-
1. Install dependencies:
|
|
19
|
-
```bash
|
|
20
|
-
pnpm install
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
2. Build AGENTS.md from rules:
|
|
24
|
-
```bash
|
|
25
|
-
pnpm build
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
3. Validate rule files:
|
|
29
|
-
```bash
|
|
30
|
-
pnpm validate
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
4. Extract test cases:
|
|
34
|
-
```bash
|
|
35
|
-
pnpm extract-tests
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Creating a New Rule
|
|
39
|
-
|
|
40
|
-
1. Copy `rules/_template.md` to `rules/area-description.md`
|
|
41
|
-
2. Choose the appropriate area prefix:
|
|
42
|
-
- `async-` for Eliminating Waterfalls (Section 1)
|
|
43
|
-
- `bundle-` for Bundle Size Optimization (Section 2)
|
|
44
|
-
- `server-` for Server-Side Performance (Section 3)
|
|
45
|
-
- `client-` for Client-Side Data Fetching (Section 4)
|
|
46
|
-
- `rerender-` for Re-render Optimization (Section 5)
|
|
47
|
-
- `rendering-` for Rendering Performance (Section 6)
|
|
48
|
-
- `js-` for JavaScript Performance (Section 7)
|
|
49
|
-
- `advanced-` for Advanced Patterns (Section 8)
|
|
50
|
-
3. Fill in the frontmatter and content
|
|
51
|
-
4. Ensure you have clear examples with explanations
|
|
52
|
-
5. Run `pnpm build` to regenerate AGENTS.md and test-cases.json
|
|
53
|
-
|
|
54
|
-
## Rule File Structure
|
|
55
|
-
|
|
56
|
-
Each rule file should follow this structure:
|
|
57
|
-
|
|
58
|
-
```markdown
|
|
59
|
-
---
|
|
60
|
-
title: Rule Title Here
|
|
61
|
-
impact: MEDIUM
|
|
62
|
-
impactDescription: Optional description
|
|
63
|
-
tags: tag1, tag2, tag3
|
|
64
|
-
---
|
|
1
|
+
# @adonis0123/react-best-practices
|
|
65
2
|
|
|
66
|
-
|
|
3
|
+
> Claude Code 技能 - React 和 Next.js 性能优化最佳实践(来自 Vercel Engineering)
|
|
67
4
|
|
|
68
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@adonis0123/react-best-practices)
|
|
69
6
|
|
|
70
|
-
|
|
7
|
+
**原始项目**: [vercel-labs/agent-skills/react-best-practices](https://github.com/vercel-labs/agent-skills/tree/main/skills/react-best-practices)
|
|
71
8
|
|
|
72
|
-
|
|
73
|
-
// Bad code example
|
|
74
|
-
```
|
|
9
|
+
## 安装
|
|
75
10
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
// Good code example
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g @adonis0123/react-best-practices
|
|
80
13
|
```
|
|
81
14
|
|
|
82
|
-
|
|
15
|
+
## 使用
|
|
83
16
|
|
|
84
|
-
|
|
17
|
+
安装后,Claude Code 在编写或审查 React/Next.js 代码时会自动应用这些最佳实践。
|
|
85
18
|
|
|
86
|
-
##
|
|
19
|
+
## 规则分类
|
|
87
20
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
21
|
+
| 优先级 | 分类 | 影响 |
|
|
22
|
+
|--------|------|------|
|
|
23
|
+
| 1 | 消除瀑布流 | 关键 |
|
|
24
|
+
| 2 | 包体积优化 | 关键 |
|
|
25
|
+
| 3 | 服务端性能 | 高 |
|
|
26
|
+
| 4 | 客户端数据获取 | 中高 |
|
|
27
|
+
| 5 | 重渲染优化 | 中 |
|
|
28
|
+
| 6 | 渲染性能 | 中 |
|
|
29
|
+
| 7 | JavaScript 性能 | 低中 |
|
|
30
|
+
| 8 | 高级模式 | 低 |
|
|
93
31
|
|
|
94
|
-
##
|
|
32
|
+
## 核心规则
|
|
95
33
|
|
|
96
|
-
|
|
97
|
-
- `
|
|
98
|
-
- `
|
|
99
|
-
- `MEDIUM` - Moderate performance improvements
|
|
100
|
-
- `LOW-MEDIUM` - Low-medium gains
|
|
101
|
-
- `LOW` - Incremental improvements
|
|
34
|
+
### 消除瀑布流(关键)
|
|
35
|
+
- `async-parallel` - 使用 Promise.all() 并行请求
|
|
36
|
+
- `async-suspense-boundaries` - 使用 Suspense 流式传输
|
|
102
37
|
|
|
103
|
-
|
|
38
|
+
### 包体积优化(关键)
|
|
39
|
+
- `bundle-barrel-imports` - 避免 barrel 文件,直接导入
|
|
40
|
+
- `bundle-dynamic-imports` - 使用 next/dynamic 懒加载
|
|
104
41
|
|
|
105
|
-
|
|
106
|
-
- `
|
|
107
|
-
- `
|
|
108
|
-
- `pnpm dev` - Build and validate
|
|
42
|
+
### 服务端性能(高)
|
|
43
|
+
- `server-cache-react` - 使用 React.cache() 去重
|
|
44
|
+
- `server-parallel-fetching` - 并行获取数据
|
|
109
45
|
|
|
110
|
-
|
|
46
|
+
### 重渲染优化(中)
|
|
47
|
+
- `rerender-memo` - 提取昂贵计算到 memo 组件
|
|
48
|
+
- `rerender-functional-setstate` - 使用函数式 setState
|
|
111
49
|
|
|
112
|
-
|
|
50
|
+
## 包含内容
|
|
113
51
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
4. Add appropriate tags
|
|
118
|
-
5. Run `pnpm build` to regenerate AGENTS.md and test-cases.json
|
|
119
|
-
6. Rules are automatically sorted by title - no need to manage numbers!
|
|
52
|
+
- 45 条优化规则
|
|
53
|
+
- 每条规则包含错误/正确代码示例
|
|
54
|
+
- 详细的影响说明
|
|
120
55
|
|
|
121
|
-
##
|
|
56
|
+
## 致谢
|
|
122
57
|
|
|
123
58
|
Originally created by [@shuding](https://x.com/shuding) at [Vercel](https://vercel.com).
|
|
59
|
+
|
|
60
|
+
## 更多技能
|
|
61
|
+
|
|
62
|
+
- [@adonis0123/weekly-report](https://www.npmjs.com/package/@adonis0123/weekly-report) - 周报生成
|
|
63
|
+
- [@adonis0123/agent-browser](https://www.npmjs.com/package/@adonis0123/agent-browser) - 浏览器自动化
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 开发者文档
|
|
68
|
+
|
|
69
|
+
以下是原始项目的开发文档,供贡献者参考。
|
|
70
|
+
|
|
71
|
+
### 项目结构
|
|
72
|
+
|
|
73
|
+
- `rules/` - 独立规则文件(每条规则一个文件)
|
|
74
|
+
- `_sections.md` - 分类元数据(标题、影响、描述)
|
|
75
|
+
- `_template.md` - 创建新规则的模板
|
|
76
|
+
- `area-description.md` - 独立规则文件
|
|
77
|
+
- `AGENTS.md` - 编译输出(自动生成)
|
|
78
|
+
|
|
79
|
+
### 规则文件命名
|
|
80
|
+
|
|
81
|
+
- 以 `_` 开头的文件是特殊文件(不参与构建)
|
|
82
|
+
- 规则文件格式:`area-description.md`(如 `async-parallel.md`)
|
|
83
|
+
- 分类根据文件名前缀自动推断
|
|
84
|
+
- 规则按标题字母顺序排序
|
|
85
|
+
- ID(如 1.1, 1.2)在构建时自动生成
|
|
86
|
+
|
|
87
|
+
### 区域前缀
|
|
88
|
+
|
|
89
|
+
| 前缀 | 分类 |
|
|
90
|
+
|------|------|
|
|
91
|
+
| `async-` | 消除瀑布流(Section 1)|
|
|
92
|
+
| `bundle-` | 包体积优化(Section 2)|
|
|
93
|
+
| `server-` | 服务端性能(Section 3)|
|
|
94
|
+
| `client-` | 客户端数据获取(Section 4)|
|
|
95
|
+
| `rerender-` | 重渲染优化(Section 5)|
|
|
96
|
+
| `rendering-` | 渲染性能(Section 6)|
|
|
97
|
+
| `js-` | JavaScript 性能(Section 7)|
|
|
98
|
+
| `advanced-` | 高级模式(Section 8)|
|
|
99
|
+
|
|
100
|
+
### 影响级别
|
|
101
|
+
|
|
102
|
+
- `CRITICAL` - 最高优先级,重大性能提升
|
|
103
|
+
- `HIGH` - 显著性能改进
|
|
104
|
+
- `MEDIUM-HIGH` - 中高收益
|
|
105
|
+
- `MEDIUM` - 中等性能改进
|
|
106
|
+
- `LOW-MEDIUM` - 低中收益
|
|
107
|
+
- `LOW` - 增量改进
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
MIT
|
package/install-skill.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis0123/react-best-practices",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Claude Code Skill - React 和 Next.js 性能优化最佳实践指南,来自 Vercel Engineering",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"postinstall": "node install-skill.js",
|
|
7
|
-
"preuninstall": "node uninstall-skill.js",
|
|
8
|
-
"test": "node install-skill.js && echo 'Installation test completed.'"
|
|
9
|
-
},
|
|
10
5
|
"files": [
|
|
11
6
|
"SKILL.md",
|
|
12
7
|
"AGENTS.md",
|
|
@@ -30,8 +25,13 @@
|
|
|
30
25
|
"license": "MIT",
|
|
31
26
|
"repository": {
|
|
32
27
|
"type": "git",
|
|
33
|
-
"url": "https://github.com/Adonis0123/
|
|
28
|
+
"url": "git+https://github.com/Adonis0123/agent-skill-npm-boilerplate.git",
|
|
34
29
|
"directory": "packages/react-best-practices"
|
|
35
30
|
},
|
|
36
|
-
"homepage": "https://github.com/Adonis0123/
|
|
37
|
-
|
|
31
|
+
"homepage": "https://github.com/Adonis0123/agent-skill-npm-boilerplate/tree/main/packages/react-best-practices",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"postinstall": "node install-skill.js",
|
|
34
|
+
"preuninstall": "node uninstall-skill.js",
|
|
35
|
+
"test": "node install-skill.js && echo 'Installation test completed.'"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/uninstall-skill.js
CHANGED
|
File without changes
|