lewibs/dark-factory/generate-mermaid-ink-url

Claude Code and agent skill by lewibs/dark-factory

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

How to turn a Mermaid diagram string into a tappable mermaid.ink render URL using Python's standard library base64 module.

Install

npx vskill@latest install lewibs/dark-factory/generate-mermaid-ink-url

SKILL.md

The same SKILL.md was published earlier as lewibs/dark-factory/generate-mermaid-ink-url.

When to use

When you need to share or display a Mermaid diagram as an image URL — for example, to push a tappable link to a developer's phone, embed it in a notification, or add it to a doc — without making any HTTP requests locally.

Steps

  1. Extract the diagram text — obtain the raw Mermaid diagram content (without fences) as a plain string.
  1. Validate input — if the string is empty or whitespace-only, raise (or return) an error rather than generating a broken URL.
  1. Base64-encode with URL-safe alphabet — use base64.urlsafe_b64encode, not the standard base64.b64encode, because mermaid.ink expects URL-safe encoding:

``python import base64 encoded = base64.urlsafe_b64encode(mermaid_string.encode("utf-8")).decode("utf-8") url = f"https://mermaid.ink/img/{encoded}" ``

  1. Return or print the URL — no HTTP request is made locally; the browser renders the diagram when the user taps the link.

Notes

  • Use urlsafe_b64encode (replaces + → - and / → _). Standard b64encode will produce a broken URL because + and / are not URL-safe without percent-encoding.
  • The script at ${CLAUDE_PLUGIN_ROOT}/scripts/mermaid_to_image.py implements this pattern; import or call it rather than re-implementing inline.
  • mermaid.ink is treated as an external black box — do not depend on its availability for correctness tests; unit tests should only assert the URL structure (startswith("https://mermaid.ink/img/")).
  • Padding characters (=) from base64 output are harmless in the URL for mermaid.ink, but if a future service requires padding-free encoding, strip them with .rstrip("=").

Calling the script from agents

When invoking scripts/mermaid_to_image.py from an agent (e.g. sub-planning-agent), always set MERMAID_SKIP_VALIDATE=1:

bash
MERMAID_SKIP_VALIDATE=1 python3 "${CLAUDE_PLUGIN_ROOT}/scripts/mermaid_to_image.py" <planPath>

Why: By default the script calls mmdc (via npx @mermaid-js/mermaid-cli) to validate syntax before generating the URL. In agent/CI environments npx may be unavailable or slow, causing the script to exit non-zero even though the diagram content is valid and the URL could be generated. MERMAID_SKIP_VALIDATE=1 bypasses this validation step and proceeds directly to URL generation.

Inline fallback if the script fails

If the script exits non-zero or produces no output even with MERMAID_SKIP_VALIDATE=1, fall back to generating the URL inline using Python. Extract the raw mermaid diagram text from the plan file (content between `mermaid and the closing ` ), then:

python
import base64
encoded = base64.urlsafe_b64encode(mermaid_string.encode("utf-8")).decode("utf-8")
url = f"https://mermaid.ink/img/{encoded}"

Only set url = null if both the script and the inline fallback fail (e.g., no mermaid block is found in the plan file).

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository forks
1
7-day trend score
0

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/lewibs/dark-factory/generate-mermaid-ink-url/badge)](https://verified-skill.com/skills/lewibs/dark-factory/generate-mermaid-ink-url)

Something wrong with this skill or its page? Tell us.