agentleFS
liatrio-labsliatrio-labs/ai-prompts/skills/create-mermaid-diagrams/SKILL.md

create-mermaid-diagrams

Skill4 starsChanged 13 months agoApache-2.0View on GitHub

Create, validate, and repair Mermaid diagrams for technical documentation with a deterministic CLI feedback loop. Use when an AI needs to create Mermaid diagrams, improve Mermaid diagram quality, validate Mermaid fences in markdown, diagnose Mermaid rendering failures, or fix Mermaid syntax and formatting issues.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. narumiruna/skills★ 15same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository8 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. About 0 are common, 11 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create clear Mermaid diagrams and always validate output through a repeatable loop that catches syntax and rendering errors before final …

    line 10
  2. Distinctive:

    Always begin your response with all active emoji markers, in the order they were introduced.

    line 14
  3. Distinctive:

    When manual invocation is needed, trigger this skill using whatever mechanism your assistant/tool provides for manual skill selection or …

    line 22
  4. Distinctive:

    Keep fence markers at column 0.

    line 33
  5. Very specific:

    Read raw Mermaid CLI output from mmdc.

    line 41
  6. Distinctive:

    If still failing after 3 attempts, return:

    line 45
  7. Distinctive:

    Do not change diagram type unless the error indicates the type keyword is invalid.

    line 53
  8. Distinctive:

    Prefer minimal edits per retry to avoid introducing new syntax errors.

    line 54
  9. Distinctive:

    Stop retrying early when validation succeeds.

    line 56
  10. Very specific:

    If running in a sandboxed AI tool, allow execution of mmdc explicitly.

    line 61
  11. Very specific:

    Treat mmdc stdout/stderr as the source of truth for pass/fail and diagnosis.

    line 62
  12. Distinctive:

    When validating an existing markdown file that includes multiple Mermaid blocks:

    line 66
  13. Very specific:

    Run one full-file validation command with mmdc.

    line 68
  14. Very specific:

    Treat any non-zero mmdc exit as a failure and use Mermaid CLI output as the source of truth for diagnosis and repair.

    line 76
  15. Distinctive:

    When validation cannot run, the response must clearly state that validation did not occur and include:

    line 78
  16. Distinctive:

    Always include the final Mermaid markdown block.

    line 87

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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

Create Mermaid Diagrams

Overview

Create clear Mermaid diagrams and always validate output through a repeatable loop that catches syntax and rendering errors before final delivery.

Context Marker

Always begin your response with all active emoji markers, in the order they were introduced.

Format: "<marker1><marker2><marker3>\n<response>"

The marker for this skill is: 🎨

Manual Triggering

When manual invocation is needed, trigger this skill using whatever mechanism your assistant/tool provides for manual skill selection or activation.

Workflow

  1. Define communication intent and choose the smallest diagram type that fits:
    • flowchart for process and architecture flow.
    • sequenceDiagram for interaction timelines.
    • stateDiagram-v2 for state transitions.
  2. Generate markdown with exactly one Mermaid fence per requested diagram:
    • Opening fence must be exactly <code>```mermaid</code> (no leading space; any spaced example is only Markdown escaping).
    • Closing fence must be exactly <code>```</code> (no leading space; any spaced example is only Markdown escaping).
    • Keep fence markers at column 0.
  3. Validate the full markdown file with mmdc:

    mmdc -i <input.md> -o /tmp/<name>-rendered.md -a /tmp/<name>-mermaid-artifacts
  4. If validation fails:
    • Read raw Mermaid CLI output from mmdc.
    • Apply the minimal targeted fix in the failing Mermaid fence.
    • Re-run the same full-file validation command.
  5. Repeat failure analysis and correction up to 3 attempts.
  6. If still failing after 3 attempts, return:
    • Best-effort corrected diagram.
    • Validation summary with likely root cause.
    • Raw error excerpt from Mermaid CLI output.
    • Next manual fix suggestion.

Feedback Loop Rules

  • Do not change diagram type unless the error indicates the type keyword is invalid.
  • Prefer minimal edits per retry to avoid introducing new syntax errors.
  • Preserve user intent and semantic meaning while repairing syntax.
  • Stop retrying early when validation succeeds.

Runtime Requirements

  • mmdc must be available in PATH.
  • If running in a sandboxed AI tool, allow execution of mmdc explicitly.
  • Treat mmdc stdout/stderr as the source of truth for pass/fail and diagnosis.

Existing Documentation with Multiple Mermaid Diagrams

When validating an existing markdown file that includes multiple Mermaid blocks:

  1. Run one full-file validation command with mmdc.
  2. Parse CLI output to identify discovered block count and rendered artifacts.
  3. For failures, use parse error snippet and caret location to identify the failing fence.
  4. Patch only failing blocks, then re-run full-file validation.
  5. Provide a final rollup: total blocks, passed, failed, fixed, unresolved.

Error Handling

Treat any non-zero mmdc exit as a failure and use Mermaid CLI output as the source of truth for diagnosis and repair. For dependency, access, or input failures (for example mmdc not executable in sandbox), stop immediately and do not continue retries. When validation cannot run, the response must clearly state that validation did not occur and include:

  • the exact mmdc command that failed
  • exit code (if available)
  • a raw stderr excerpt
  • explicit next steps to grant mmdc execution access or fix file/path permissions

Output Requirements

  • Always include the final Mermaid markdown block.
  • Include a short validation result summary.
  • On failure, include the actionable error context and exact next steps.

References

  • Mermaid best practices and templates: references/mermaid-best-practices.md
  • Advanced diagram patterns and constructs: references/advanced-patterns.md
  • Error classes and repair strategies: references/error-patterns.md
  • Multi-diagram markdown validation workflow: references/multi-diagram-validation.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.