artifacts-builder

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Artifacts Builder

工件构建器

To build powerful frontend claude.ai artifacts, follow these steps:
  1. Initialize the frontend repo using
    scripts/init-artifact.sh
  2. Develop your artifact by editing the generated code
  3. Bundle all code into a single HTML file using
    scripts/bundle-artifact.sh
  4. Display artifact to user
  5. (Optional) Test the artifact
Stack: React 18 + TypeScript + Vite + Parcel (bundling) + Tailwind CSS + shadcn/ui
要构建功能强大的前端claude.ai工件,请遵循以下步骤:
  1. 使用
    scripts/init-artifact.sh
    初始化前端仓库
  2. 通过编辑生成的代码开发你的工件
  3. 使用
    scripts/bundle-artifact.sh
    将所有代码打包为单个HTML文件
  4. 向用户展示工件 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.sh
This creates
bundle.html
- a self-contained artifact with all JavaScript, CSS, and dependencies inlined. This file can be directly shared in Claude conversations as an artifact.
Requirements: Your project must have an
index.html
in the root directory.
What the script does:
  • Installs bundling dependencies (parcel, @parcel/config-default, parcel-resolver-tspaths, html-inline)
  • Creates
    .parcelrc
    config with path alias support
  • Builds with Parcel (no source maps)
  • Inlines all assets into single HTML using html-inline
要将React应用打包为单个HTML工件:
bash
bash scripts/bundle-artifact.sh
这会生成
bundle.html
——一个包含所有内联JavaScript、CSS和依赖的自包含工件。该文件可直接在Claude对话中作为工件分享。
要求:你的项目根目录必须有一个
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

参考资料