agentleFS
timurgaleevtimurgaleev/vibestack/skills/diagram/SKILL.md

diagram

Skill8 starsChanged 6 months agoMITView on GitHub

Render Mermaid to self-contained HTML, SVG, PNG and an Excalidraw scene; no diagram toolchain.

51 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ios-sync, benchmark-models and 5 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.
  • Saqlain-811Skill

    ios-sync

    Regenerate the iOS debug bridge against the latest upstream gstack templates. (gstack)

    Also in 4 projects that use this

  • ShreyRaviSkill

    benchmark-models

    Cross-model benchmark for gstack skills. Runs the same prompt through Claude, GPT (via Codex CLI), and Gemini side-by-side — compares latency, tokens, cost, and optionally quality via LLM judge. Answers "which model is actually best for this skill?" with data instead of vibes. Separate from /benchmark, which measures web page performance. Use when: "benchmark models", "compare models", "which model is best for X", "cross-model comparison", "model shootout". (gstack) Voice triggers (speech-to-text aliases): "compare models", "model shootout", "which model is best".

    Also in 5 projects that use this

  • ShreyRaviSkill

    setup-gbrain

    Set up gbrain for this coding agent: install the CLI, initialize a local PGLite or Supabase brain, register MCP, capture per-remote trust policy. One command from zero to "gbrain is running, and this agent can call it." Use when: "setup gbrain", "connect gbrain", "start gbrain", "install gbrain", "configure gbrain for this machine". (gstack)

    Also in 4 projects that use this

  • Saqlain-811Skill

    ios-clean

    Remove the DebugBridge SPM package and all #if DEBUG wiring from an iOS app. (gstack)

    Also in 3 projects that use this

  • seek888Skill

    open-gstack-browser

    Launch GStack Browser — AI-controlled Chromium with the sidebar extension baked in. Opens a visible browser window where you can watch every action in real time. The sidebar shows a live activity feed and chat. Anti-bot stealth built in. Use when asked to "open gstack browser", "launch browser", "connect chrome", "open chrome", "real browser", "launch chrome", "side panel", or "control my browser". Voice triggers (speech-to-text aliases): "show me the browser".

    Also in 4 projects that use this

  • bastosSkill

    ios-design-review

    Review iOS app UI/UX design quality using Apple's design principles and the Liquid Glass-era design language from WWDC25/26. Use when asked for a design review, UX critique, visual design assessment, or evaluation of an app's interface quality, design intent, alignment with the new Apple design system, or usability. Triggers: "design review", "UX review", "visual design critique", "review the UI", "does this design work", "evaluate this interface", "design feedback", "Liquid Glass review".

    Also in 3 projects that use this

  • +1 more from Saqlain-811

The file

We split this skill into the rules it gives an agent

