Skip to content

Fantasia1999/skills-zh / translations/web-artifacts-builder

web-artifacts-builder

Verified

一套用于使用现代前端Web技术(React、Tailwind CSS、shadcn/ui)创建精细、多组件 claude.ai HTML 工件的工具集。适用于需要状态管理、路由或 shadcn/ui 组件的复杂工件 - 不适用于简单的单文件 HTML/JSX 工件。

FileKindSize
SKILL.mdskill md2.9 KB
---
name: web-artifacts-builder
description: 一套用于使用现代前端Web技术(React、Tailwind CSS、shadcn/ui)创建精细、多组件 claude.ai HTML 工件的工具集。适用于需要状态管理、路由或 shadcn/ui 组件的复杂工件 - 不适用于简单的单文件 HTML/JSX 工件。
license: 完整条款见 LICENSE.txt
---

# Web Artifacts Builder

要构建功能强大的前端 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

## 设计与风格指南

非常重要:为避免通常所说的“AI 垃圾内容”,请避免过度使用居中布局、紫色渐变、统一的圆角和 Inter 字体。

## 快速入门

### 第 1 步:初始化项目

运行初始化脚本以创建一个新的 React 项目:
```bash
bash scripts/init-artifact.sh <project-name>
cd <project-name>
```

这将创建一个完全配置好的项目,包含:
- ✅ 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 构建 (无 source maps)
- 使用 html-inline 将所有资源内联到单个 HTML 文件中

### 第 4 步:与用户共享工件

最后,在对话中与用户共享打包好的 HTML 文件,以便他们可以将其作为工件查看。

### 第 5 步:测试/可视化工具 (可选)

注意:这是一个完全可选的步骤。仅在必要或被请求时执行。

要测试/可视化该工件,请使用可用工具(包括其他技能或像 Playwright 或 Puppeteer 这样的内置工具)。通常,避免预先测试工件,因为这会增加从请求到看到成品工件之间的延迟。如果在呈现工件后被请求或出现问题,则稍后进行测试。

## 参考

- **shadcn/ui 组件**: https://ui.shadcn.com/docs/components
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall