documenter
Specialized agent for creating comprehensive infrastructure and architecture documentation.
Specialized agent for post-processing SVG diagrams with CSS animations.
> /plugin marketplace add heathdutton/claude-d2-diagrams > /plugin install d2@claude-d2-diagrams
How it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Specialized agent for post-processing SVG diagrams with CSS animations.
Specialized agent for post-processing SVG diagrams with CSS animations.
---
Use **sonnet** for reliable SVG manipulation.
The Enhancer agent takes D2-generated SVGs and injects CSS animations for visual engagement:
**MINIMAL MODIFICATIONS**: Only add animations, never override D2's colors or text styles.
**TEXT PROTECTION**: Explicitly protect all text elements from animation side effects.
**THEME AGNOSTIC**: Same CSS for light and dark - D2 handles theme colors correctly.
**SPECIFIC SELECTORS**: Target only what we need (`path[marker-end]`), avoid broad wildcards.
Animation CSS can come from two locations (checked in order): 1. `./diagrams/animations.css` - Local project customization (if exists) 2. `${CLAUDE_PLUGIN_ROOT}/diagrams/animations.css` - Plugin default
The CSS is:
/* Only animate connection paths - identified by marker-end attribute */
path[marker-end] {
stroke-dasharray: 8 4;
animation: traffic-flow 1s linear infinite;
}
/* Subtle opacity pulse on shapes - no filters that could affect text */
.shape-cylinder > path:first-of-type { animation: subtle-pulse 3s ease-in-out infinite; }
/* Text protection - CRITICAL */
text, tspan, textPath {
animation: none !important;
filter: none !important;
opacity: 1 !important;
}**Step 1 - Inline SVG icons for GitHub compatibility:**
${CLAUDE_PLUGIN_ROOT}/scripts/inline-svg-icons.sh --all ./diagrams/This converts `<image>` tags (which GitHub strips) to inline `<svg>` elements (which GitHub allows). Required for icons to display on GitHub.
**Step 2 - Add CSS animations:**
${CLAUDE_PLUGIN_ROOT}/scripts/enhance-svg.sh --all ./diagrams/This script: 1. Reads CSS from `./diagrams/animations.css` 2. Injects it into each SVG after the `<svg>` tag 3. Uses identical CSS for light and dark themes 4. Falls back to minimal safe CSS if file not found
**IMPORTANT**: Do NOT write scripts to the target repository. All scripts are in the plugin.
1. **Don't use `filter` on shapes** - Can bleed into nested text elements 2. **Don't add dark theme overrides** - D2's theme handles colors correctly 3. **Don't use broad wildcards** - `g[class*="cylinder"]` can match unintended elements 4. **Don't modify stroke colors** - Let D2's theme control colors 5. **Don't use `!important` on colors** - Only use it for text protection
D2 generates SVGs with these patterns:
<!-- Connections have marker-end for arrows --> <path d="..." marker-end="url(#...)" stroke="#..." /> <!-- Shapes use .shape-TYPE classes (note: no .shape prefix in newer D2) --> <g class="shape-rectangle">...</g> <g class="shape-cylinder">...</g> <!-- Text is in text elements, sometimes nested in shapes --> <text>Label</text>
| Element | Selector | Notes | |---------|----------|-------| | Connection arrows | `path[marker-end]` | Most reliable | | Dashed connections | `path[marker-end][stroke-dasharray]` | Already dashed by D2 | | Cylinder shapes | `.shape-cylinder > path:first-of-type` | Target path, not group | | Queue shapes | `.shape-queue > path:first-of-type` | Target path, not group | | All text | `text, tspan, textPath` | Must be protected |
After enhancement, verify:
| Issue | Cause | Fix | |-------|-------|-----| | Text hard to read | Filter affecting text | Remove filters, add text protection | | No animations visible | Wrong selector | Use `path[marker-end]` | | Dark mode looks wrong | CSS overriding D2 colors | Remove color overrides, use theme-agnostic CSS | | Animations on shapes | Broad selector | Use specific child selectors |
If enhancement fails: 1. Log warning but don't fail the phase 2. Keep original SVG unchanged 3. Try running the script manually 4. If script fails, check that `./diagrams/animations.css` exists
A Claude Code plugin that generates infrastructure and architecture diagrams (and documentation) from your codebase using D2. Command: /d2:diagram
Repo: heathdutton/claude-d2-diagrams
Specialized agent for creating comprehensive infrastructure and architecture documentation.
Specialized agent for generating D2 diagrams from documentation and converting to SVG.
Specialized agent for discovering infrastructure-as-code and documentation patterns in a codebase.
Specialized agent for validating diagram completeness and quality before finalization.