Skip to content

JimLiu/baoyu-skills / skills/baoyu-diagram

baoyu-diagram

Flagged

Create professional diagrams with configurable dark/light theme via CSS custom properties. Use this skill whenever the user asks for any kind of technical or conceptual diagram, visualization of a system, process flow, data flow, component relationship, network topology, decision tree, org chart, state machine, or any visual representation of structure/logic/process. Also trigger when the user says "画个图" "画一个架构图" "diagram" "flowchart" "sequence diagram" "draw me a ..." or uploads content and asks to visualize it. Outputs a dark-theme SVG, a light-theme SVG, and a @2x PNG of each.

FileKindSize
SKILL.mdskill md15.8 KB
references/architecture.mdmarkdown3.1 KB
references/flowchart.mdmarkdown2.3 KB
references/sequence.mdmarkdown3.9 KB
references/structural.mdmarkdown3.8 KB
scripts/bun.lockother8.1 KB
scripts/flatten-vars.tsscript1.3 KB
scripts/main.tsscript5.3 KB
scripts/package.jsonmanifest104 B
scripts/theme-switch.tsscript7.1 KB
scripts/themes.test.tsscript2.9 KB
scripts/themes.tsscript4.1 KB
themes/dark.jsonconfig958 B
themes/light.jsonconfig978 B

scripts/themes.test.ts

View on GitHub
import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync, readdirSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

import { flattenVars, hasCssVars, listThemes, loadTheme, THEMES_DIR } from "./themes.ts";

const SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
<style>
:root { --bg: #000000; --only-here: #123456; }
</style>
<rect fill="var(--bg)"/><rect fill="var(--only-here)"/><rect fill="var(--nowhere, #abcdef)"/>
</svg>`;

test("dark and light themes define the same variables", () => {
  assert.deepEqual(listThemes().slice(0, 2).length, 2);
  assert.deepEqual(Object.keys(loadTheme("light")).sort(), Object.keys(loadTheme("dark")).sort());
});

test("loadTheme reports available themes for an unknown name", () => {
  assert.throws(() => loadTheme("does-not-exist"), /available: .*dark.*light/);
});

test("flattenVars inlines theme values, SVG-defined values and fallbacks", () => {
  const { svg, count, missing } = flattenVars(SVG, loadTheme("light"));
  assert.equal(count, 3);
  assert.deepEqual(missing, []);
  assert.equal(hasCssVars(svg), false);
  assert.match(svg, /fill="#f8fafc"/);
  assert.match(svg, /fill="#123456"/);
  assert.match(svg, /fill="#abcdef"/);
  assert.doesNotMatch(svg, /:root/);
});

test("flattenVars keeps functional and nested fallbacks intact", () => {
  const svg = '<rect fill="var(--bg, rgb(255,255,255))"/><rect fill="var(--nope, rgba(1,2,3,0.5))"/><rect fill="var(--nope, var(--text))"/>';
  const { svg: out, missing } = flattenVars(svg, loadTheme("light"));
  assert.deepEqual(missing, []);
  assert.equal(out, '<rect fill="#f8fafc"/><rect fill="rgba(1,2,3,0.5)"/><rect fill="#0f172a"/>');
});

test("flattenVars resolves aliases and stops on cycles", () => {
  const svg = '<style>:root { --label: var(--text); --a: var(--b); --b: var(--a); }</style><text fill="var(--label)"/><rect fill="var(--a)"/>';
  const { svg: out, missing } = flattenVars(svg, loadTheme("light"));
  assert.match(out, /<text fill="#0f172a"\/>/);
  assert.doesNotMatch(out, /<text fill="var/);
  assert.ok(missing.length > 0);
});

test("flattenVars reports variables it cannot resolve", () => {
  const { missing } = flattenVars('<rect fill="var(--typo)"/>', loadTheme("dark"));
  assert.deepEqual(missing, ["--typo"]);
});

test("reference examples use only theme variables for colors", () => {
  const dir = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "references");
  const known = new Set(Object.keys(loadTheme("dark")));
  for (const file of readdirSync(dir)) {
    const text = readFileSync(path.join(dir, file), "utf8");
    assert.doesNotMatch(text, /(?:fill|stroke)="(?:#[0-9a-fA-F]{3,8}|rgba?\(|white|black)/, file);
    for (const m of text.matchAll(/var\((--[\w-]+)\)/g)) assert.ok(known.has(m[1]), `${file}: ${m[1]}`);
  }
  assert.ok(THEMES_DIR.endsWith("themes"));
});
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