-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add rsbuild-docs skill #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "skill_name": "rsbuild-docs", | ||
| "evals": [ | ||
| { | ||
| "id": 0, | ||
| "prompt": "我在用 Rsbuild,想把 /api 开头的请求代理到 http://localhost:3000,怎么配置?", | ||
| "expected_output": "Should explain dev.proxy or server.proxy config with a concrete code example", | ||
| "files": [], | ||
| "assertions": [] | ||
| }, | ||
| { | ||
| "id": 1, | ||
| "prompt": "Rsbuild 里怎么修改 CSS Modules 生成的类名格式?比如我想用 [name]__[local] 这种格式", | ||
| "expected_output": "Should explain output.cssModules.localIdentName config with code example", | ||
| "files": [], | ||
| "assertions": [] | ||
| }, | ||
| { | ||
| "id": 2, | ||
| "prompt": "我有一个 Create React App 项目想迁移到 Rsbuild,大概要怎么做?有什么需要注意的?", | ||
| "expected_output": "Should provide step-by-step CRA migration guide based on the official migration doc", | ||
| "files": [], | ||
| "assertions": [] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| { | ||
| "metadata": { | ||
| "skill_name": "rsbuild-docs", | ||
| "skill_path": "/Users/bytedance/Documents/codes/agent-skills/skills/rsbuild-docs/SKILL.md", | ||
| "executor_model": "claude-opus-4-6", | ||
| "timestamp": "2026-03-10T11:51:37Z", | ||
| "evals_run": ["dev-proxy-config", "css-modules-classname"], | ||
| "runs_per_configuration": 1, | ||
| "note": "CRA migration eval was skipped due to rate limit" | ||
| }, | ||
| "runs": [ | ||
| { | ||
| "eval_name": "dev-proxy-config", | ||
| "eval_id": 0, | ||
| "prompt": "我在用 Rsbuild,想把 /api 开头的请求代理到 http://localhost:3000,怎么配置?", | ||
| "configurations": [ | ||
| { | ||
| "name": "with_skill", | ||
| "pass_rate": 1.0, | ||
| "passed": 4, | ||
| "total": 4, | ||
| "time_seconds": 42.5, | ||
| "tokens": 12091, | ||
| "expectations": [ | ||
| { | ||
| "text": "Has concrete rsbuild.config code snippet with proxy", | ||
| "passed": true, | ||
| "evidence": "Multiple server.proxy examples" | ||
| }, | ||
| { | ||
| "text": "Mentions correct config path (server.proxy)", | ||
| "passed": true, | ||
| "evidence": "Uses server.proxy throughout" | ||
| }, | ||
| { | ||
| "text": "Correctly maps /api to http://localhost:3000", | ||
| "passed": true, | ||
| "evidence": "'/api': 'http://localhost:3000'" | ||
| }, | ||
| { | ||
| "text": "Sourced from fetched docs", | ||
| "passed": true, | ||
| "evidence": "References rsbuild.rs/config/server/proxy" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "without_skill", | ||
| "pass_rate": 0.75, | ||
| "passed": 3, | ||
| "total": 4, | ||
| "time_seconds": 19.8, | ||
| "tokens": 9076, | ||
| "expectations": [ | ||
| { | ||
| "text": "Has concrete rsbuild.config code snippet with proxy", | ||
| "passed": true, | ||
| "evidence": "Multiple server.proxy examples" | ||
| }, | ||
| { | ||
| "text": "Mentions correct config path (server.proxy)", | ||
| "passed": true, | ||
| "evidence": "Uses server.proxy throughout" | ||
| }, | ||
| { | ||
| "text": "Correctly maps /api to http://localhost:3000", | ||
| "passed": true, | ||
| "evidence": "'/api': 'http://localhost:3000'" | ||
| }, | ||
| { | ||
| "text": "Sourced from fetched docs", | ||
| "passed": false, | ||
| "evidence": "No docs fetched, model knowledge only" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "eval_name": "css-modules-classname", | ||
| "eval_id": 1, | ||
| "prompt": "Rsbuild 里怎么修改 CSS Modules 生成的类名格式?比如我想用 [name]__[local] 这种格式", | ||
| "configurations": [ | ||
| { | ||
| "name": "with_skill", | ||
| "pass_rate": 1.0, | ||
| "passed": 4, | ||
| "total": 4, | ||
| "time_seconds": 44.3, | ||
| "tokens": 12796, | ||
| "expectations": [ | ||
| { | ||
| "text": "Has concrete cssModules config code snippet", | ||
| "passed": true, | ||
| "evidence": "Shows output.cssModules block" | ||
| }, | ||
| { | ||
| "text": "Mentions correct config path (output.cssModules.localIdentName)", | ||
| "passed": true, | ||
| "evidence": "Correctly identified" | ||
| }, | ||
| { | ||
| "text": "Shows [name]__[local] pattern", | ||
| "passed": true, | ||
| "evidence": "localIdentName: '[name]__[local]'" | ||
| }, | ||
| { | ||
| "text": "Sourced from fetched docs", | ||
| "passed": true, | ||
| "evidence": "References rsbuild.rs/config/output/css-modules" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "without_skill", | ||
| "pass_rate": 0.75, | ||
| "passed": 3, | ||
| "total": 4, | ||
| "time_seconds": 23.2, | ||
| "tokens": 9227, | ||
| "expectations": [ | ||
| { | ||
| "text": "Has concrete cssModules config code snippet", | ||
| "passed": true, | ||
| "evidence": "Shows output.cssModules block" | ||
| }, | ||
| { | ||
| "text": "Mentions correct config path (output.cssModules.localIdentName)", | ||
| "passed": true, | ||
| "evidence": "Correctly identified" | ||
| }, | ||
| { | ||
| "text": "Shows [name]__[local] pattern", | ||
| "passed": true, | ||
| "evidence": "localIdentName: '[name]__[local]'" | ||
| }, | ||
| { | ||
| "text": "Sourced from fetched docs", | ||
| "passed": false, | ||
| "evidence": "No docs fetched, model knowledge only. Production default may be inaccurate." | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "run_summary": { | ||
| "with_skill": { | ||
| "mean_pass_rate": 1.0, | ||
| "mean_time_seconds": 43.4, | ||
| "mean_tokens": 12444 | ||
| }, | ||
| "without_skill": { | ||
| "mean_pass_rate": 0.75, | ||
| "mean_time_seconds": 21.5, | ||
| "mean_tokens": 9152 | ||
| }, | ||
| "delta": { | ||
| "pass_rate": "+0.25", | ||
| "time_seconds": "+21.9", | ||
| "tokens": "+3292" | ||
| } | ||
| }, | ||
| "notes": [ | ||
| "With-skill achieves 100% pass rate vs 75% without skill — the difference is doc sourcing", | ||
| "With-skill takes ~2x longer and ~40% more tokens due to fetching llms.txt index + specific doc pages", | ||
| "Both versions produce correct config paths and code for these common Rsbuild topics — the model's built-in knowledge is quite good for Rsbuild basics", | ||
| "The skill's main value add is verifiable accuracy (doc sourcing) rather than correctness delta on common topics", | ||
| "CRA migration eval (skipped due to rate limit) would likely show larger correctness delta as migration guides have more specific steps" | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Skill Benchmark: rsbuild-docs | ||
|
|
||
| **Model**: <model-name> | ||
| **Date**: 2026-03-10T11:51:37Z | ||
| **Evals**: (3 runs each per configuration) | ||
|
|
||
|
Comment on lines
+3
to
+6
|
||
| ## Summary | ||
|
|
||
| | Metric | Config A | Config B | Delta | | ||
| | --------- | ----------- | ----------- | ----- | | ||
| | Pass Rate | 0% ± 0% | 0% ± 0% | +0.00 | | ||
| | Time | 0.0s ± 0.0s | 0.0s ± 0.0s | +0.0s | | ||
| | Tokens | 0 ± 0 | 0 ± 0 | +0 | | ||
|
Comment on lines
+9
to
+13
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "eval_id": 2, | ||
| "eval_name": "cra-migration", | ||
| "prompt": "我有一个 Create React App 项目想迁移到 Rsbuild,大概要怎么做?有什么需要注意的?", | ||
| "assertions": [ | ||
| { | ||
| "text": "Response provides step-by-step migration instructions", | ||
| "type": "content" | ||
| }, | ||
| { | ||
| "text": "Response mentions installing @rsbuild/core and @rsbuild/plugin-react", | ||
| "type": "content" | ||
| }, | ||
| { | ||
| "text": "Response mentions updating package.json scripts (dev/build commands)", | ||
| "type": "content" | ||
| }, | ||
| { | ||
| "text": "Response mentions creating rsbuild.config file", | ||
| "type": "content" | ||
| }, | ||
| { | ||
| "text": "Information is sourced from fetched docs, not hallucinated", | ||
| "type": "accuracy" | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| # 从 Create React App 迁移到 Rsbuild | ||
|
|
||
| ## 概述 | ||
|
|
||
| Rsbuild 是基于 Rspack 的构建工具,提供了与 CRA 类似的开箱即用体验,但构建速度大幅提升。以下是迁移的主要步骤和注意事项。 | ||
|
|
||
| ## 迁移步骤 | ||
|
|
||
| ### 1. 安装依赖 | ||
|
|
||
| ```bash | ||
| npm install @rsbuild/core @rsbuild/plugin-react -D | ||
| ``` | ||
|
|
||
| 然后移除 CRA 相关依赖: | ||
|
|
||
| ```bash | ||
| npm uninstall react-scripts | ||
| ``` | ||
|
|
||
| ### 2. 创建 Rsbuild 配置文件 | ||
|
|
||
| 在项目根目录创建 `rsbuild.config.ts`: | ||
|
|
||
| ```ts | ||
| import { defineConfig } from '@rsbuild/core'; | ||
| import { pluginReact } from '@rsbuild/plugin-react'; | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [pluginReact()], | ||
| source: { | ||
| // CRA 默认入口是 src/index,Rsbuild 也是,通常不需要改 | ||
| // entry: { index: './src/index.tsx' }, | ||
| }, | ||
| html: { | ||
| // 如果你有自定义的 HTML 模板 | ||
| template: './public/index.html', | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| ### 3. 更新 package.json 中的 scripts | ||
|
|
||
| 将 `package.json` 中的脚本替换: | ||
|
|
||
| ```json | ||
| { | ||
| "scripts": { | ||
| "start": "rsbuild dev", | ||
| "build": "rsbuild build", | ||
| "preview": "rsbuild preview" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### 4. 处理 HTML 模板 | ||
|
|
||
| CRA 使用 `public/index.html` 作为模板,其中使用 `%PUBLIC_URL%` 这样的占位符。Rsbuild 中需要做调整: | ||
|
|
||
| - 将 `%PUBLIC_URL%/` 替换为空字符串或 `/`,因为 Rsbuild 会自动处理公共路径。 | ||
| - 例如把 `%PUBLIC_URL%/favicon.ico` 改为 `/favicon.ico`。 | ||
|
|
||
| ### 5. 处理环境变量 | ||
|
|
||
| CRA 中以 `REACT_APP_` 为前缀的环境变量会自动注入到客户端代码中。Rsbuild 中默认前缀是 `PUBLIC_`,你可以通过配置修改: | ||
|
|
||
| ```ts | ||
| export default defineConfig({ | ||
| source: { | ||
| define: { | ||
| // 手动定义需要的环境变量 | ||
| }, | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| 或者使用 `loadEnv` 工具函数来加载 `.env` 文件中的变量。如果你想保持 `REACT_APP_` 前缀的兼容性,可以配置 `source.envPrefix`: | ||
|
|
||
| ```ts | ||
| export default defineConfig({ | ||
| source: { | ||
| envPrefix: ['REACT_APP_'], | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| ### 6. 处理 public 目录 | ||
|
|
||
| CRA 中 `public` 目录下的静态资源会被复制到构建输出。Rsbuild 同样支持这个特性,默认会处理 `public` 目录,通常不需要额外配置。 | ||
|
|
||
| ### 7. 处理 SVG 导入 | ||
|
|
||
| CRA 支持将 SVG 作为 React 组件导入(`import { ReactComponent as Logo } from './logo.svg'`)。Rsbuild 中需要安装 SVGR 插件: | ||
|
|
||
| ```bash | ||
| npm install @rsbuild/plugin-svgr -D | ||
| ``` | ||
|
|
||
| 然后在配置中添加: | ||
|
|
||
| ```ts | ||
| import { pluginSvgr } from '@rsbuild/plugin-svgr'; | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [ | ||
| pluginReact(), | ||
| pluginSvgr({ | ||
| mixedImport: true, | ||
| }), | ||
| ], | ||
| }); | ||
| ``` | ||
|
|
||
| 这样你可以继续使用 named import 的方式导入 SVG 作为组件。 | ||
|
|
||
| ### 8. 处理 CSS/样式 | ||
|
|
||
| - **CSS Modules**:CRA 中 `.module.css` / `.module.scss` 文件会被当作 CSS Modules。Rsbuild 也默认支持这种约定,无需额外配置。 | ||
| - **Sass/Less**:如果使用 Sass,安装对应插件: | ||
| ```bash | ||
| npm install @rsbuild/plugin-sass -D | ||
| ``` | ||
| 然后在配置中引入 `pluginSass()`。Less 同理,使用 `@rsbuild/plugin-less`。 | ||
|
|
||
| ### 9. TypeScript 支持 | ||
|
|
||
| Rsbuild 内置了 TypeScript 支持,CRA 项目中的 `tsconfig.json` 一般可以直接使用。需要注意: | ||
|
|
||
| - CRA 的 `tsconfig.json` 中可能有 `paths` 别名配置(如 `src/*`),需要在 Rsbuild 中对应配置 `source.alias`。 | ||
| - CRA 中 `react-app-env.d.ts` 的类型声明可以删除,替换为 Rsbuild 提供的类型引用。 | ||
|
|
||
| ## 注意事项 | ||
|
|
||
| 1. **Webpack 特有的语法**:如果代码中使用了 `require.context`、webpack-specific 的 magic comments 等,需要检查 Rspack 的兼容情况。Rspack 对大部分 webpack API 有兼容支持,但个别 API 可能不同。 | ||
|
|
||
| 2. **Proxy 配置**:CRA 中在 `package.json` 里配置的 `proxy` 字段或 `src/setupProxy.js`,需要迁移到 Rsbuild 的 `server.proxy` 配置中。 | ||
|
|
||
| 3. **测试**:`react-scripts test` 使用的是 Jest。迁移后你需要单独配置 Jest 或改用 Vitest 等测试框架,因为 Rsbuild 本身不包含测试功能。 | ||
|
|
||
| 4. **eject 过的项目**:如果你的 CRA 项目已经 eject,那么你可能有大量自定义 webpack 配置,迁移时需要逐一检查并找到 Rsbuild/Rspack 中的对应配置。 | ||
|
|
||
| 5. **Babel 插件**:CRA 内置了一些 Babel 配置。Rsbuild 默认使用 SWC 进行编译,速度更快。如果你依赖特定的 Babel 插件,可以通过 `@rsbuild/plugin-babel` 来使用 Babel,但建议尽量迁移到 SWC 以获得更好的性能。 | ||
|
|
||
| 6. **browserslist**:CRA 在 `package.json` 中设置了 browserslist。Rsbuild 也会读取 browserslist 配置,可以保留或根据需要调整。 | ||
|
|
||
| 7. **构建输出目录**:CRA 默认输出到 `build` 目录,Rsbuild 默认输出到 `dist` 目录。如果你的部署流程依赖 `build` 目录,可以通过 `output.distPath.root` 来修改。 | ||
|
|
||
| ## 总结 | ||
|
|
||
| 从 CRA 迁移到 Rsbuild 总体来说比较平滑,因为两者的设计理念相似——都是开箱即用的 React 构建工具。主要工作集中在:替换依赖和脚本、处理环境变量前缀、处理 SVG 导入方式、以及迁移代理和特殊 webpack 配置。迁移后你会获得显著的构建速度提升。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skill_pathcontains a machine-specific absolute path (including a username). This leaks local environment details and isn’t portable; consider removing this field or storing a repo-relative path (e.g.,skills/rsbuild-docs/SKILL.md).