11 rules. 0 are common, 3 are distinctive, and 8 are very specific to this project.

  • 0

    Common

    Most of the 43 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 8

    Very specific

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

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

    If this session was compacted, the copy of this skill in context may be cut off.

    line 17
  2. Very specific:

    Read ${CLAUDE_SKILL_DIR}/SKILL.md from disk and resume at the step you are on.

    line 18
  3. Distinctive:

    Use to turn a description or some Mermaid source into a picture — "draw a diagram", "make a flowchart", "diagram this architecture", …

    line 22
  4. Very specific:

    If the user gave Mermaid, use it.

    line 40
  5. Distinctive:

    5-15 nodes is the readable range: Keep labels to a few words.

    line 49
  6. Distinctive:

    Say what the arrows mean: when a graph mixes kinds of edge — a call, a data flow and a deploy step look identical otherwise.

    line 53
  7. Very specific:

    Write the Mermaid source to $OUT.mmd with the Write tool.

    line 62
  8. Very specific:

    Every $B js / $B wait / $B closetab below MUST pass --tab-id $TAB.

    line 118
  9. Very specific:

    If the first call errors, the Mermaid has a syntax problem — read the error, fix $OUT.mmd, and re-render.

    line 137
  10. Very specific:

    When the user edits $OUT.excalidraw (excalidraw.com, the VS Code extension) and wants the picture back, open a render tab exactly as above …

    line 145
  11. Very specific:

    If RENDER_UNAVAILABLE printed, say what is missing and how to get it back (./install from the checkout for the bundle.

    line 207

“Common” is measured: kept by at least 6 in 10 of the 43 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

If this session was compacted, the copy of this skill in context may be cut off. Read ${CLAUDE_SKILL_DIR}/SKILL.md from disk and resume at the step you are on.

When to invoke

Use to turn a description or some Mermaid source into a picture — "draw a diagram", "make a flowchart", "diagram this architecture", "visualize this as a graph".

/diagram — Render a Mermaid diagram

vibestack renders Mermaid offline. The repo ships the whole renderer as one self-contained page (lib/diagram-render/dist/diagram-render.html, mermaid pinned at build time), so the browse shim turns your source into SVG with no network at all. The SVG is inlined into the HTML artifact you keep — it opens in any browser, on any machine, forever, with nothing to fetch — and the PNG comes from the same $B you already use for QA. The same page also converts the source into an editable .excalidraw scene.

{{include lib/snippets/browse-setup.md}}

1. Get the Mermaid source

If the user gave Mermaid, use it. Otherwise write it from their description (flowchart, sequenceDiagram, erDiagram, classDiagram, gantt, etc.).

Authoring rules, all in service of one thing — a diagram nobody can read is worse than a paragraph:

  • Direction follows the subject. graph LR for pipelines and flows, where the eye should travel with the data; graph TD for hierarchies and decompositions, where depth is the point.
  • 5-15 nodes is the readable range. Keep labels to a few words. If the ask genuinely needs more, split it into two diagrams along a seam the reader already understands (one per subsystem, or overview plus detail) rather than shrinking everything to fit.
  • Say what the arrows mean when a graph mixes kinds of edge — a call, a data flow and a deploy step look identical otherwise.

Then pick an output base path. In a git repo, default to a diagram directory the repo already uses (or docs/) with a slug from the diagram's subject, so the artifacts land somewhere tracked and stop overwriting each other. Outside a repo, default to ./diagram. Confirm the path with the user if the diagram is one they will commit.

Write the Mermaid source to $OUT.mmd with the Write tool. Passing it through a heredoc mangles quotes and backslashes in edge labels, and it is the artifact the user edits to re-render anyway.

2. Render the source to SVG with the offline bundle

The staged copy is content-addressed, so concurrent sessions and mixed vibestack versions never clobber each other:

B='<BROWSE_BIN>'
OUT="${OUT:-./diagram}"            # base path; produces $OUT.mmd/.svg/.html/.png/.excalidraw
mkdir -p "$(dirname "$OUT")"
echo "OUT: $OUT"

# The renderer is linked into this skill's own directory at install time
# (skills/diagram/renderer -> lib/diagram-render), so it resolves the same way
# in a user-scope install, a project-scope install, and the checkout itself.
BUNDLE=""
for c in "${CLAUDE_SKILL_DIR:-$HOME/.claude/skills/diagram}/renderer/dist/diagram-render.html" \
         "$(git rev-parse --show-toplevel 2>/dev/null)/lib/diagram-render/dist/diagram-render.html"; do
  [ -f "$c" ] && BUNDLE="$c" && break
done
if [ -z "$BUNDLE" ] || [ -z "${B:-}" ] || [ "$("$B" status 2>/dev/null)" = "BROWSE_NOT_AVAILABLE" ]; then
  echo "RENDER_UNAVAILABLE"
else
  SHA=$(shasum -a 256 "$BUNDLE" | cut -c1-16)
  # A shared temp dir is writable by others: stage in a dir only this user owns,
  # and reuse a staged copy only when its hash still matches the bundle.
  STAGE_DIR="${TMPDIR:-/tmp}/vibestack-diagram-$(id -u)"
  mkdir -p -m 700 "$STAGE_DIR" 2>/dev/null
  { [ -O "$STAGE_DIR" ] && [ ! -L "$STAGE_DIR" ] && chmod 700 "$STAGE_DIR"; } || STAGE_DIR=$(mktemp -d)
  STAGED="$STAGE_DIR/diagram-render-$SHA.html"
  if [ ! -f "$STAGED" ] || [ "$(shasum -a 256 "$STAGED" | cut -c1-16)" != "$SHA" ]; then
    (umask 077; cp "$BUNDLE" "$STAGED.$$") && mv -f "$STAGED.$$" "$STAGED"
  fi
  TAB=$("$B" newtab --json | sed -n 's/.*"tabId":[[:space:]]*\([0-9]*\).*/\1/p')
  [ -z "$TAB" ] && { echo "TAB_OPEN_FAILED — daemon busy? check browse status"; } || {
    "$B" load-html "$STAGED" --tab-id "$TAB"
    "$B" wait '#done' --tab-id "$TAB"
    echo "RENDER_TAB_READY: tab $TAB"
    echo "TAB: $TAB"
  }
fi

Both failure lines are terminal — STOP, do not continue to Step 3. With no $TAB and no $OUT.svg, the steps below would build an HTML file around a file that does not exist and screenshot a blank page, reporting success. On RENDER_UNAVAILABLE, say which half is missing. A missing bundle means an incomplete checkout — re-run ./install from it. A missing shim means the browse dependencies were never fetched; $B status bootstraps them on first use and prints BROWSE_NOT_AVAILABLE when it cannot (npm absent). On TAB_OPEN_FAILED, report what $B status says — the daemon is busy, wedged, or unable to open a tab — and re-run.

Every $B js / $B wait / $B closetab below MUST pass --tab-id $TAB. Without it the call hits whatever tab is active, which may be a live /qa or /scrape session sharing the daemon.

Render the source, reading it from disk inside the page call so no shell quoting touches the Mermaid text. The blocks below start from fresh shells: replace <OUT> and <TAB> with the values the render block printed on its OUT: and TAB: lines.

B='<BROWSE_BIN>'
OUT='<OUT>'
TAB='<TAB>'
SRC=$(python3 -I -c 'import json,sys; print(json.dumps(open(sys.argv[1]).read()))' "$OUT.mmd")
"$B" js "__renderMermaid('diagram-1', $SRC)" --tab-id "$TAB" --out "$OUT.svg"
"$B" js "__mermaidToExcalidraw($SRC)" --tab-id "$TAB" --out "$OUT.excalidraw"
"$B" closetab "$TAB" >/dev/null 2>&1 || true

If the first call errors, the Mermaid has a syntax problem — read the error, fix $OUT.mmd, and re-render. If only the scene call errors, keep the SVG and report the scene as not produced; it is a bonus artifact, not a gate. Do not fall back to a CDN page: rendering is offline by design, and a silent network fallback turns an air-gapped failure into a blank diagram nobody notices.

Re-render an edited scene

When the user edits $OUT.excalidraw (excalidraw.com, the VS Code extension) and wants the picture back, open a render tab exactly as above and swap the render block for the scene call, then continue with Step 3:

B='<BROWSE_BIN>'
OUT='<OUT>'
TAB='<TAB>'
"$B" js "__excalidrawToSvg($(python3 -I -c 'import json,sys; print(json.dumps(open(sys.argv[1]).read()))' "$OUT.excalidraw"))" \
  --tab-id "$TAB" --out "$OUT.svg"
"$B" closetab "$TAB" >/dev/null 2>&1 || true

Image elements render only from the scene's own embedded files; an image that points at a URL stays blank, because the page never fetches. Flowcharts convert shape by shape; a diagram type the converter does not support comes back as one image element, so the scene opens but is not editable piece by piece — say so when it happens.

3. Inline the SVG into the HTML artifact, then screenshot it

B='<BROWSE_BIN>'
OUT='<OUT>'
{
  printf '%s' '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Diagram</title>'
  printf '%s' '<style>body{margin:0;padding:20px;background:#fff;font-family:system-ui}svg{max-width:100%}</style>'
  printf '%s' '</head><body>'
  cat "$OUT.svg"
  printf '%s' '</body></html>'
} > "$OUT.html"

if [ -n "${B:-}" ] && [ "$("$B" status 2>/dev/null)" != "BROWSE_NOT_AVAILABLE" ]; then
  # The tab verbs above need the full daemon, so this chain uses its single
  # pipe-separated argument; the shim's one-argument-per-step form would run
  # only the goto here.
  "$B" chain "goto \"file://$(cd "$(dirname "$OUT")" && pwd)/$(basename "$OUT").html\" | wait --load | screenshot \"$OUT.png\""
  echo "DIAGRAM: $OUT.png (and $OUT.html, $OUT.svg, $OUT.mmd, $OUT.excalidraw)"
else
  echo "DIAGRAM_HTML_ONLY: $OUT.html — open it in a browser (no shim for PNG)"
fi

The SVG is already drawn, so the capture waits on page load rather than on a fixed timer — nothing is still rendering when the screenshot fires.

4. Report

List the artifacts: .mmd (the source to edit), .svg (vector for docs), .html (opens anywhere, offline), .png (for chat and READMEs), .excalidraw (a scene to hand-edit, then re-render as above).

Notes

  • Mermaid is the source format. The Excalidraw scene is derived from it and can be edited and re-rendered here; DOCX and multi-page exports are not — hand the user the HTML or use a dedicated tool.
  • Fully offline. The renderer is vendored in the repo, and the HTML artifact carries the finished SVG inline — no CDN, no network, at render time or later.
  • PDF-bound diagrams belong to /make-pdf. It renders a ```mermaid fence as a vector figure inside the document, which beats pasting this skill's PNG into a page. Say so when the user's real target is a PDF.
  • If RENDER_UNAVAILABLE printed, say what is missing and how to get it back (./install from the checkout for the bundle; $B status to bootstrap the browse dependencies). Never fall back to a CDN behind the user's back.

{{include lib/snippets/capture-learnings.md}}

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.