From d2
Validates D2 syntax in .d2 files, directories, or .md files with D2 code blocks. Extracts blocks from Markdown, runs d2 validate, and reports per-file/block pass/fail with errors.
npx claudepluginhub diegomarino/claude-toolshed --plugin d2This skill is limited to using the following tools:
User request: "$ARGUMENTS"
Validates Mermaid syntax in Markdown files or directories. Extracts diagrams from code blocks, checks validity with Node.js, and reports pass/fail summaries per file.
Renders .d2 diagram files or extracts D2 code blocks from Markdown to SVG/PNG images in configurable output directory.
Validates and repairs Mermaid diagrams in markdown files by scanning code blocks, validating syntax, and auto-fixing common errors. Useful for documentation with broken diagrams.
Share bugs, ideas, or general feedback.
User request: "$ARGUMENTS"
Validate D2 syntax in .d2 files or .md files containing D2 code blocks.
PLUGIN_DIR=$(find "$HOME/.claude/plugins/cache" -type d -name "d2" -path "*/skills/d2" 2>/dev/null | head -1)
[ -z "$PLUGIN_DIR" ] && PLUGIN_DIR=$(find "$HOME" -maxdepth 8 -type d -name "d2" -path "*/skills/d2" 2>/dev/null | head -1)
bash "$PLUGIN_DIR/scripts/ensure-deps.sh"
From $ARGUMENTS:
.d2 file → validate directly.md file → extract D2 blocks first with extract_d2.sh, then validate each.d2 files and .md files with D2 blocksFor .d2 files:
# Validate directly
d2 validate {file.d2}
For .md files:
# Extract D2 blocks to temp files
bash "$PLUGIN_DIR/scripts/extract_d2.sh" {file.md}
# Then validate each extracted temp file
d2 validate {temp_file}
For directories:
# Find all .d2 files
find {dir} -name "*.d2" -not -path "*/node_modules/*" -not -path "*/.git/*"
# Find .md files containing d2 blocks
grep -rl '```d2' {dir} --include="*.md" 2>/dev/null
For each file:
d2 validate {file} 2>&1
# Exit 0 = valid, non-zero = error
Track: filename, pass/fail, error message (if any).
Validated {N} diagrams:
✅ diagrams/architecture-services-20260310.d2
✅ diagrams/sequence-auth-flow-20260310.d2
❌ docs/design.md (block 2) — unexpected token at line 14: missing closing brace
If any failures:
{N} validation error(s) found.
See $PLUGIN_DIR/references/guides/troubleshooting.md for fixes.
If all pass:
All {N} diagrams valid ✅
D2 Validation Summary
─────────────────────
Path: {input_path}
Files checked: {N}
Passed: {N} Failed: {N}
{per-file results}
{troubleshooting hint if any failures}