Artifacts Builder
Builds multi-component claude.ai HTML artifacts with React, Tailwind, and shared UI.
by shipshitdev · Apache-2.0
The skill
Builds multi-component claude.ai HTML artifacts with React, Tailwind, and shared UI. Use for complex artifacts needing state management, not simple single-file HTML.
Artifacts Builder
To build claude.ai artifacts, follow these steps:
- Initialize the frontend repo using
scripts/init-artifact.sh - Develop your artifact by editing the generated code
- Bundle all code into a single HTML file using
scripts/bundle-artifact.sh - Display artifact to user
- (Optional) Test the artifact
Stack: React 19 + TypeScript + Vite + Tailwind CSS v4 + shadcn/ui (Radix), installed and run with Bun. Bundling: vite-plugin-singlefile.
Requirements: Bun and Node.js 20.19+ or 22.12+ (the Vite minimum; the init script rejects anything older).
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 (it refuses a project name that already exists and is not an empty directory):
bash scripts/init-artifact.sh <project-name>
cd <project-name>
This creates a fully configured project with:
- ✅ React + TypeScript (via
bun create vite) - ✅ Tailwind CSS v4, CSS-first:
@import "tailwindcss"insrc/index.css, tokens in@theme inline, the@tailwindcss/viteplugin, notailwind.config.* - ✅ shadcn/ui initialized (
components.json, OKLCH theme variables,cnutility,tw-animate-css) with the full component set insrc/components/ui - ✅ Path alias (
@/) configured in tsconfig and Vite - ✅ A starter
src/App.tsxusingButtonandCard
Add or refresh components later with bunx shadcn@latest add <component>.
Step 2: Develop Your Artifact
To build the artifact, edit the generated files.
Step 3: Bundle to Single HTML File
To bundle the React app into a single HTML artifact:
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
vite-plugin-singlefile,parse5andcss-tree(exact, pinned) as dev dependencies when they are missing, under a lock so concurrent runs in one project cannot race - Writes
vite.singlefile.config.ts, which extends yourvite.config.*and inlines all JS, CSS, fonts and assets intoindex.html - Runs
bunx vite buildwith that config and a per-run--outDir(object, promise or function-stylevite.config.*all work, and a retained customvite.singlefile.config.tsis honoured even if it hard-codesbuild.outDir) - Inlines the files that the HTML or CSS reference (images, fonts, icons, valid
srcset/imagesrcsetcandidates, linked stylesheets and@importtargets processed as CSS whatever their extension, and their ownurl()dependencies resolved against the stylesheet's URL directory) as data URIs, keeping#fragments, and fails with the list of any local reference it cannot inline - Parses HTML with
parse5(browser-grade tokenizing:<!-->comment recovery, any-case and unquoted attributes, character references such as©,€) and writes it back so it parses to the same DOM (leading newline ofpre,textareaandlisting, doctype identifiers kept). CSS is tokenized with the CSS Syntax 3 tokenizer fromcss-tree:url(),URL(),u\72l(),@import/@IMPORTand image-set strings count, whilecontent:"url(x)"and comments do not, and CSS escapes follow the spec (\61followed by NBSP keeps the NBSP). A malformedurl()token fails the bundle. srcset candidates with invalid descriptors (0w,1x 2x,100w 2x, ...) are discarded like a browser does, while a valid candidate that is missing still fails - Builds in a private temporary work directory per run, so concurrent runs do not collide. Every referenced file is first copied into a private snapshot directory (mode 0700, deleted afterwards), walking the path component by component and rejecting symlinks, hard-linked files and non-regular files in the build and in
public/; inlining reads only the snapshot, so swapping a parent directory during inlining cannot inject other bytes - Writes HTML back so it parses to the same DOM, and checks that by reparsing the output (document mode, namespaces, attributes, every script and style element): rewritten CSS strings escape
<and>, data-URI fragments are percent-encoded, and any difference (for example a<plaintext>element) fails the bundle instead of changing the page - Serializes dependency installs with a lock directory that records its owner (pid and start time); a lock left by a killed run is detected and taken over
- Replaces
bundle.htmlonly after every step succeeded, so a failed build never destroys the previous bundle
Threat model: the confinement covers symlinks and hard links committed in the project (and anything a malicious page, stylesheet or public/ tree can reference). It is not a defense against a concurrent local attacker who races the snapshot copy itself while the script runs.
Files referenced only by hard-coded path strings inside JavaScript are not detected: import them from code (Vite inlines those) or reference them from the HTML or CSS.
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)
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: https://ui.shadcn.com/docs (see also the
shadcnandtailwindskills in this marketplace)
Use this skill
Connect your agent to the Skill Store MCP server and ask for it by ref: shipshitdev/artifacts-builder-99148531285.
Details
- Publisher
- shipshitdev
- Category
- Software Development › Frontend & UI
- License
- Apache-2.0
- Updated
- 2026-10-17
References
More from shipshitdev
- Readme Sync Regenerate catalog counts, layout claims, and README summaries from canonical sources.
- Skill Auditor Audit the skills library for duplicates, stale content, spec violations, and structural issues.
- Skill Validator Validate SKILL.md files against the Agent Skills spec and Claude Code extensions.
- Agent Dispatch Router behind /agent.