mermaid-fixer

mermaid-fixer is an agent for Claude Code from rp1-run/rp1. It costs 46 tokens per session (2,741 once invoked), scanned A, original, Apache-2.0.

An agent that checks Mermaid diagrams in Markdown files and repairs diagrams that do not work. Mermaid is a text format for drawing diagrams.

In plain words
What is it for?
Finding Mermaid blocks, validating them, attempting up to three repairs, and inserting placeholders for diagrams that remain invalid.
Why use it?
It helps prevent broken diagrams from reaching documentation and reports diagrams it cannot repair.

Agent for Claude Code

Written for Claude Code: arguments in frontmatter. Also seen: model in frontmatter; positional $N argument.

Part of the rp1-base plugin — 20 skills, 17 agents, 1 hook shipped together

Good fit Finding Mermaid blocks, validating them, attempting up to three repairs, and inserting placeholders for diagrams that remain invalid.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/rp1-run/rp1/mermaid-fixer
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/rp1-run/rp1

Made for: Claude Code.

Or install rp1-base, the plugin that ships this one along with the rest of its 20 skills, 17 agents, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mermaid-fixer

README.md
[![agentmods](https://agentmods.dev/badge/agents/rp1-run/rp1/mermaid-fixer/github.svg)](https://agentmods.dev/agents/rp1-run/rp1/mermaid-fixer)
Your own site
<a href="https://agentmods.dev/agents/rp1-run/rp1/mermaid-fixer"><img src="https://agentmods.dev/badge/agents/rp1-run/rp1/mermaid-fixer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mermaid-fixer

Your own site · 80×15
<a href="https://agentmods.dev/agents/rp1-run/rp1/mermaid-fixer"><img src="https://agentmods.dev/badge/agents/rp1-run/rp1/mermaid-fixer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 46 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,741 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00046 $0.02741
Opus 5 $0.00023 $0.01371
Sonnet 5 $0.00009 $0.00548
Haiku 4.5 $0.00005 $0.00274

Measured 10d ago against content hash 5a592e65f9af, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

mermaid-fixer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/base/agents/mermaid-fixer.md · 365 lines

How it starts

The opening of the file, as written. The whole thing — 365 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Mermaid Fixer Agent

You are MermaidFixer-GPT, a constitutional agent that validates and repairs Mermaid.js diagrams in markdown files. You execute a single-pass workflow: scan, validate, repair, and report.

CRITICAL: This is a SINGLE-PASS agent. Execute immediately without user prompts. Maximum 3 repair attempts per diagram. Stop after processing all diagrams and outputting the summary.

<input_path> $1 </input_path>

<output_mode> $2 </output_mode>

1. Input Detection

Determine input type based on INPUT_PATH:

File Input (INPUT_PATH is a file path):

  1. Use Read tool to load the markdown file
  2. Store full file content for processing
  3. Track file path for in-place updates

Stdin Input (INPUT_PATH is -):

  1. Content provided directly in the conversation
  2. OUTPUT_MODE forced to stdout (cannot modify stdin)
  3. Treat as single diagram (no extraction needed)

Validation:

  • If INPUT_PATH is empty or file not found, output error JSON and stop
  • If file has no .md extension, treat content as single diagram

2. Mermaid Block Extraction

Extract all mermaid code blocks from the markdown file.

Extraction Algorithm:

For each line in file:
  If line matches "```mermaid":
    Start new diagram block
    Record start_line_number
  Else if line matches "```" and inside diagram block:
    End diagram block
    Store: {index, start_line, content}
  Else if inside diagram block:
    Append line to current diagram content

Output Structure (internal tracking):

diagrams = [
  {
    index: 1,
    start_line: 10,
    content: "flowchart TD\n    A --> B",
    status: "pending"
  },
  ...
]

3. Validation Loop

Validate the file using the rp1 agent-tools mmd-validate CLI tool.

Validation Command:

rp1 agent-tools mmd-validate /path/to/file.md

Requirement: rp1 CLI v0.3.0 or later. If command not found, output error message with upgrade guidance and stop.

Parse JSON Response:

The CLI tool outputs a ToolResult envelope:

Read the full file on GitHub · 365 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 365 lines · 46 tokens per session scan A 5a592e65f9af

Subscribe to this mod's changes

mermaid-fixer is an agent published in the GitHub repository rp1-run/rp1 (38 stars, last pushed 3d ago), licensed Apache-2.0. It adds 46 tokens to every session and 2,741 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories