lewibs/dark-factory/generate-mermaid-ink-url
Claude Code and agent skill by lewibs/dark-factory
- community
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-urlSKILL.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
- Extract the diagram text — obtain the raw Mermaid diagram content (without fences) as a plain string.
- Validate input — if the string is empty or whitespace-only, raise (or return) an error rather than generating a broken URL.
- Base64-encode with URL-safe alphabet — use
base64.urlsafe_b64encode, not the standardbase64.b64encode, becausemermaid.inkexpects 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}" ``
- 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/→_). Standardb64encodewill produce a broken URL because+and/are not URL-safe without percent-encoding. - The script at
${CLAUDE_PLUGIN_ROOT}/scripts/mermaid_to_image.pyimplements this pattern; import or call it rather than re-implementing inline. mermaid.inkis 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 formermaid.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:
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:
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
- SKILL.md in the repositoryCheckingskills/generate-mermaid-ink-url/SKILL.md
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
[](https://verified-skill.com/skills/lewibs/dark-factory/generate-mermaid-ink-url)