validate-mermaid
Validate Mermaid diagrams in Markdown, MDX, HTML, and standalone Mermaid files using Mermaid's own parser. Use when an agent creates or edits Mermaid diagrams, when a browser reports "Syntax error in text", or before publishing generated docs and reports.
- License 许可
- MIT
- 最近更新
- 2026-08-20
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- validate-mermaid
- description
- Validate Mermaid diagrams in Markdown, MDX, HTML, and standalone Mermaid files using Mermaid's own parser. Use when an agent creates or edits Mermaid diagrams, when a browser reports "Syntax error in text", or before publishing generated docs and reports.
02 资源文件 4
- 参考文档agents/openai.yaml197 B
- 脚本scripts/validate.mjs4.7 KB
- 脚本scripts/validate.py7.7 KB
- 脚本tests/test_validate_mermaid.py6.6 KB
03 SKILL.md 正文
Validate Mermaid
Run Mermaid's parser over diagrams before treating their source as complete. This catches grammar errors with the same parser family used by the browser instead of relying on visual inspection or a Markdown parser that does not understand Mermaid.
Validate
From this skill's directory, run:
python3 scripts/validate.py <file-or-directory>
Add --recursive when a directory tree should be scanned:
python3 scripts/validate.py --recursive <directory>
The command reads Mermaid fences in .md, .markdown, and .mdx; elements with the mermaid class in .html and .htm; and complete diagrams in .mmd and .mermaid files. Recursive scans skip .git, other version-control metadata, virtual environments, and node_modules.
Use the Mermaid version that will render the document. Exact versions in HTML imports are detected automatically. For another renderer, pass its exact version explicitly:
python3 scripts/validate.py --mermaid-version 11.16.1 <path>
Files without a detectable renderer version use Mermaid 11.16.1. The first run for a version installs Mermaid and JSDOM into ~/.cache/validate-mermaid; it does not add packages to the user's repository.
Handle results
The validator prints each diagram's file and starting line. It exits non-zero when a diagram is invalid, a requested path cannot be read, no supported documents are found, or the scanned documents contain no Mermaid diagrams.
When diagram changes are part of the current task, fix every reported syntax error and rerun the same command until it succeeds. When the user asked only for validation, report the errors without changing their files.
Report the command, Mermaid version, number of diagrams, and whether validation passed. Do not claim that syntax validation proves browser rendering: CDN loading, fonts, sizing, theme behaviour, and layout still require a browser check.
04 同仓库更多 Skills
writing-for-agents
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.
wait-what
Stop. That last message did not land — re-pitch it.
to-questionnaire
Turn a decision you can't fully answer into a questionnaire for someone else to fill in.
teach
Teach the user a new skill or concept, within this workspace.
slidev
Build, revise, and verify Slidev presentations as working web projects.
handoff
Compact the current conversation into a handoff document for another agent to pick up.