Hooks
What d2 runs automatically, and when. A hook is a command Claude Code fires at a fixed moment, without you asking for it.
> /plugin marketplace add heathdutton/claude-d2-diagrams > /plugin install d2@claude-d2-diagrams
Ships with d2. Installing the plugin gets these hooks.
What fires, and when
SessionStart
Fires once when a session begins, and again after a context compaction. It is where a plugin sets up its environment, or restores state the compaction dropped.
${CLAUDE_PLUGIN_ROOT}/scripts/check-d2.sh
UserPromptSubmit
Fires before Claude sees each prompt you send. A plugin can use it to inject context, so the same instruction reaches the model every turn instead of only at session start.
${CLAUDE_PLUGIN_ROOT}/scripts/keyword-trigger.sh
PostToolUse
- Matches
Write|Edit${CLAUDE_PLUGIN_ROOT}/scripts/d2-validator.sh
Stop
${CLAUDE_PLUGIN_ROOT}/scripts/todo-continuation.sh
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

