Artifacts Builder
Overview
Generate self-contained, production-quality HTML/CSS/JS artifacts that run in any modern browser without a build step. Each artifact is a single file (or minimal file set) containing everything needed for an interactive demo, prototype, data visualization, or utility tool. Emphasis on progressive enhancement, responsive design, and clean code.
Phase 1: Scope Definition
- Clarify the artifact's purpose (demo, prototype, tool, visualization)
- Determine interactivity level (static, interactive, data-driven)
- Identify required dependencies (none, CDN-loaded, embedded)
- Define responsive requirements (mobile, desktop, both)
- Set constraints (file size, browser support, offline capability)
STOP — Confirm scope and constraints with user before architecture decisions.
Artifact Type Decision Table
| Purpose |
Complexity |
Dependencies |
Example |
| Static demo |
Low |
None |
Product mockup, landing page |
| Interactive widget |
Medium |
None or Alpine.js |
Calculator, form builder |
| Data visualization |
Medium-High |
D3.js or Chart.js |
Dashboard, chart explorer |
| Prototype |
Medium |
Alpine.js or Petite-Vue |
Clickable UI prototype |
| Utility tool |
Medium-High |
Varies |
JSON formatter, color picker |
| Generative art |
Medium |
None |
Canvas animation, pattern generator |
| Presentation |
Medium |
None or Mermaid |
Slide deck, diagram viewer |
Phase 2: Architecture
- Choose single-file or multi-file approach
- Select CDN dependencies (if any)
- Plan component structure within the file
- Define state management approach
- Plan progressive enhancement layers
STOP — Present architecture and dependency choices for approval.
Architecture Decision Table
| Constraint |
Single-File |
Multi-File |
| Easy sharing (email, paste) |
Yes |
No |
| File size < 100KB |
Yes |
Either |
| Multiple pages/views |
Possible (SPA) |
Better |
| Team collaboration |
Difficult |
Better |
| Offline use |
Yes (self-contained) |
Needs bundling |
| SEO requirements |
N/A |
N/A (artifacts are tools) |
Dependency Decision Table
| Need |
Recommended |
CDN URL |
Size |
| Lightweight reactivity |
Alpine.js |
cdn.jsdelivr.net/npm/alpinejs@3 |
~15KB |
| Minimal Vue-like |
Petite-Vue |
unpkg.com/petite-vue |
~6KB |
| Charts |
Chart.js |
cdn.jsdelivr.net/npm/chart.js@4 |
~65KB |
| Data visualization |
D3.js |
cdn.jsdelivr.net/npm/d3@7 |
~90KB |
| Diagrams |
Mermaid |
cdn.jsdelivr.net/npm/mermaid@10 |
~120KB |
| CSS framework (proto) |
Tailwind Play CDN |
cdn.tailwindcss.com |
Runtime |
| Icons |
Lucide |
unpkg.com/lucide@latest |
On-demand |
| No dependency needed |
Vanilla JS |
N/A |
0KB |
CDN Usage Rules
| Rule |
Rationale |
Pin to major version (@3, @7) |
Prevent breaking changes |
| Maximum 3 CDN dependencies |
Keep artifacts lightweight |
Add integrity and crossorigin |
Security against CDN compromise |
| Provide graceful degradation |
Work if CDN fails |
| Prefer smaller alternatives |
Alpine over React, Petite-Vue over Vue |
Phase 3: Implementation
- Build semantic HTML structure
- Add CSS (inline
<style> or embedded)
- Implement JavaScript functionality
- Add error handling and fallbacks
- Test across viewports and browsers
STOP — Verify the artifact works correctly before delivering to user.
Template Structure
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>[Artifact Title]</title>
<style>
/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Design Tokens */
:root {
--color-bg: #ffffff;
--color-text: #1a1a2e;
--color-primary: #3b82f6;
--color-border: #e2e8f0;
--radius: 0.5rem;
--space: 1rem;
--font: system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
:root {
--color-bg: #0f172a;
--color-text: #e2e8f0;
--color-primary: #60a5fa;
--color-border: #334155;
}
}
/* Base Styles */
body {
font-family: var(--font);
background: var(--color-bg);
color: var(--color-text);
line-height: 1.6;
}
/* Component Styles */
/* ... */
</style>
</head>
<body>
<!-- Semantic HTML content -->
<script>
// Application logic
(function() {
'use strict';
// ...
})();
</script>
</body>
</html>
Responsive Design Patterns
Container-Based Layout
.container {
width: min(100% - 2rem, 1200px);
margin-inline: auto;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
gap: var(--space);
}
Mobile-First Media Queries
/* Base: mobile */
.layout { display: flex; flex-direction: column; }
/* Tablet and up */
@media (min-width: 768px) {
.layout { flex-direction: row; }
.sidebar { width: 280px; flex-shrink: 0; }
}
Progressive Enhancement
| Layer |
Purpose |
Requirement |
| HTML |
Content accessible and meaningful |
Works without CSS or JS |
| CSS |
Visual presentation and layout |
Works without JS |
| JavaScript |
Enhanced interactivity |
Adds dynamic behavior |
Feature Detection
// Check before using modern APIs
if ('IntersectionObserver' in window) {
// Use lazy loading
} else {
// Load all images immediately
}
if (CSS.supports('backdrop-filter', 'blur(10px)')) {
element.classList.add('glass-effect');
}
State Management (No Framework)
Simple State Pattern
function createStore(initialState) {
let state = { ...initialState };
const listeners = new Set();
return {
getState: () => ({ ...state }),
setState(updates) {
state = { ...state, ...updates };
listeners.forEach(fn => fn(state));
},
subscribe(fn) {
listeners.add(fn);
return () => listeners.delete(fn);
},
};
}
URL-Based State (for shareable artifacts)
function syncStateWithURL(store) {
const params = new URLSearchParams(location.search);
for (const [key, value] of params) {
store.setState({ [key]: JSON.parse(value) });
}
store.subscribe(state => {
const params = new URLSearchParams();
Object.entries(state).forEach(([k, v]) => params.set(k, JSON.stringify(v)));
history.replaceState(null, '', `?${params}`);
});
}
Export Formats
| Format |
Use Case |
Method |
| Single HTML file |
Sharing, embedding |
Self-contained <style> and <script> |
| HTML + assets |
Complex artifacts |
Separate CSS/JS files |
| Data URL |
Inline embedding |
data:text/html;base64,... |
| Screenshot/PNG |
Documentation |
html2canvas or browser screenshot |
| PDF |
Print/report |
window.print() with print styles |
Quality Checklist
Anti-Patterns / Common Mistakes
| Anti-Pattern |
Why It Is Wrong |
What to Do Instead |
| React/Vue/Angular in single-file artifact |
Massive overhead for simple interactions |
Use Alpine.js or vanilla JS |
| Heavy framework from CDN for simple UI |
Slow load, wasted bandwidth |
Match dependency weight to need |
| Inline styles instead of CSS custom properties |
Cannot theme, cannot dark-mode |
Use CSS custom properties (tokens) |
| No error handling on user input |
Crashes on bad input |
Validate and provide feedback |
| Fixed pixel dimensions |
Breaks on mobile, tablets |
Use responsive units (%, rem, vw) |
Missing <meta viewport> |
Mobile renders desktop-zoomed |
Always include viewport meta tag |
Blocking <script> in <head> |
Delays page rendering |
Use defer attribute or put at end of body |
| No IIFE wrapper for script |
Global scope pollution |
Wrap in (function() { ... })() |
| Hardcoded colors without tokens |
Cannot switch themes |
Use CSS custom properties |
Integration Points
| Skill |
Integration |
ui-ux-pro-max |
Style selection and UX guidelines |
ui-design-system |
Design tokens for consistent theming |
canvas-design |
Canvas/SVG visualizations within artifacts |
senior-frontend |
Complex component patterns |
mobile-design |
Mobile-responsive artifact design |
planning |
Artifact scope is defined during planning |
Skill Type
FLEXIBLE — Adapt the architecture, dependencies, and complexity to the artifact's requirements. Simple demos should remain as minimal as possible; complex tools may use lightweight frameworks and multiple CDN dependencies.
1---
2name: artifacts-builder
3description: >
4 Use when the user needs standalone HTML/CSS/JS artifacts — interactive demos, prototypes, single-file
5 applications, or visual tools that run independently in a browser. Triggers: user says "artifact",
6 "demo", "prototype", "single-file app", "HTML tool", "interactive widget", "standalone page",
7 building something that runs in a browser without a build step.
8---
9
10# Artifacts Builder
11
12## Overview
13
14Generate self-contained, production-quality HTML/CSS/JS artifacts that run in any modern browser without a build step. Each artifact is a single file (or minimal file set) containing everything needed for an interactive demo, prototype, data visualization, or utility tool. Emphasis on progressive enhancement, responsive design, and clean code.
15
16## Phase 1: Scope Definition
17
181. Clarify the artifact's purpose (demo, prototype, tool, visualization)
192. Determine interactivity level (static, interactive, data-driven)
203. Identify required dependencies (none, CDN-loaded, embedded)
214. Define responsive requirements (mobile, desktop, both)
225. Set constraints (file size, browser support, offline capability)
23
24**STOP — Confirm scope and constraints with user before architecture decisions.**
25
26### Artifact Type Decision Table
27
28| Purpose | Complexity | Dependencies | Example |
29|---|---|---|---|
30| Static demo | Low | None | Product mockup, landing page |
31| Interactive widget | Medium | None or Alpine.js | Calculator, form builder |
32| Data visualization | Medium-High | D3.js or Chart.js | Dashboard, chart explorer |
33| Prototype | Medium | Alpine.js or Petite-Vue | Clickable UI prototype |
34| Utility tool | Medium-High | Varies | JSON formatter, color picker |
35| Generative art | Medium | None | Canvas animation, pattern generator |
36| Presentation | Medium | None or Mermaid | Slide deck, diagram viewer |
37
38## Phase 2: Architecture
39
401. Choose single-file or multi-file approach
412. Select CDN dependencies (if any)
423. Plan component structure within the file
434. Define state management approach
445. Plan progressive enhancement layers
45
46**STOP — Present architecture and dependency choices for approval.**
47
48### Architecture Decision Table
49
50| Constraint | Single-File | Multi-File |
51|---|---|---|
52| Easy sharing (email, paste) | Yes | No |
53| File size < 100KB | Yes | Either |
54| Multiple pages/views | Possible (SPA) | Better |
55| Team collaboration | Difficult | Better |
56| Offline use | Yes (self-contained) | Needs bundling |
57| SEO requirements | N/A | N/A (artifacts are tools) |
58
59### Dependency Decision Table
60
61| Need | Recommended | CDN URL | Size |
62|---|---|---|---|
63| Lightweight reactivity | Alpine.js | `cdn.jsdelivr.net/npm/alpinejs@3` | ~15KB |
64| Minimal Vue-like | Petite-Vue | `unpkg.com/petite-vue` | ~6KB |
65| Charts | Chart.js | `cdn.jsdelivr.net/npm/chart.js@4` | ~65KB |
66| Data visualization | D3.js | `cdn.jsdelivr.net/npm/d3@7` | ~90KB |
67| Diagrams | Mermaid | `cdn.jsdelivr.net/npm/mermaid@10` | ~120KB |
68| CSS framework (proto) | Tailwind Play CDN | `cdn.tailwindcss.com` | Runtime |
69| Icons | Lucide | `unpkg.com/lucide@latest` | On-demand |
70| No dependency needed | Vanilla JS | N/A | 0KB |
71
72### CDN Usage Rules
73
74| Rule | Rationale |
75|---|---|
76| Pin to major version (`@3`, `@7`) | Prevent breaking changes |
77| Maximum 3 CDN dependencies | Keep artifacts lightweight |
78| Add `integrity` and `crossorigin` | Security against CDN compromise |
79| Provide graceful degradation | Work if CDN fails |
80| Prefer smaller alternatives | Alpine over React, Petite-Vue over Vue |
81
82## Phase 3: Implementation
83
841. Build semantic HTML structure
852. Add CSS (inline `<style>` or embedded)
863. Implement JavaScript functionality
874. Add error handling and fallbacks
885. Test across viewports and browsers
89
90**STOP — Verify the artifact works correctly before delivering to user.**
91
92### Template Structure
93
94```html
95<!DOCTYPE html>
96<html lang="en">
97<head>
98 <meta charset="UTF-8">
99 <meta name="viewport" content="width=device-width, initial-scale=1.0">
100 <title>[Artifact Title]</title>
101 <style>
102 /* Reset */
103 *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
104
105 /* Design Tokens */
106 :root {
107 --color-bg: #ffffff;
108 --color-text: #1a1a2e;
109 --color-primary: #3b82f6;
110 --color-border: #e2e8f0;
111 --radius: 0.5rem;
112 --space: 1rem;
113 --font: system-ui, -apple-system, sans-serif;
114 }
115
116 @media (prefers-color-scheme: dark) {
117 :root {
118 --color-bg: #0f172a;
119 --color-text: #e2e8f0;
120 --color-primary: #60a5fa;
121 --color-border: #334155;
122 }
123 }
124
125 /* Base Styles */
126 body {
127 font-family: var(--font);
128 background: var(--color-bg);
129 color: var(--color-text);
130 line-height: 1.6;
131 }
132
133 /* Component Styles */
134 /* ... */
135 </style>
136</head>
137<body>
138 <!-- Semantic HTML content -->
139
140 <script>
141 // Application logic
142 (function() {
143 'use strict';
144 // ...
145 })();
146 </script>
147</body>
148</html>
149```
150
151### Responsive Design Patterns
152
153#### Container-Based Layout
154
155```css
156.container {
157 width: min(100% - 2rem, 1200px);
158 margin-inline: auto;
159}
160
161.grid {
162 display: grid;
163 grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
164 gap: var(--space);
165}
166```
167
168#### Mobile-First Media Queries
169
170```css
171/* Base: mobile */
172.layout { display: flex; flex-direction: column; }
173
174/* Tablet and up */
175@media (min-width: 768px) {
176 .layout { flex-direction: row; }
177 .sidebar { width: 280px; flex-shrink: 0; }
178}
179```
180
181### Progressive Enhancement
182
183| Layer | Purpose | Requirement |
184|---|---|---|
185| HTML | Content accessible and meaningful | Works without CSS or JS |
186| CSS | Visual presentation and layout | Works without JS |
187| JavaScript | Enhanced interactivity | Adds dynamic behavior |
188
189#### Feature Detection
190
191```javascript
192// Check before using modern APIs
193if ('IntersectionObserver' in window) {
194 // Use lazy loading
195} else {
196 // Load all images immediately
197}
198
199if (CSS.supports('backdrop-filter', 'blur(10px)')) {
200 element.classList.add('glass-effect');
201}
202```
203
204### State Management (No Framework)
205
206#### Simple State Pattern
207
208```javascript
209function createStore(initialState) {
210 let state = { ...initialState };
211 const listeners = new Set();
212
213 return {
214 getState: () => ({ ...state }),
215 setState(updates) {
216 state = { ...state, ...updates };
217 listeners.forEach(fn => fn(state));
218 },
219 subscribe(fn) {
220 listeners.add(fn);
221 return () => listeners.delete(fn);
222 },
223 };
224}
225```
226
227#### URL-Based State (for shareable artifacts)
228
229```javascript
230function syncStateWithURL(store) {
231 const params = new URLSearchParams(location.search);
232 for (const [key, value] of params) {
233 store.setState({ [key]: JSON.parse(value) });
234 }
235 store.subscribe(state => {
236 const params = new URLSearchParams();
237 Object.entries(state).forEach(([k, v]) => params.set(k, JSON.stringify(v)));
238 history.replaceState(null, '', `?${params}`);
239 });
240}
241```
242
243### Export Formats
244
245| Format | Use Case | Method |
246|---|---|---|
247| Single HTML file | Sharing, embedding | Self-contained `<style>` and `<script>` |
248| HTML + assets | Complex artifacts | Separate CSS/JS files |
249| Data URL | Inline embedding | `data:text/html;base64,...` |
250| Screenshot/PNG | Documentation | `html2canvas` or browser screenshot |
251| PDF | Print/report | `window.print()` with print styles |
252
253## Quality Checklist
254
255- [ ] Valid HTML5 (`<!DOCTYPE html>`, `lang` attribute)
256- [ ] Responsive viewport meta tag
257- [ ] Works without JavaScript (content visible)
258- [ ] Dark mode support (`prefers-color-scheme`)
259- [ ] Keyboard navigable
260- [ ] No console errors
261- [ ] File size under 100KB (excluding images)
262- [ ] Cross-browser tested (Chrome, Firefox, Safari)
263- [ ] Print styles if applicable
264- [ ] Semantic HTML elements used appropriately
265
266## Anti-Patterns / Common Mistakes
267
268| Anti-Pattern | Why It Is Wrong | What to Do Instead |
269|---|---|---|
270| React/Vue/Angular in single-file artifact | Massive overhead for simple interactions | Use Alpine.js or vanilla JS |
271| Heavy framework from CDN for simple UI | Slow load, wasted bandwidth | Match dependency weight to need |
272| Inline styles instead of CSS custom properties | Cannot theme, cannot dark-mode | Use CSS custom properties (tokens) |
273| No error handling on user input | Crashes on bad input | Validate and provide feedback |
274| Fixed pixel dimensions | Breaks on mobile, tablets | Use responsive units (%, rem, vw) |
275| Missing `<meta viewport>` | Mobile renders desktop-zoomed | Always include viewport meta tag |
276| Blocking `<script>` in `<head>` | Delays page rendering | Use `defer` attribute or put at end of body |
277| No IIFE wrapper for script | Global scope pollution | Wrap in `(function() { ... })()` |
278| Hardcoded colors without tokens | Cannot switch themes | Use CSS custom properties |
279
280## Integration Points
281
282| Skill | Integration |
283|---|---|
284| `ui-ux-pro-max` | Style selection and UX guidelines |
285| `ui-design-system` | Design tokens for consistent theming |
286| `canvas-design` | Canvas/SVG visualizations within artifacts |
287| `senior-frontend` | Complex component patterns |
288| `mobile-design` | Mobile-responsive artifact design |
289| `planning` | Artifact scope is defined during planning |
290
291## Skill Type
292
293**FLEXIBLE** — Adapt the architecture, dependencies, and complexity to the artifact's requirements. Simple demos should remain as minimal as possible; complex tools may use lightweight frameworks and multiple CDN dependencies.