write-demos

Create and manage partial HTML demos for custom elements served by cem serve.

46|4|Updated May 27, 2025
One-click install
npx skills add https://github.com/bennypowers/cem --skill write-demos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-demos
Source: https://github.com/bennypowers/cem/tree/main/extensions/claude-code/skills/write-demos
Command: npx skills add https://github.com/bennypowers/cem --skill write-demos

SYSTEM DOCUMENTATION & REQUIREMENTS

## What problem does it solve? Write demos are essential for testing and showcasing custom elements with cem serve, while keeping demos lightweight and isolated from a full HTML document.

## Core Features & Use Cases

  • Index demos: minimal demos that render an element without full page scaffolding.
  • Feature demos: one feature per file with a small script importing the element and its dependencies.
  • Multi-element demos: demo-for metadata to associate demos with multiple elements.
  • Validation: ensure demos contain no DOCTYPE or html, head, or body tags and import maps resolve correctly.

### Quick Start Place a minimal index demo HTML in the element's demo directory following the partials guideline.

Frequently Asked Questions about write-demos

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create element demos for cem serve without full HTML page scaffolding?

To create element demos for cem serve, write self-contained partial HTML files containing module scripts and metadata, omitting DOCTYPE or html, head, and body tags. The generate_html validation ensures these partials are suitable for the server wrapper to render.

What is a partial HTML demo and why does cem serve require it for custom elements?

A partial HTML demo is a lightweight file without DOCTYPE or full document structure that isolates custom element rendering. Cem serve requires partials because it wraps the content with its own server-side scaffolding and import maps to display the demo.

How do I associate a single demo file with multiple custom elements?

To associate a single demo with multiple custom elements, use the demo-for metadata field in the partial HTML file. This links the demo to several elements simultaneously, enabling multi-element showcase scenarios within a per-element demo directory.

What validation rules must custom element demos follow to render correctly in cem serve?

Custom element demos must pass generate_html validation by omitting DOCTYPE and html, head, or body tags, including module scripts for imports, and ensuring import maps resolve correctly via serve.importMap configuration to render in cem serve.

Can I use cem serve to organize index and feature demos for web components?

Yes, cem serve organizes web component demos by supporting minimal index demos for basic rendering and feature demos isolating single functionalities, stored under per-element demo directories and discovered via the generate.demoDiscovery configuration key.

Why does my custom element demo fail validation when it includes a DOCTYPE tag?

Custom element demos fail validation when including a DOCTYPE tag because cem serve expects partial HTML fragments, not full documents. The generate_html validation rejects complete HTML structures to ensure the server wrapper can properly inject scaffolding.