From sugarforever-01coder-agent-skills
Converts Mermaid diagrams and Markdown tables to PNG images via the mermaid-red API. Useful for platforms that don't support rich formatting, such as X/Twitter.
How this skill is triggered — by the user, by Claude, or both
Slash command
/sugarforever-01coder-agent-skills:diagram-to-imageThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Convert Mermaid diagrams and Markdown tables to PNG images via the mermaid-red API (diagramless.xyz). Produces high-quality, styled output with custom themes — no heavy local dependencies needed.
Convert Mermaid diagrams and Markdown tables to PNG images via the mermaid-red API (diagramless.xyz). Produces high-quality, styled output with custom themes — no heavy local dependencies needed.
Use this skill when:
The bundled script uses Node.js built-in fetch (Node 18+). No npm install needed.
# The render script is bundled with this skill:
SKILL_DIR=~/.claude/skills/diagram-to-image/scripts
ls $SKILL_DIR/diagram-to-image.mjs
IMPORTANT: Determine the best output location based on context. Follow this decision tree:
If user explicitly mentions a path or filename, use that.
Check for common image/asset directories in the current project:
# Check for existing image directories (in order of preference)
ls -d ./images ./assets ./img ./static ./public/images ./assets/images 2>/dev/null | head -1
Use the first existing directory found. Common patterns:
./images/ - General projects./assets/ - Web projects./assets/images/ - Structured web projects./public/images/ - Next.js, React projects./static/ - Hugo, other static site generators./img/ - Short form conventionIf user is writing an article or document:
images/ subdirectory if appropriateAnalyze the conversation to determine:
auth-flow.png, user-journey.png)If no context clues:
Create meaningful filenames based on content analysis:
| Content Pattern | Example Filename |
|---|---|
flowchart with auth/login | auth-flow.png |
sequenceDiagram with API | api-sequence.png |
erDiagram | entity-relationship.png |
pie chart about X | x-distribution.png |
gantt chart | project-timeline.png |
| Table with comparison | comparison-table.png |
| Table with data | data-table.png |
Rules:
diagram.png or image.pngBefore converting, gather context:
# Example logic (implement mentally, not as literal script)
if user_specified_path:
output_path = user_specified_path
elif exists("./images"):
output_path = "./images/{generated_name}.png"
elif exists("./assets"):
output_path = "./assets/{generated_name}.png"
elif exists("./public/images"):
output_path = "./public/images/{generated_name}.png"
else:
output_path = "./{generated_name}.png"
# For Mermaid diagrams
cat > /tmp/diagram.mmd << 'DIAGRAM_EOF'
<mermaid content>
DIAGRAM_EOF
# For Markdown tables
cat > /tmp/table.md << 'TABLE_EOF'
<table content>
TABLE_EOF
The API auto-detects content type (mermaid vs table). Both use the same command.
Using the bundled script:
# Mermaid diagram
node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/diagram.mmd -o <output_path>.png
# Markdown table
node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/table.md -o <output_path>.png
# With custom theme
node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/diagram.mmd -o <output_path>.png --theme ocean
# Force content type (if auto-detect gets it wrong)
node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/table.md -o <output_path>.png --type table
Available options:
--theme <name> — default, dark, forest, neutral, ocean, emerald, midnight, slate, lavender, blueprint--type <type> — auto (default), mermaid, table--scale <n> — 1-4 (default: 2, for 2x DPI)--bg <color> — Background color (default: white, use "transparent" for no bg)--server <url> — Override server (default: https://diagramless.xyz)Piping from stdin also works:
echo "graph TD; A-->B" | node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs -o out.png
cat /tmp/table.md | node ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs --type table -o table.png
After conversion, tell the user:
Context: User is in a project that has ./images/ directory, discussing authentication.
User: "Convert this to an image"
flowchart TD
A[Login] --> B{Valid?}
B -->|Yes| C[Dashboard]
B -->|No| D[Error]
Action:
./images/ existslogin-flow.png/tmp/diagram.mmdnode ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/diagram.mmd -o ./images/login-flow.pngContext: User mentioned writing an article about AI agents for X.
User: "Make this a PNG with ocean theme"
flowchart LR
User --> Agent --> Tools --> Response
Action:
/tmp/diagram.mmdnode ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/diagram.mmd -o ./ai-agent-flow.png --theme oceanUser: "Export this table as image"
| Model | Speed | Accuracy |
|-------|-------|----------|
| GPT-4 | Slow | High |
| Claude | Fast | High |
Action:
/tmp/table.mdnode ~/.claude/skills/diagram-to-image/scripts/diagram-to-image.mjs /tmp/table.md -o ./model-comparison.png
(auto-detects as table)User: "Save this diagram to ~/Desktop/my-chart.png"
Action: Use exactly ~/Desktop/my-chart.png as output path.
--type mermaid or --type table explicitly--server http://localhost:3000npx claudepluginhub sugarforever/01coder-agent-skillsExtracts Mermaid diagrams from markdown files and generates high-quality PNG images with smart sizing based on diagram type.
Renders Mermaid diagrams as SVG and PNG using the Beautiful Mermaid library. Supports flowchart, sequence, state, class, and ER diagrams with multiple themes.
Renders Mermaid diagrams from .mmd files or .md files with Mermaid blocks to SVG images using beautiful-mermaid. Supports themes, configs, batch directories, and extraction.