/d2:d2-validatefrom d2
Validates D2 syntax in .d2 files, .md files with D2 code blocks, or directories. Reports per-file pass/fail with error messages.
Ships in d2. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
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}
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub diegomarino/claude-toolshed --plugin d27 skills in this plugin
/d2Internal routing hub for d2 diagram skills/d2-architectScan a codebase and auto-generate relevant diagrams from its structure/d2-configChange theme, layout engine, sketch mode, or check plugin dependencies/d2-convertConvert a Mermaid diagram to D2 format/d2-diagramGenerate a D2 diagram from a text description/d2-renderRender .d2 files to SVG or PNG imagesOther plugins' skills for the same job