artifacts-builder
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseArtifacts Builder
工件构建工具
To build powerful frontend claude.ai artifacts, follow these steps:
- Initialize the frontend repo using
scripts/init-artifact.sh - Develop your artifact by editing the generated code
- Bundle all code into a single HTML file using
scripts/bundle-artifact.sh - Display artifact to user
- (Optional) Test the artifact
Stack: React 18 + TypeScript + Vite + Parcel (bundling) + Tailwind CSS + shadcn/ui
要构建功能强大的前端claude.ai工件,请按照以下步骤操作:
- 使用初始化前端仓库
scripts/init-artifact.sh - 通过编辑生成的代码开发你的工件
- 使用将所有代码打包为单个HTML文件
scripts/bundle-artifact.sh - 向用户展示工件 5.(可选)测试工件
技术栈:React 18 + TypeScript + Vite + Parcel(打包)+ Tailwind CSS + shadcn/ui
Design & Style Guidelines
设计与样式指南
VERY IMPORTANT: To avoid what is often referred to as "AI slop", avoid using excessive centered layouts, purple gradients, uniform rounded corners, and Inter font.
非常重要:为了避免所谓的“AI劣质设计”,请避免使用过多的居中布局、紫色渐变、统一圆角和Inter字体。
Quick Start
快速开始
Step 1: Initialize Project
步骤1:初始化项目
Run the initialization script to create a new React project:
bash
bash scripts/init-artifact.sh <project-name>
cd <project-name>This creates a fully configured project with:
- ✅ React + TypeScript (via Vite)
- ✅ Tailwind CSS 3.4.1 with shadcn/ui theming system
- ✅ Path aliases () configured
@/ - ✅ 40+ shadcn/ui components pre-installed
- ✅ All Radix UI dependencies included
- ✅ Parcel configured for bundling (via .parcelrc)
- ✅ Node 18+ compatibility (auto-detects and pins Vite version)
运行初始化脚本以创建新的React项目:
bash
bash scripts/init-artifact.sh <project-name>
cd <project-name>这将创建一个配置齐全的项目,包含:
- ✅ React + TypeScript(基于Vite)
- ✅ 带有shadcn/ui主题系统的Tailwind CSS 3.4.1
- ✅ 已配置路径别名()
@/ - ✅ 预安装40+个shadcn/ui组件
- ✅ 包含所有Radix UI依赖项
- ✅ 已配置Parcel用于打包(通过.parcelrc)
- ✅ 兼容Node 18+(自动检测并锁定Vite版本)
Step 2: Develop Your Artifact
步骤2:开发你的工件
To build the artifact, edit the generated files. See Common Development Tasks below for guidance.
要构建工件,请编辑生成的文件。请参阅下方的常见开发任务获取指导。
Step 3: Bundle to Single HTML File
步骤3:打包为单个HTML文件
To bundle the React app into a single HTML artifact:
bash
bash scripts/bundle-artifact.shThis creates - a self-contained artifact with all JavaScript, CSS, and dependencies inlined. This file can be directly shared in Claude conversations as an artifact.
bundle.htmlRequirements: Your project must have an in the root directory.
index.htmlWhat the script does:
- Installs bundling dependencies (parcel, @parcel/config-default, parcel-resolver-tspaths, html-inline)
- Creates config with path alias support
.parcelrc - Builds with Parcel (no source maps)
- Inlines all assets into single HTML using html-inline
要将React应用打包为单个HTML工件:
bash
bash scripts/bundle-artifact.sh这将生成——一个包含所有内联JavaScript、CSS和依赖项的独立工件。该文件可作为工件直接在Claude对话中共享。
bundle.html要求:你的项目根目录必须有一个文件。
index.html脚本功能:
- 安装打包依赖项(parcel、@parcel/config-default、parcel-resolver-tspaths、html-inline)
- 创建支持路径别名的配置文件
.parcelrc - 使用Parcel构建(不生成源映射)
- 使用html-inline将所有资源内联到单个HTML文件中
Step 4: Share Artifact with User
步骤4:与用户共享工件
Finally, share the bundled HTML file in conversation with the user so they can view it as an artifact.
最后,在与用户的对话中共享打包后的HTML文件,以便他们将其作为工件查看。
Step 5: Testing/Visualizing the Artifact (Optional)
步骤5:测试/可视化工件(可选)
Note: This is a completely optional step. Only perform if necessary or requested.
To test/visualize the artifact, use available tools (including other Skills or built-in tools like Playwright or Puppeteer). In general, avoid testing the artifact upfront as it adds latency between the request and when the finished artifact can be seen. Test later, after presenting the artifact, if requested or if issues arise.
注意:这是完全可选的步骤。仅在必要或用户要求时执行。
要测试/可视化工件,请使用可用工具(包括其他Skill或内置工具如Playwright或Puppeteer)。一般来说,避免提前测试工件,因为这会增加请求到成品工件可查看之间的延迟。如果用户要求或出现问题,请在展示工件后再进行测试。
Reference
参考资料
- shadcn/ui components: https://ui.shadcn.com/docs/components
- shadcn/ui组件:https://ui.shadcn.com/docs/components