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
Artifacts Builder
要构建强大的前端claude.ai artifacts,请遵循以下步骤:
- 1. 使用 scripts/init-artifact.sh 初始化前端仓库
- 通过编辑生成的代码来开发你的artifact
- 使用 scripts/bundle-artifact.sh 将所有代码打包到单个HTML文件中
- 向用户展示artifact
- (可选)测试artifact
技术栈:React 18 + TypeScript + Vite + Parcel(打包工具)+ Tailwind CSS + shadcn/ui
设计与样式指南
非常重要:为避免所谓的AI 生成痕迹,请避免过度使用居中布局、紫色渐变、统一圆角和Inter字体。
快速开始
第一步:初始化项目
运行初始化脚本创建新的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版本)
第二步:开发你的Artifact
要构建artifact,请编辑生成的文件。有关指导,请参阅下面的常见开发任务。
第三步:打包为单个HTML文件
要将React应用打包为单个HTML artifact:
bash
bash scripts/bundle-artifact.sh
这将创建 bundle.html - 一个自包含的artifact,所有JavaScript、CSS和依赖都已内联。该文件可以直接在Claude对话中作为artifact分享。
要求:你的项目根目录中必须有一个 index.html 文件。
脚本功能:
- - 安装打包依赖(parcel、@parcel/config-default、parcel-resolver-tspaths、html-inline)
- 创建支持路径别名的 .parcelrc 配置
- 使用Parcel构建(无源码映射)
- 使用html-inline将所有资源内联到单个HTML中
第四步:与用户分享Artifact
最后,在对话中与用户分享打包后的HTML文件,以便他们可以将其作为artifact查看。
第五步:测试/可视化Artifact(可选)
注意:这是完全可选的步骤。仅在必要或要求时执行。
要测试/可视化artifact,请使用可用工具(包括其他技能或内置工具,如Playwright或Puppeteer)。通常,避免预先测试artifact,因为这会在请求和看到完成的artifact之间增加延迟。在展示artifact后,如果被要求或出现问题,再进行测试。
参考
- - shadcn/ui组件:https://ui.shadcn.com/docs/components