Skip to content

paperclipai/paperclip / .agents/skills/directions-lab

directions-lab

Verified

Scaffold a directions lab that shows shipped UI (Today) beside 2-3 design directions, with surface tabs, theme and animation toggles and the V1 MVP hover motion, registered in design-proposals Storybook. Use for a directions page or lab, or to explore design directions next to production.

FileKindSize
SKILL.mdskill md15.4 KB
agents/openai.yamlconfig291 B
assets/PRECEDENTother187 B
assets/motion/v1-mvp-motion.cssother787 B
assets/templates/api-routes.ts.mjsscript531 B
assets/templates/api-stub.ts.mjsscript1.9 KB
assets/templates/build-info.ts.mjsscript220 B
assets/templates/define-lab.ts.mjsscript3.9 KB
assets/templates/direction/MotionSpecimen.tsx.mjsscript2.3 KB
assets/templates/direction/SlotBody.tsx.mjsscript521 B
assets/templates/direction/index.tsx.mjsscript445 B
assets/templates/direction/tokens.css.mjsscript1.1 KB
assets/templates/entry.html.mjsscript752 B
assets/templates/fixtures.ts.mjsscript1.2 KB
assets/templates/frames/AppShell.tsx.mjsscript5.2 KB
assets/templates/frames/Board.tsx.mjsscript4.8 KB
assets/templates/frames/LabToolbar.tsx.mjsscript4.4 KB
assets/templates/frames/Slot.tsx.mjsscript329 B
assets/templates/frames/SurfaceFrame.tsx.mjsscript1.3 KB
assets/templates/frames/SurfaceView.tsx.mjsscript540 B
assets/templates/kit.ts.mjsscript1.9 KB
assets/templates/lab-state.ts.mjsscript1.8 KB
assets/templates/lab.css.mjsscript74 B
assets/templates/launch-entries.json.mjsscript680 B
assets/templates/main.tsx.mjsscript6.2 KB
assets/templates/providers.tsx.mjsscript920 B
assets/templates/registry.ts.mjsscript1.6 KB
assets/templates/shot.cjs.mjsscript10.0 KB
assets/templates/stories/compare.stories.tsx.mjsscript3.4 KB
assets/templates/tests/api-stub.test.ts.mjsscript1.6 KB
assets/templates/tests/lab-state.test.ts.mjsscript3.1 KB
assets/templates/tests/motion-contract.test.ts.mjsscript5.7 KB
assets/templates/tests/registry.test.ts.mjsscript2.5 KB
assets/templates/tests/today.test.tsx.mjsscript2.0 KB
assets/templates/today/SlotBody.tsx.mjsscript972 B
assets/templates/today/adapters.ts.mjsscript748 B
assets/templates/today/index.tsx.mjsscript387 B
assets/templates/vite.config.mjs.mjsscript2.9 KB
evals/asks-how-many-directions/case.yamlconfig343 B
evals/asks-how-many-directions/graders/01-expected-output.mdmarkdown347 B
evals/asks-how-many-directions/prompt.mdmarkdown197 B
evals/multi-surface-three-directions/case.yamlconfig674 B
evals/multi-surface-three-directions/graders/01-expected-output.mdmarkdown672 B
evals/multi-surface-three-directions/prompt.mdmarkdown510 B
evals/single-surface-two-directions/case.yamlconfig398 B
evals/single-surface-two-directions/graders/01-expected-output.mdmarkdown397 B
evals/single-surface-two-directions/prompt.mdmarkdown284 B
references/canonical-directory.mdmarkdown15.5 KB
references/design-proposals-storybook.mdmarkdown29.2 KB
references/drawing-phases.mdmarkdown21.7 KB
references/generator.mdmarkdown25.7 KB
references/lab-anatomy.mdmarkdown28.7 KB
references/lifecycle.mdmarkdown18.9 KB
references/motion-spec.mdmarkdown21.1 KB
references/questions-and-defaults.mdmarkdown15.6 KB
references/repo-gates.mdmarkdown20.8 KB
references/today-fixtures-and-build.mdmarkdown34.9 KB
scripts/lib/args.mjsscript2.4 KB
scripts/lib/capabilities.mjsscript2.1 KB
scripts/lib/check.mjsscript10.6 KB
scripts/lib/context.mjsscript8.6 KB
scripts/lib/modes.mjsscript1001 B
scripts/lib/ports.mjsscript1.9 KB
scripts/lib/registry-edit.mjsscript5.2 KB
scripts/lib/render.mjsscript3.6 KB
scripts/lib/shared-files.mjsscript2.9 KB
scripts/lib/verify.mjsscript1.8 KB
scripts/lib/write.mjsscript2.3 KB
scripts/scaffold.mjsscript14.3 KB
scripts/scaffold.test.mjsscript33.7 KB

