Web Artifacts Builder
To build powerful frontend claude.ai artifacts, follow these steps:
- 1. Initialize the frontend repo using INLINECODE0
- Develop your artifact by editing the generated code
- Bundle all code into a single HTML file using INLINECODE1
- Display artifact to user
- (Optional) Test the artifact
Stack: React 18 + TypeScript + Vite + Parcel (bundling) + 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.
Quick Start
Step 1: Initialize Project
Run the initialization script to create a new React project:
CODEBLOCK0
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)
Step 2: Develop Your Artifact
To build the artifact, edit the generated files. See Common Development Tasks below for guidance.
Step 3: Bundle to Single HTML File
To bundle the React app into a single HTML artifact:
CODEBLOCK1
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
Step 4: Share Artifact with User
Finally, share the bundled HTML file in conversation with the user so they can view it as an artifact.
Step 5: Testing/Visualizing the Artifact (Optional)
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.
Reference
- - shadcn/ui components: https://ui.shadcn.com/docs/components
Web Artifacts Builder
要构建强大的前端claude.ai工件,请遵循以下步骤:
- 1. 使用 scripts/init-artifact.sh 初始化前端仓库
- 通过编辑生成的代码来开发你的工件
- 使用 scripts/bundle-artifact.sh 将所有代码打包到单个HTML文件中
- 向用户展示工件
- (可选)测试工件
技术栈:React 18 + TypeScript + Vite + Parcel(打包工具)+ Tailwind CSS + shadcn/ui
设计与样式指南
非常重要:为避免通常被称为AI 垃圾的问题,请避免使用过多的居中布局、紫色渐变、统一圆角和 Inter 字体。
快速开始
步骤 1:初始化项目
运行初始化脚本以创建新的 React 项目:
bash
bash scripts/init-artifact.sh <项目名称>
cd <项目名称>
这将创建一个完全配置好的项目,包含:
- - ✅ React + TypeScript(通过 Vite)
- ✅ Tailwind CSS 3.4.1 与 shadcn/ui 主题系统
- ✅ 路径别名(@/)已配置
- ✅ 预装了 40+ 个 shadcn/ui 组件
- ✅ 包含所有 Radix UI 依赖
- ✅ Parcel 已配置用于打包(通过 .parcelrc)
- ✅ Node 18+ 兼容性(自动检测并锁定 Vite 版本)
步骤 2:开发你的工件
要构建工件,请编辑生成的文件。有关指导,请参阅下面的常见开发任务。
步骤 3:打包到单个 HTML 文件
要将 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 中
步骤 4:与用户分享工件
最后,在对话中与用户分享打包后的 HTML 文件,以便他们可以将其作为工件查看。
步骤 5:测试/可视化工件(可选)
注意:这是一个完全可选的步骤。仅在必要时或应要求时执行。
要测试/可视化工件,请使用可用的工具(包括其他技能或内置工具,如 Playwright 或 Puppeteer)。通常,避免提前测试工件,因为这会在请求和看到完成的工件之间增加延迟。在展示工件后,如果被要求或出现问题,再进行测试。
参考
- - shadcn/ui 组件:https://ui.shadcn.com/docs/components