1实现原理 · 为什么它能做到
机制是『脚手架+打包』两段式:init-artifact.sh 现场用 pnpm create vite 生成 React-TS 工程并安装 Tailwind/shadcn 依赖、解包预置的 43 个 shadcn/ui 组件;bundle-artifact.sh 用 Parcel 构建再用 html-inline 内联成单个 bundle.html。
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`
组件不是按需拉取而是随包交付:shadcn-components.tar.gz 内置 40+ 个 components/ui/*.tsx,离线解包即可用,避免逐组件 CLI 拉取。
✅ 40+ shadcn/ui components pre-installed
产物哲学=单个自包含 HTML:bundle.html 内联全部 JS/CSS/依赖,可直接作为 claude.ai 工件分享或浏览器打开。
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.
范围纪律:只服务『多组件/有状态/路由/复杂交互』工件,简单单文件 HTML/JSX 明确不在范围内(触发前先判断复杂度)。
Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.
测试/可视化被显式降级为可选后置步骤:避免在『用户还没看到成品』前增加延迟,有问题再测。
Note: This is a completely optional step. Only perform if necessary or requested.
样式防 'AI slop' 规则内置:显式禁止过度居中布局、紫色渐变、统一圆角与 Inter 字体。
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.
2核心能力
3外部依赖
| 类型 | 依赖 |
|---|---|
| network | npm registry(registry.npmjs.org) |
| package | create-vite / vite / tailwindcss@3.4.1 / postcss / autoprefixer / tailwindcss-animate / class-variance-authority / clsx / tailwind-merge / lucide-react / next-themes / @radix-ui/react-*(20+)/ sonner / cmdk / vaul / embla-carousel-react / react-day-picker / react-resizable-panels / date-fns / react-hook-form / zod |
| package | parcel / @parcel/config-default / parcel-resolver-tspaths / html-inline(打包期,bundle 脚本安装) |
| cli | node ≥18 / pnpm(宿主环境) |
4风险提醒 风险提醒:橙色 · 评估后使用
- 供应链执行面(主要) — 每次 init 都从 registry 拉取并执行多轮第三方包(含 create-vite latest 与 radix/parcel 生态);registry 侧投毒或依赖漂移会在本机执行恶意 install 脚本——建议锁版本/离线镜像/隔离环境。
- sed 未转义插值 — PROJECT_NAME 直接进 sed 替换串,特殊字符(&、/、\)可破坏脚本或产生意外替换(本地、agent/用户输入面)。
- 网络为运行必需 — 无网络环境无法 init(create vite/install 全走 registry);预置 tarball 只能缓解组件层。
- pnpm 读用户 npm 配置 — 宿主机器 ~/.npmrc 中的 registry 令牌可能被 pnpm 使用(宿主侧事实,非脚本显式读取),在共享机器上需注意。
- 产物内联一切 — bundle.html 会把全部依赖打进单个 HTML,体量大(脚本会报告体积);对超大门槛场景需权衡。
5第二遍独立确认
- [ok] 40+ 组件声称 vs tarball — tar -tzf 实测 43 个 components/ui/*.tsx(含 sonner/drawer/resizable),声称成立。
- [ok] init 脚本步骤与 SKILL 流程一致 — create vite(react-ts)→ 清理模板 → 装 tailwind/依赖 → 写 postcss/tailwind/vite/tsconfig → tar 解包,SKILL 描述可逐句对应。
- [ok] bundle 单文件化 — parcel build --no-source-maps + html-inline 输出 bundle.html;.parcelrc tspaths 配置存在。
- [ok] 网络外发对象 — 无自有端点/回调;全部为 pnpm→registry.npmjs.org(create-vite/tailwind/radix/parcel)。版本 pin:tailwindcss@3.4.1 固定,create-vite 与多数依赖取 latest——版本漂移与供应链留意点已在 reason 说明。
- [ok] 凭证读取 — skill 脚本零凭证读取;pnpm 读 ~/.npmrc 属包管理器宿主行为(已在 credential_reads 注明,非脚本显式读取)。
- [ok] PROJECT_NAME 注入点 — pnpm create vite "$PROJECT_NAME" 引号安全;sed 标题替换串未转义(& / \ 字符可破坏表达式)——本地低危输入面,已在 injection_surface 记录。
- [ok] Node 版本门禁 — 脚本有 NODE_VERSION < 18 拒绝与 Vite 版本 pin 逻辑,与 SKILL 'Node 18+ compatibility' 声称一致。
- [ok] 元数据 — 本地 HEAD==pin 41bbe19;Apache-2.0 LICENSE.txt。
6结论
c56ef465edf880ee…41bbe19d1a