gen-tests
Generate test scaffolding for custom elements using cem serve's chromeless demo UI with Playwright or Puppeteer. Use when the user asks to "generate tests", "scaffold tests", "create test boilerplate", "write tests for element", "playwright tests", "puppeteer tests", or mentions "test coverage" for custom elements.
What this skill does
# Test Scaffolding Generator
Generate browser-based test scaffolding for custom elements using the
Page Object Model pattern, testing against `cem serve`'s chromeless demo UI
with Playwright or Puppeteer.
## Workflow
### Phase 1: Gather Element Data
Read the target element's full manifest data:
```text
cem://element/{tagName}
cem://element/{tagName}/attributes
cem://element/{tagName}/slots
cem://element/{tagName}/events
cem://element/{tagName}/css/parts
cem://element/{tagName}/css/custom-properties
cem://element/{tagName}/css/states
```
Check which demos exist for the element — the manifest's `demos` array defines
the available demo pages and their URLs.
### Phase 2: Detect Test Environment
Search the project for existing test patterns:
1. Look for existing test files to match conventions:
- `*.test.ts`, `*.spec.ts` patterns
- Test framework: Playwright (`@playwright/test`) or Puppeteer (`puppeteer`)
- Existing `playwright.config.ts` or `puppeteer` setup
- Existing page objects in `tests/pages/`, `tests/models/`, etc.
2. Check `package.json` for test dependencies and scripts
3. If no test framework is present, recommend Playwright and generate a config
### Phase 3: Generate Playwright Config (if needed)
If the project doesn't have a Playwright config, generate one that starts
`cem serve` in chromeless mode:
```ts
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
webServer: {
command: 'cem serve --rendering=chromeless',
port: 8000,
reuseExistingServer: !process.env.CI,
},
use: {
baseURL: 'http://localhost:8000',
},
});
```
For Puppeteer, generate equivalent setup/teardown that spawns `cem serve`.
### Phase 4: Generate Page Object
Generate a page object class for the element that encapsulates all locators
and interactions derived from the manifest. The page object is the primary
output — tests become thin and readable when the page object does the work.
#### Page Object Structure
```ts
// tests/pages/MyButtonPage.ts
import type { Locator, Page } from '@playwright/test';
export class MyButtonPage {
readonly page: Page;
/** The <my-button> element */
readonly host: Locator;
// --- Slots (from manifest slots) ---
/** Default slot content */
readonly slotDefault: Locator;
/** The icon slot */
readonly slotIcon: Locator;
constructor(page: Page) {
this.page = page;
this.host = page.locator('my-button');
this.slotDefault = this.host.locator('> :not([slot])');
this.slotIcon = this.host.locator('[slot="icon"]');
}
// --- Navigation ---
async goto(demo = '') {
const path = demo
? `/elements/my-button/demo/${demo}`
: '/elements/my-button/demo/';
await this.page.goto(path);
}
// --- Attribute helpers (from manifest attributes) ---
async variant(): Promise<string | null> {
return this.host.getAttribute('variant');
}
async setVariant(value: 'primary' | 'secondary' | 'danger') {
await this.host.evaluate((el, v) => el.setAttribute('variant', v), value);
}
async disabled(): Promise<boolean> {
return this.host.evaluate((el) => el.hasAttribute('disabled'));
}
async setDisabled(value: boolean) {
await this.host.evaluate(
(el, v) => el.toggleAttribute('disabled', v),
value,
);
}
// --- Property helpers (for non-attribute properties) ---
async setComplexData(value: unknown) {
await this.host.evaluate((el, v) => (el as any).complexData = v, value);
}
// --- Event helpers (from manifest events) ---
/**
* Returns a promise that resolves with serializable event data when the
* element fires the given event. Call this BEFORE triggering the interaction.
*
* DOM Event objects are not serializable across the Playwright boundary.
* This extracts the event's own enumerable properties (the class fields
* on typed Event subclasses) into a plain object.
*/
async waitForEvent(eventName: string): Promise<Record<string, unknown>> {
return this.host.evaluate(
(el, name) =>
new Promise<Record<string, unknown>>((resolve) =>
el.addEventListener(
name,
(ev) => {
const data: Record<string, unknown> = { type: ev.type };
for (const key of Object.keys(ev)) {
data[key] = (ev as Record<string, unknown>)[key];
}
resolve(data);
},
{ once: true },
),
),
eventName,
);
}
// --- CSS helpers (from manifest CSS custom properties) ---
async setCssProperty(name: string, value: string) {
await this.host.evaluate(
(el, [n, v]) => el.style.setProperty(n, v),
[name, value] as const,
);
}
async computedStyle(property: string, internalSelector?: string): Promise<string> {
return this.host.evaluate(
(el, [prop, selector]) => {
const target = selector
? el.shadowRoot?.querySelector(selector) ?? el
: el;
return getComputedStyle(target).getPropertyValue(prop);
},
[property, internalSelector ?? null] as const,
);
}
// --- State helpers (from manifest CSS states) ---
async matchesState(state: string): Promise<boolean> {
return this.host.evaluate((el, s) => el.matches(`:state(${s})`), state);
}
// --- Interaction helpers ---
async click() {
await this.host.click();
}
async focus() {
await this.host.focus();
}
}
```
#### Page Object Generation Rules
For each manifest feature, generate the corresponding page object members:
| Manifest Feature | Page Object Member |
|------------------|--------------------|
| Each attribute | Getter method + setter method (typed for enums) |
| Each property (no attribute) | Setter via `evaluate` |
| Each named slot | `Locator` field: `this.host.locator('[slot="name"]')` |
| Default slot | `Locator` field: `this.host.locator('> :not([slot])')` |
| Each CSS part | Helper method using `evaluate` to query shadow root |
| Each CSS custom property | Helper via `setCssProperty` / `computedStyle` |
| Each CSS state | `matchesState(name)` boolean helper |
| Each event | Typed `waitForEvent` usage or dedicated method |
| Each demo URL | Named navigation method or param to `goto()` |
### Phase 5: Generate Test Cases
Tests use the page object — they should read almost like plain English.
```ts
// tests/my-button.spec.ts
import { test, expect } from '@playwright/test';
import { MyButtonPage } from './pages/MyButtonPage';
test.describe('<my-button>', () => {
let button: MyButtonPage;
test.beforeEach(async ({ page }) => {
button = new MyButtonPage(page);
await button.goto();
});
test.describe('attributes', () => {
test('has primary variant by default', async () => {
await expect(button.host).toHaveAttribute('variant', 'primary');
});
test('reflects variant attribute', async () => {
await button.setVariant('secondary');
await expect(button.host).toHaveAttribute('variant', 'secondary');
});
test('supports all variant values', async () => {
for (const variant of ['primary', 'secondary', 'danger'] as const) {
await button.setVariant(variant);
await expect(button.host).toHaveAttribute('variant', variant);
}
});
test('toggles disabled', async () => {
expect(await button.disabled()).toBe(false);
await button.setDisabled(true);
expect(await button.disabled()).toBe(true);
});
});
test.describe('slots', () => {
test('projects default slot content', async () => {
await expect(button.slotDefault.first()).toBeVisible();
});
test('projects icon slot content', async () => {
// Only test if the demo includes icon slot content
await expect(button.slotIcon).toBeAttached();
});
});
test.describe('events', () => {
test('fires change event', async () => {
const eventData = button.Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.