agentleFS
VzlentinVzlentin/skills/skills/artifacts/SKILL.md

artifacts

Skill1 starsChanged 4 days agoMITView on GitHub

Make HTML pages for the user and get them to him: pages that teach, with widgets that the reader plays, pages that ask for his edits, and copies to share. Covers the approach, the terminal theme, the base shell, Alpine and widgets, the way back, the check, and the hosts (local file, Radius, Claude Artifact).

12 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use plan, test-driven-development and 3 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • BlockSkill

    plan

    Draft a TDD, PRD, or lightweight plan in the conversation without committing it.

    Also in 3 projects that use this

  • OpenAISkill

    test-driven-development

    Use when implementing any feature or bugfix, before writing implementation code

    Also in 3 projects that use this

  • OpenAISkill

    brainstorming

    You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

    Also in 3 projects that use this

  • MicrosoftSkill

    handoff

    Compact the current conversation into a handoff document for another agent to pick up.

    Also in 3 projects that use this

  • +1 more from openai

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 4 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When the source has an Alpine attribute (x-data, x-model, @click, ...), the page gets Alpine.js with its persist plugin ({baseDir}/vendor).

    line 81
  2. Very specific:

    When the body has a <w-…> tag, the page gets Lit ({baseDir}/vendor/lit.min.js) and the kit ({baseDir}/kit.js).

    line 119
  3. Very specific:

    Use a widget only for an interactive model that no block of the kit (stepper, timeline, diagram, split, grid, card) can draw.

    line 121
  4. Distinctive:

    Never put text, a table or a list in the tabs of a widget: the reader sees one tab at a time.

    line 122
  5. Very specific:

    When a widget is useful outside its page, move its script to {baseDir}/widgets/w-<name>.js and add it to the list above.

    line 161
  6. Distinctive:

    Before you publish, run the check on the built page:

    line 165
  7. Very specific:

    After a change, run the check with --from on the part that changed.

    line 192
  8. Distinctive:

    Never publish while an edit runs.

    line 207
  9. Distinctive:

    If the Radius tools fail, or the user cannot open the link (a client VPN can block it), use another host.

    line 209

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

artifacts

An artifact is a page that you make for the user, outside the terminal: to explain, to ask for his edits, or to share. He reads it on his computer or on his phone.

{baseDir} is the directory of this SKILL.md.

Approach

  • Progressive disclosure: each section answers one question in its heading, gives the answer in its first line, and puts the rest behind a tap.
  • Plain language. Define each term on first use.
  • Concrete before abstract: start from what is true today.
  • The page uses the width of the screen it is on. On a laptop (1280 to 1728 px), text and the part that shows it sit side by side: put each view, example, code block, table or card beside the text that explains it (.split). On a phone, they stack in one column. Both must work.
  • Building blocks: compose the page from the blocks of the kit (split, card, grid, diagram, stepper, timeline). Write a widget only for a model that no block can draw.
  • The terminal theme: Pi's colors from Ghostty, when Ghostty is there. If not, the saved colors. The page keeps these colors in each light or dark setting of the viewer. Only the share copy is light. Use no other colors.

Build