assets/templates/shot.cjs.mjs

View on GitHub
export default (ctx) => `#!/usr/bin/env node
"use strict";

const fs = require("node:fs");
const path = require("node:path");

const THEMES = ["dark", "light"];

const HELP = \`Usage:
  node ${ctx.labDir}/shot.cjs --port <p> --d <kit|all> --out <dir> [--s <surfaces,board>] [--theme <themes>] [--hover]

  --port   port of a running lab dev server (required)
  --d      a direction id | all   (default: today; the ids come from the page's window.__LAB__)
           "all" captures every kit; for the board it composes the one all-kits sheet
  --out    output directory (required; created if missing)
  --s      comma-separated surfaces and/or board   (default: every surface and the board)
  --theme  comma-separated: \${THEMES.join(",")}   (default: both)
  --hover  also capture each surface with the first kit button hovered (no reduced motion)

Start the dev server first (it is not started for you):
  cd ui && npx vite --config ${ctx.configFile} --port <p> --strictPort
\`;

function parseArgs(argv) {
  const args = {};
  for (let i = 0; i < argv.length; i += 1) {
    const token = argv[i];
    if (token === "--help" || token === "-h") args.help = true;
    else if (token === "--hover") args.hover = true;
    else if (token.startsWith("--")) {
      const [key, inline] = token.slice(2).split("=");
      args[key] = inline ?? argv[(i += 1)];
    }
  }
  return args;
}

function list(value, allowed, name) {
  if (!value) return allowed;
  const picked = value.split(",").map((item) => item.trim()).filter(Boolean);
  const unknown = picked.filter((item) => !allowed.includes(item));
  if (unknown.length > 0) fail(\`Unknown \${name}: \${unknown.join(", ")} (expected \${allowed.join(", ")})\`);
  return picked;
}

function fail(message) {
  console.error(\`shot: \${message}\\n\`);
  console.error(HELP);
  process.exit(2);
}

function loadChromium() {
  for (const name of ["@playwright/test", "playwright"]) {
    try {
      return require(name).chromium;
    } catch {
      continue;
    }
  }
  throw new Error("Playwright is not installed (looked for @playwright/test and playwright). Run pnpm install.");
}

async function settleFrame() {
  for (const img of document.querySelectorAll('img[loading="lazy"]')) img.loading = "eager";
  await document.fonts.ready;
  const quiet = () =>
    new Promise((resolve) => {
      let timer = setTimeout(done, 400);
      const observer = new MutationObserver(() => {
        clearTimeout(timer);
        timer = setTimeout(done, 400);
      });
      function done() {
        observer.disconnect();
        resolve();
      }
      observer.observe(document.documentElement, { subtree: true, childList: true, attributes: true, characterData: true });
    });
  await quiet();
  await Promise.all(
    [...document.images].map((img) =>
      img.complete ? null : new Promise((resolve) => ["load", "error"].forEach((type) => img.addEventListener(type, resolve, { once: true }))),
    ),
  );
  await Promise.all(
    [...document.querySelectorAll("video")].map((video) =>
      video.readyState >= 2 ? null : new Promise((resolve) => {
        ["loadeddata", "error"].forEach((type) => video.addEventListener(type, resolve, { once: true }));
        setTimeout(resolve, 3500);
      }),
    ),
  );
  await quiet();
}

function watch(page) {
  const problems = [];
  page.on("console", (message) => {
    if (message.type() === "error") problems.push(\`console error: \${message.text()}\`);
  });
  page.on("pageerror", (error) => problems.push(\`page error: \${error.message}\`));
  page.on("requestfailed", (request) => problems.push(\`request failed: \${request.url()} (\${request.failure()?.errorText ?? "unknown"})\`));
  page.on("response", (response) => {
    if (response.status() >= 400) problems.push(\`HTTP \${response.status()}: \${response.url()}\`);
  });
  return problems;
}

async function discoverLab(browser, base) {
  const context = await browser.newContext({ viewport: { width: 1440, height: 900 } });
  const page = await context.newPage();
  const problems = watch(page);
  await page.goto(\`\${base}/?chrome=0\`, { waitUntil: "networkidle", timeout: 120000 });
  const lab = await page.evaluate(() => window.__LAB__);
  await context.close();
  if (!lab) throw new Error(\`page did not expose window.__LAB__; main.tsx did not run, read the console\${problems.length ? \`:\\n  \${problems.join("\\n  ")}\` : ""}\`);
  return lab;
}

const shotUrl = (base, shot) => \`\${base}/?d=\${shot.kit}&s=\${shot.surface}&theme=\${shot.theme}&chrome=0\`;

async function capture(browser, base, shot, outDir) {
  const context = await browser.newContext({
    viewport: { width: 1440, height: 900 },
    deviceScaleFactor: 2,
    reducedMotion: "reduce",
  });
  const page = await context.newPage();
  const problems = watch(page);
  await page.goto(shotUrl(base, shot), { waitUntil: "networkidle", timeout: 120000 });
  for (const frame of page.frames()) await frame.evaluate(settleFrame);
  const file = path.join(outDir, \`\${shot.kit}__\${shot.surface}__\${shot.theme}.png\`);
  await page.screenshot({ path: file, fullPage: true });
  await context.close();
  return { file, problems };
}

async function captureHover(browser, base, shot, outDir) {
  const context = await browser.newContext({ viewport: { width: 1440, height: 900 }, deviceScaleFactor: 2 });
  const page = await context.newPage();
  const problems = watch(page);
  await page.goto(shotUrl(base, shot), { waitUntil: "networkidle", timeout: 120000 });
  for (const frame of page.frames()) await frame.evaluate(settleFrame);
  const target = page.locator("[data-direction] button").first();
  const file = path.join(outDir, \`\${shot.kit}__\${shot.surface}__\${shot.theme}__hover.png\`);
  if ((await target.count()) === 0) problems.push(\`no button inside [data-direction] to hover at \${shotUrl(base, shot)}\`);
  else {
    await target.hover();
    await page.waitForTimeout(350);
    await page.screenshot({ path: file, fullPage: true });
  }
  await context.close();
  return { file, problems };
}

async function captureBoard(browser, base, lab, kit, theme, outDir) {
  const kits = kit === "all" ? lab.directions : [kit];
  const problems = [];
  for (const k of kits) {
    for (const surface of lab.surfaces) {
      if (fs.existsSync(path.join(outDir, \`\${k}__\${surface}__\${theme}.png\`))) continue;
      const result = await capture(browser, base, { kit: k, surface, theme }, outDir);
      problems.push(...result.problems);
    }
  }
  const dark = theme === "dark";
  const tile = (k, surface) => \`<figure style="height:1100px"><img src="\${k}__\${surface}__\${theme}.png" alt="\${k} \${surface}"></figure>\`;
  const rows = kits.map((k) => \`<section><h2>\${lab.names[k]}</h2>\${lab.surfaces.map((surface) => tile(k, surface)).join("")}</section>\`).join("");
  const heads = lab.surfaces.map((surface) => \`<span>\${lab.labels[surface]}</span>\`).join("");
  const html = \`<!doctype html><meta charset="utf-8"><style>
    body{margin:0;padding:32px;background:\${dark ? "#0f0f0f" : "#e9e9e9"};color:\${dark ? "#f5f5f5" : "#171717"};font:600 22px/1.2 Inter,system-ui,sans-serif}
    header,section{display:grid;grid-template-columns:150px repeat(\${lab.surfaces.length},minmax(0,1fr));gap:16px;align-items:start}
    header{font:500 13px/1 ui-monospace,Menlo,monospace;letter-spacing:.08em;text-transform:uppercase;opacity:.6;margin-bottom:12px}
    section{margin-bottom:32px}h2{margin:0;font:inherit}
    figure{margin:0;overflow:hidden;border-radius:6px;outline:1px solid \${dark ? "#ffffff1f" : "#0000001f"}}
    img{display:block;width:100%}
  </style><header><span>\${theme}</span>\${heads}</header>\${rows}\`;
  const sheet = path.join(outDir, \`.board-\${kit}-\${theme}.html\`);
  fs.writeFileSync(sheet, html);
  const context = await browser.newContext({ viewport: { width: 2880, height: 1200 }, deviceScaleFactor: 1 });
  const page = await context.newPage();
  await page.goto(\`file://\${sheet}\`, { waitUntil: "load" });
  const file = path.join(outDir, \`\${kit}__board__\${theme}.png\`);
  await page.screenshot({ path: file, fullPage: true });
  await context.close();
  fs.unlinkSync(sheet);
  return { file, problems };
}

async function main() {
  const args = parseArgs(process.argv.slice(2));
  if (args.help) {
    console.log(HELP);
    return;
  }
  if (!args.port) fail("--port is required");
  if (!args.out) fail("--out is required");
  const base = \`http://127.0.0.1:\${args.port}\`;
  const browser = await loadChromium().launch({ headless: true });
  let failed = 0;
  let shots = [];
  try {
    const lab = await discoverLab(browser, base);
    const kit = args.d ?? "today";
    if (kit !== "all" && !lab.directions.includes(kit)) fail(\`Unknown --d: \${kit} (expected \${lab.directions.join(", ")} or all)\`);
    const views = list(args.s, [...lab.surfaces, "board"], "surface");
    const themes = list(args.theme, THEMES, "theme");
    for (const surface of [...views.filter((s) => s !== "board"), ...views.filter((s) => s === "board")]) {
      const kits = kit === "all" && surface !== "board" ? lab.directions : [kit];
      for (const k of kits) for (const theme of themes) shots.push({ kit: k, surface, theme });
    }
    const outDir = path.resolve(args.out);
    fs.mkdirSync(outDir, { recursive: true });
    for (const shot of shots) {
      const results = [];
      if (shot.surface === "board") results.push(await captureBoard(browser, base, lab, shot.kit, shot.theme, outDir));
      else {
        results.push(await capture(browser, base, shot, outDir));
        if (args.hover) results.push(await captureHover(browser, base, shot, outDir));
      }
      for (const { file, problems } of results) {
        console.log(\`\${problems.length > 0 ? "FAIL" : "ok  "} \${file}\`);
        for (const problem of [...new Set(problems)]) console.log(\`       \${problem}\`);
        if (problems.length > 0) failed += 1;
      }
    }
  } finally {
    await browser.close();
  }
  if (failed > 0) {
    console.error(\`\\nshot: \${failed} capture(s) reported errors.\`);
    process.exit(1);
  }
}

main().catch((error) => {
  console.error(\`shot: \${error.message}\`);
  process.exit(1);
});
`;
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 323kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall