web-artifacts-builder
Build a self-contained web page, dashboard, prototype, calculator or small interactive tool as ONE HTML file (plain HTML/CSS/JS, or React plus Tailwind bundled into a single file), check it, and preview it locally. Use when the user wants a page they can open, share as a file, or iterate on in a browser.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 5
- Forks
- 2
01 前言 Front Matter
- name
- web-artifacts-builder
- invocation
- model+user
- description
- Build a self-contained web page, dashboard, prototype, calculator or small interactive tool as ONE HTML file (plain HTML/CSS/JS, or React plus Tailwind bundled into a single file), check it, and preview it locally. Use when the user wants a page they can open, share as a file, or iterate on in a browser.
03 SKILL.md 正文
Web artifacts builder
An artifact here is one .html file that opens from disk, an email attachment
or any static host, with nothing else to install or serve. You build it locally,
check it, preview it on loopback and hand back the file. This skill never
publishes or deploys anything.
The installed scripts/wab.mjs (Node 22+, no dependencies) scaffolds, checks,
builds and previews. Find the installed plugin directory with
/plugin show web-artifacts-builder; do not assume the process cwd. Call it as
node <plugin-dir>/scripts/wab.mjs <command>.
Choose the smallest tier that fits
- Single file, no build. Plain HTML, CSS and a script block. Use this for most pages: a calculator, a report, a one-screen tool, a visual explainer. No network, no dependencies, opens instantly. Start here unless state or component reuse is genuinely getting complicated.
- React + Tailwind, bundled to one file. Use it when the page has many
interacting components or non-trivial state. It needs Node, npm and the npm
registry once (
npm install), then produces the same singledist/index.html. Tell the user thatbuilddownloads packages before you run it.
Do not load React, Tailwind or fonts from a CDN in a "single file". That page
fails offline, behind a firewall and when the CDN changes. If the user insists
on a CDN, say what it costs and run check --allow-network.
Workflow
- Pin the job. One sentence: who opens this, what they do, what data it shows. Ask only if the answer changes the design. Real content beats lorem ipsum; if you lack data, build with clearly labelled sample data the user can replace, and keep it in one object at the top of the script.
- Scaffold.
wab.mjs new <dir> --template single|react --title "Name". The directory must be new or empty. Read the generated file before editing it. - Write the page. Follow the build rules below. Replace the starter content entirely; do not ship the starter's checklist.
- Build (react only).
wab.mjs build <dir>runsnpm installif needed andnpm run build, leaving<dir>/dist/index.html. Report any npm failure with its output instead of guessing. - Check.
wab.mjs check <file.html>. It fails on: missing doctype, title or viewport, unreplaced placeholders, files over the size limit, anysrc/hrefto a separate file, any network-loaded resource, and strings shaped like API keys or private keys. Fix every error. A warning needs a reason to keep it. - Preview and look.
wab.mjs preview <file-or-dir>serves on127.0.0.1and prints the URL; it keeps running until stopped, so start it in the background. If a browser tool is available (the Browser pane, Chromewhale, Computer Use or a Playwright MCP), open the URL, read the console for errors, exercise each control once, and view it at phone width (about 375 px) and desktop width. If none is available, say you could only run the static check and could not look at the rendered page. - Hand back the absolute path of the single file, what you verified and what you did not. Stop the preview server.
Build rules
- Self-contained. Inline CSS and JS. Images are inline SVG or
data:URIs. Use the system font stack unless the user supplies a font to embed. - No secrets, no private data. Anything in the file is readable by whoever
receives it. Never paste credentials, tokens or private records into the page.
checkcatches common key shapes, not all secrets. - No network at runtime by default. Do not call APIs from the page unless the user asked and understands the endpoint receives their visitors' requests. Never embed an API key in client-side code.
- Responsive. Works at 375 px wide without horizontal scroll. Use fluid
widths,
min-width: 0on flex children and a 16 px minimum body size. - Light and dark. Define colors as CSS variables and swap them under
prefers-color-scheme: dark. Set the background explicitly. - Accessible by default. Real
<button>,<label>,<main>and heading order; visible:focus-visibleoutlines; text contrast of at least 4.5:1; state changes announced witharia-livewhere the user would otherwise miss them; motion respectsprefers-reduced-motion. - Persist only what is safe.
localStoragecan be blocked or full, so wrap every read and write intry/catchand render correctly without it. - Decide on the look. Pick a point of view (editorial, instrument panel, paper, terminal) and commit to a small palette, one type scale and consistent spacing. Avoid the default template look: purple gradient hero, three identical cards, emoji as icons.
- Small is a feature. Aim well under 200 KB for a single-file page. If React pushes it near the 1 MB limit, you probably wanted tier 1.
Failure recovery
npm installfails or there is no network: fall back to tier 1, or ask the user to approve network access for the registry.checkreports an external resource: inline it, or remove it. For a font or library, copy the minimal needed part into the file if its license permits.- Blank page in preview: read the console error first; in the react tier, confirm
you opened
dist/index.html, not the sourceindex.html. previewrefuses to start: the path does not exist, or the port is taken. Omit--portto take a free one.
04 同仓库更多 Skills
xlsx
Create/edit/analyze/verify spreadsheet workbooks including XLSX/CSV/TSV.
webapp-testing
Start/reuse a local app, wait for readiness, inspect rendered state/console/network, act from observed selectors, and verify with evidence.
verify
Exercise the real app/API/CLI and collect observable evidence; tests alone do not count as end-to-end verification.
tts
暂无简介
test
Detect the project’s test stack, run the narrowest useful tests, create tests when authorized, and report coverage/gaps honestly.
spreadsheets
Compatibility alias for the xlsx skill. Prefer loading xlsx.