node {baseDir}/render.mjs /tmp/pages/<slug>/page.html [out.html]   # /tmp/pages/<slug>/index.html
node {baseDir}/render.mjs --share /tmp/pages/<slug>/page.html      # share.html: a light copy for other people, and for a PDF
node {baseDir}/render.mjs --theme                                  # the theme as CSS variables, for a page by hand
  • The source: HTML in /tmp/pages/<slug>/page.html, the content of <main>. The slug is the name of its folder. The title is the text of the first <h1>: a source with no <h1> stops the build.
  • The build converts no Markdown: write HTML. The HTML goes into the page as it is, except <diagram>. <style> and <script> blocks go in as they are.
  • The built page is a disposable output: to change it, change page.html and build again.
  • A page that must last more than a day keeps its source (page.html and its files) in ${XDG_STATE_HOME:-$HOME/.local/state}/pages/<slug>/, because /tmp does not last. render.mjs builds it from there and still writes /tmp/pages/<slug>/index.html, because the slug is the name of the folder of page.html.
  • The base shell gives the theme as CSS variables (--accent, --text, --muted, --card, --line, ...), the type, the spacing, the code style and the layout. Do not write layout CSS of your own (widths, margins, columns, media queries): use the parts of the shell.
  • The layout: the page takes the width of the screen, up to 1760 px, with one left edge for every part. It has two tracks: the main track holds text at a readable measure (--measure, 70 ch), and the side track takes the rest of the width. Under 1080 px, it has one track.

    • Text goes in the main track by itself.
    • .split puts its first child in the main track and its second child in the side track, side by side. On a phone, the second child comes under the first. It is the part to use most: the text of a section on the left, and its view, example, code, table or card on the right.
    • Tables, figures, code, .grid and .card outside a .split take the full width.
    <div class="split">
    <div>
    <h2>Why the test passed</h2>
    <p>The text of the section.</p>
    </div>
    <div>
    <diagram src="flow.svg" alt="The request goes through the cache"></diagram>
    </div>
    </div>
  • The other blocks of the kit:
    • .card: a box for one thing. <div class="card"><h3>Release plan</h3><p>…</p></div>
    • .grid: columns that wrap on a phone. <div class="grid"><div class="card">…</div><div class="card">…</div></div>
    • <diagram>: an image from a file, with src relative to the folder of page.html. Draw a diagram with show-me (mermaid.mjs --large) as an SVG in that folder. The SVG goes into the page as it is, so it takes the page colors. A .png, .jpg, .jpeg, .gif or .webp file becomes an image with a data URL. A missing file or an unknown type stops the build. <diagram src="flow.svg" alt="what it shows"></diagram>
    • ol.stepper: ordered steps, all in view. Mark the steps that are done with li.done, and the step that runs now with li.now. <ol class="stepper"><li class="done">Plan</li><li class="now">Build</li><li>Check</li></ol>
    • ol.timeline: events in time order. Each <li> starts with a <time>. <ol class="timeline"><li><time>10-27</time>The first page.</li><li><time>11-08</time>The retro.</li></ol>
  • Other parts: .kicker (a small label above a heading), .lead (the answer under it), .pill with .good, .warn or .bad, .term with .s1 to .s4 (a word in the color of a series), .muted, .no-share.
  • A code sample is <pre class="code"><code>, with &lt;, &gt;, &amp; and &quot; in the text. The build does not color code. A diff is <pre class="code diff"><code>, with each line in <span class="add">, <span class="del"> or <span class="ctx">.
  • A wide table goes in <div class="tw">: it scrolls sideways in its own box.
  • A PDF: <chrome> --headless=new --no-pdf-header-footer --print-to-pdf=<file.pdf> file:///tmp/pages/<slug>/share.html. <chrome> is google-chrome or chromium on Linux and WSL, and "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" on macOS.

Interaction: Alpine connects, widgets draw

A page that moves uses one model:

  • Alpine holds what the page knows: the state that the text, the fields and the widgets share, and the way back. Write it as attributes in the HTML.
  • A widget draws one part that the reader plays, moves or points at: a chart, a timeline, a process that runs. It is a <w-…> tag.
  • They meet in one attribute: <w-days x-model="day">. Alpine sets the value of the widget, and the widget tells Alpine when the reader changes it.
<div x-data="{ day: 2 }">
	<p>On day <b x-text="day"></b>, the forecast uses the data of day <b x-text="day - 1"></b>.</p>
	<w-days x-model="day"></w-days>
</div>

A page gets only what it uses. Alpine weighs 56 KB and the widget kit 27 KB: a page with a toggle or two uses <details>, and a page without a part that draws uses no widget.

Alpine

When the source has an Alpine attribute (x-data, x-model, @click, ...), the page gets Alpine.js with its persist plugin ({baseDir}/vendor). Write tabs, steps, toggles and fields as Alpine attributes in the HTML.

The way back

The way back is how the user's edits come back to you: one store, $store.back, kept in his browser.

<textarea x-data x-init="$store.back.field('reply 1', $el.value)" x-model="$store.back.values['reply 1']">Draft</textarea>
<span x-data x-show="$store.back.changed('reply 1')">edited <a @click="$store.back.undo('reply 1')">undo</a></span>
  • An interactive page ends with the bar: the block, Copy, Send in a host that has sendPrompt, and Clear once there is an edit. The build adds it, and it shows once the page has a field or a part.
  • $store.back.text is the block that Copy gives: the lines of each part, then each changed field as key: and its text. With no part, it starts with [slug].
  • A page that builds its own lines adds a part: Alpine.store("back").part(() => "a line"), in an alpine:init listener. Its fields take { list: false }, so that only the part reports them.
  • A widget value goes back as a field: <w-lags x-data x-init="$store.back.field('lag', 3)" x-model="$store.back.values['lag']"></w-lags>.
  • The browser keeps only the user's edits. When you build the page again with new defaults, a field that he did not edit shows the new default.
  • The user pastes the block to you. Read it, then apply it.

A choice

A choice asks the reader to pick one option: a question, a body (any HTML: text, a table, a <diagram>), two options or more, and a box for his own words. Each option has a key, a label, gains and costs. data-plan is optional: it is the key of the option that you propose, picked when the page opens, with a badge. Without it, no option is picked.

<section class="choice" data-name="cache" data-plan="b" x-data="choice">
<p class="question">Where does the cache live?</p>
<div class="body"><p>The cache is read on each start.</p></div>
<label class="option"><input type="radio" value="a" x-model="value"><span class="key">a</span><span class="label">In the package folder</span><span class="gains">One folder to remove</span><span class="costs">Lost on each update</span></label>
<label class="option"><input type="radio" value="b" x-model="value"><span class="key">b</span><span class="label">In the home folder</span><span class="gains">Kept on each update</span><span class="costs">One more folder</span></label>
<input class="own" type="text" placeholder="Or your own answer" x-model="own">
</section>
  • The value of a choice is always in the block, also when the reader does not change it: cache: and the picked key, his own words, or nothing when he picked nothing. data-name is the name of the field: each choice needs its own.
  • A choice with a long body goes in a .split, with its view beside it.
  • The check fails a choice that has no data-name or the data-name of another choice, no question, no body, fewer than two options, an option with no key, label, gains or costs, or a data-plan that is not one of the keys.

Widgets

When the body has a <w-…> tag, the page gets Lit ({baseDir}/vendor/lit.min.js) and the kit ({baseDir}/kit.js). A code sample does not count: its < is escaped.

  • Use a widget only for an interactive model that no block of the kit (stepper, timeline, diagram, split, grid, card) can draw.
  • Never put text, a table or a list in the tabs of a widget: the reader sees one tab at a time.

Ready widgets are in {baseDir}/widgets/: the page gets widgets/w-<name>.js for each <w-name> tag. Use them as tags, with no script.

  • <w-aside>The question that the reader asks here</w-aside>: answer it in the text after it.

A new widget goes in a <script type="module"> of the page. It extends kit.Widget and uses the global Lit and kit, with no import from a URL. Each module script has its own scope, so two widgets can use the same names.

<script type="module">
const { css, html } = Lit;
const { Widget, Player, slider } = kit;

class Days extends Widget {
	static styles = css`.big { font: 700 40px var(--mono); color: var(--c); }`;
	player = new Player(this, { min: 0, max: 10, speed: 2, bind: true });
	render() {
		const day = Math.floor(this.player.value);
		return html`<div class="card">
			<div class="head">Day ${day}</div>
			<div class="body"><div class="big s1">${day}</div></div>
			<div class="foot">
				${this.player.button()} ${this.player.backButton()}
				${slider({ min: 0, max: 10, value: day, label: "Day", onInput: (v) => { this.player.pause(); this.emit(v); } })}
				${this.player.nextButton()}
			</div>
		</div>`;
	}
}
customElements.define("w-days", Days);
</script>
  • kit.Widget: the base of a widget. It gives the kit styles before its own static styles, a value that Alpine binds with x-model, and this.emit(value), which sets the value and tells the page. An attribute such as value="3" is JSON when it parses: the number 3.
  • The kit styles: .card with .head, .body and .foot, .btn (.ghost, .on), .seg (a group of buttons), .count, .note, .mono, and .s1 to .s4, which set --c to the color of series 1 to 4.
  • kit.slider({ min, max, step, value, label, onInput }), kit.icon(name) and kit.iconButton(name, { label, disabled, ghost, onClick }). The icons: play, pause, back, next, replay.
  • new kit.Player(this, { min, max, value, speed, autoplay, bind }) moves a value from min to max at speed units per second. It stops at max and pauses when the widget is off the screen. It does not start by itself when the reader asks for reduced motion. With bind: true, it moves the value of the widget, and the page gets each whole unit. player.button() is play, pause and replay. player.backButton() and player.nextButton() call player.step(-1) and player.step(1).
  • The colors: the theme variables, and --series-1 to --series-4, four colors that differ in each scheme.
  • Lit draws, Alpine connects: a widget does not keep the state of the page, and Alpine does not draw inside a widget.
  • When a widget is useful outside its page, move its script to {baseDir}/widgets/w-<name>.js and add it to the list above.

Check

Before you publish, run the check on the built page:

node {baseDir}/check.mjs /tmp/pages/<slug>/index.html

At 390, 1280 and 1728 px, it cuts the whole page into tiles of one screen. It prints the path of each tile with the heading that the tile starts at:

tiles at 390 px:
  /tmp/pages/<slug>/check/390-1.png  The title of the page
  /tmp/pages/<slug>/check/390-2.png  The title of the page
  /tmp/pages/<slug>/check/390-3.png  Options
  …
tiles at 1280 px:
  /tmp/pages/<slug>/check/1280-1.png  The title of the page
  …
tiles at 1728 px:
  …

--from '<selector>', for example --from '#options', starts the tiles at the first element that matches.

It lists the errors of the scripts, the <w-…> tags that did not start, the widgets that do not extend kit.Widget, the code that a script loads from outside the page (a src, or an import of a URL), the players that do not move, and the choices that miss a part. It checks the layout: one left edge, the shell's --page and --measure with two tracks at 1728 px, no text alone for more than 700 px with the side track empty at 1728 px, no sideways scroll at 390 px, and the same colors in a light and a dark setting. Its exit code is 1 when it finds a problem, and 2 when --from matches no element. It needs Chrome, Chromium or Edge: set CHROME=<path> when it does not find one.

  • Take screenshots only with check.mjs, and read only the tile paths that it prints. Never run headless Chrome with --screenshot, never crop a tile, and never guess a file name. When the tiles are missing, fix the error and run the check again.
  • Pick the tiles to read by their heading. Ask: what covers the screen on the phone? Is the laptop screen full, with each view next to its text?
  • After a change, run the check with --from on the part that changed.
  • Open the page and use each control once.
  • One error in a script stops all the widgets of that script.
  • A script contains no </script: it would end the script.

Hosts

When the user is at this machine, the local file works. When he is not (on his phone, in a remote session), the host must give him a link. Use the first host that is there: Radius when its tools (artifacts_create, ...) are there, else the Claude Code Artifact.

Radius

  • mcp__radius__artifacts_create({ title, content, content_type: "text/html", visibility: "private", note }) creates the artifact once. It returns structuredContent.artifact. Its id is the slug of each later call, and it is not the <slug> of /tmp/pages/<slug>/. Its canonical_url is the link to give the user.
  • mcp__radius__artifacts_versions_publish({ slug, content, content_type: "text/html", note }) adds a version. The note says what changed. It returns the same artifact object.
  • mcp__radius__artifacts_files_download({ slug, version: "latest", path: "index.html" }) returns structuredContent.url, a presigned URL that expires in 10 minutes. The URL is a credential: do not print or log it.
  • The title cannot change after the create. Name the topic, not the state.
  • Never publish while an edit runs.
  • Radius keeps an artifact 90 days after its last publish.
  • If the Radius tools fail, or the user cannot open the link (a client VPN can block it), use another host.

Publish each version with this codemode script. A page with Alpine or widgets is larger than one tool output (50 KB), so the script reads it in parts. Then it reads the page back from Radius and compares it with the local file. It returns the artifact id, the link to give the user, and same or DIFFERENT. When the download fails, the script stops with the curl error.

const dir = "/tmp/pages/<slug>", file = `${dir}/index.html`;
const run = async (command) => {
	const { exitCode, output } = await tools.bash({ command, timeout: 60 });
	if (exitCode !== 0) throw new Error(output);
	return output.trim();
};
const size = Number(await run(`wc -c < ${file}`));
// 30000 bytes give 40 KB of base64, and a multiple of 3 lets the parts join.
let b64 = "";
for (let at = 0; at < size; at += 30000) {
	b64 += await run(`node -e 'const [, file, at] = process.argv; process.stdout.write(require("fs").readFileSync(file).subarray(+at, +at + 30000).toString("base64"))' ${file} ${at}`);
}
const content = decodeURIComponent(escape(atob(b64)));
const { artifact } = (await tools.mcp__radius__artifacts_versions_publish({ slug: "<artifact id>", content, content_type: "text/html", note: "<what changed>" })).structuredContent;
const slug = artifact.id;
const { url } = (await tools.mcp__radius__artifacts_files_download({ slug, version: "latest", path: "index.html" })).structuredContent;
const check = await run(`curl -fsSL '${url}' -o ${dir}/remote.html && { cmp -s ${file} ${dir}/remote.html && echo same || echo DIFFERENT; }`);
return { slug, link: artifact.canonical_url, check };
  • For the first version, replace the publish call with tools.mcp__radius__artifacts_create({ title: "<topic>", content, content_type: "text/html", visibility: "private", note: "<note>" }).
  • The codemode sandbox has no TextEncoder, TextDecoder or URL. File work stays in bash or node, and codemode makes only the Radius calls.

Local file

Open /tmp/pages/<slug>/index.html. On macOS: open <file>. On Linux: xdg-open <file>. On WSL: wslview <file>, or explorer.exe "$(wslpath -w <file>)".

Claude Code

Publish the page as an Artifact. If the artifact-capabilities skill exists, load it first. If the account has them, keep the answers in the page database (ArtifactData) and use comment threads (ArtifactComments). Copy stays as the fallback. In an inline widget, the page shows Send (sendPrompt). The page meets the Artifact contract as built: one file, scripts inline, its own colors. Test Copy on the first publish.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.