d2-diagram
Draw a software architecture, system, data-model or call-flow diagram as D2 text laid out by TALA (D2's whiteboard-style engine, open source since D2 0.9)…
Skill by hasegama
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/hasegama-d2-diagram
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: spreadsheets, data, writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Node.js package
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/d2-diagram
What's inside
- Skill name
d2-diagram- Description
- Draw a software architecture, system, data-model or call-flow diagram as D2 text laid out by TALA (D2's whiteboard-style engine, open source since D2 0.9), look at it in the terminal before anyone opens an image, and check that the picture says what it claims — `d2 --layout=tala x.d2 x.txt` renders the layout as Unicode box drawing, `--ascii-mode standard` as plain ASCII for a README, and `assets/d2-facts.mjs` reads the drawn boxes and arrows back out of the render and holds them to a fact sheet. Loop: write `.d2` → `d2 fmt --check` / `validate` → facts → terminal render → PNG → fix the text. Use when asked for a D2 diagram, an architecture diagram kept as editable text in the repo, a TALA layout, a diagram that shows in a terminal or a code block, or when the repo already has `.d2` files. Not for animations or figures with a moving walk (`explanatory-animation`, `explain-with-anim`).
- License
- MIT
- Instructions
- 432 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
- Instructions call the network
Files (6)
- SKILL.md
- d2-facts.mjs · assets/
- vlmkit-workspace.d2 · assets/
- vlmkit-workspace.facts.json · assets/
- vlmkit-workspace.svg · assets/
- vlmkit-workspace.txt · assets/
SKILL.md (first lines)
# d2-diagram
Paths below: `<skill>` is this skill's directory and `<skills>` the directory the skills are
installed in (`skills/` in mizchi/explainer, `.claude/skills/` in a project that installed them).
A D2 file is the diagram; the picture is a render of it. The writer's job is the
text — ids, labels, containers, connections — and TALA's job is where the boxes
go and how the lines bend. The terminal render exists so the writer reads the
picture on every round without leaving the shell, and so the diagram can live in
a README code block, a PR comment, or a `--help` text.
```d2
direction: right
web: Web frontend
api: API server
db: PostgreSQL {shape: cylinder}
web -> api: HTTPS
api -> db: SQL
```
```
.-‾‾‾‾‾‾-.
│╲-______-╱│
HTTPS SQL │ │
┌─────────────┐──────────────▶┌───────────┐─────────────▶│ │
│Web frontend │ │API server │ │PostgreSQL│
│ │ │ │ │ │
└─────────────┘ └───────────┘ ╲-______-╱
```
(`d2 --layout=tala x.d2 x.txt`, verbatim, D2 0.8.1-HEAD.)
This skill is for a diagram whose deliverable is **D2 text**: someone will edit
it later, TALA lays it out, and it renders wherever D2 does. When the picture has
to *move* (an algorithm step by step, a walked request) use
`explanatory-animation` / `explain-with-anim` instead. The two combine: draw the
modules and dependencies that `vlmkit-anim facts <dir> --depth 1 --out
f.expect.json` lists, so the D2 is grounded in the code, and keep both files.
## Invocation
```bash
d2 layout # must list `tala (bundled)`. That, not the version
# string, is the gate: v0.8.1-HEAD already bundles it.
d2 --layout=tala arch.d2 arch.txt && cat arch.txt # the terminal render (Unicode box drawing)
d2 --layout=tala --ascii-mode standard arch.d2 arch.txt # plain ASCII (+ - | / < > v) for a README
d2 --layout=tala arch.d2 --stdout-format ascii - # to stdout, for a pipe or a PR comment
d2 --layout=tala arch.d2 arch.svg # the figure for docs
d2 --layout=tala arch.d2 arch.png # a raster to LOOK at (see the loop, step 5)
d2 validate arch.d2 # syntax only; exit 1 with file:line:col
d2 fmt --check arch.d2 # formatted? exit 1 and names the file, changes nothing
d2 fmt arch.d2 # ...and this rewrites it in place
node <skill>/assets/d2-facts.mjs arch.d2 # what the picture DRAWS
node <skill>/assets/d2-facts.mjs arch.d2 --expect f.json # ...held to a sheet
LC_ALL=C.UTF-8 wc -L arch.txt # the width in columns — the locale matters, see below
```
Install when `d2` is missing — never drive the diagram through an online
playground:
```bash
curl -fsSL https://d2lang.com/install.sh | sh -s -- # the installer; it rejects the obsolete --tala flag
brew install d2 # macOS
go install github.com/d2lang/d2@latest # Go 1.27+; what to do when the install script gets a 403 through a proxy
```
`D2_LAYOUT=tala` in the environment is the same as the flag. `vars: { d2-config:
{ layout-engine: tala } }` inside the file is honoured for `.svg` / `.png` **and
not for `.txt`** on the build measured (0.8.1-HEAD: the text render fell back to
dagre and came out 163 columns instead of 120), so pass the flag anyway; keep the
config in the file so the next person's SVG gets the same engine. A
`sequence_diagram` is the exception that proves the rule — it lays itself out, so
its text render came out byte-identical with and without the flag.
## Nothing in D2 tells you the picture is wrong
`validate` reads syntax. The renderers draw whatever the file says. There is no
`--expect`, no layout report, and **no error for a reference to an id that is not
in scope — it creates a new shape.** So this is a silently wrong diagram:
```d2
edge: { cdn; gateway }
cluster: { orders; inventory }
gateway -> orders # ← two NEW empty boxes at the root; the real ones keep no arrow
```
A writer in this skill's own validation round shipped exactly that: `d2 validate`
0, `d2 fmt` clean, 94 columns, and its log said "can trace all connections". The
render had **four duplicated boxes**, two orphans, and the system's entry call
drawn as a floating pair outside every region
([report](https://github.com/mizchi/vlmkit/blob/main/docs/reports/2026-09-14-d2-diagram-v1.md)).
**Write cross-container connections at the root, with full paths.** That is the
one form that always works and the one every writer in the round that got this
right used:
```d2
edge.gateway -> cluster.orders # at the root: full path on both ends
cluster: {
billing -> _.outside.stripe # from INSIDE: `_` is this container's parent
}
```
`_` is **one level and only valid inside a container**. From inside `cluster`,
`_` is the root, so a shape in a sibling container is `_.outside.stripe` — not
`_.stripe`, which invents a root-level `stripe` (that was the round's fourth
phantom). At the root `_` has no parent to mean: `d2` fails the compile with
`invalid underscore`, which a later writer hit and read as the escape being
broken.
`assets/d2-facts.mjs` is the check D2 does not have. It renders the file and
reads the picture back out of the SVG — d2 writes every shape's and every
connection's fully-qualified id into it — so what it reports is what a reader
sees, not what the source seems to say. No dependencies; copy it next to your
diagrams in another repo.From hasegama/pstack-agents, MIT.
More from hasegama/pstack-agents
- 0.570score
explainer
hasegama
特定の読み手に向けて、概念・PR・設計を「冗長にならない水準」の速習資料として説明し、図と主張を道具で検証する。読み手のペルソナ(既に知っていること・知らないこと・読み方)を質問と公開情報から作り、その差分だけを書く。図は vlmkit-anim…
SkillAFreshness: AClaude Code +9 - 0.566score
explainer-book
hasegama
1 本の速習資料では収まらない、章立ての学習資料(topic-book/01-quickstart.md, 02-….md …)を、読み手のペルソナに合わせて設計・執筆・検証する。章ごとの学習目標と理解度チェックの対応、概念を導入より前に使わない順序、章の読了時間の予算、「未完成なら落ち、答えなら通る」演習、book…
SkillAFreshness: AClaude Code +9 - 0.565score
explanatory-animation
hasegama
Explain an algorithm, protocol, data structure, state machine, or architecture as a checked animation or still figure with `vlmkit-anim` — one JSON scene (a…
SkillAFreshness: AClaude Code +9 - 0.565score
explain-with-anim
hasegama
Answer "how does this work / how is this structured / what does this change" with a drawn figure and a narration that follows it — a module map from the…
SkillAFreshness: AClaude Code +9 - 0.560score
d2-slides
hasegama
Build a slide deck whose source is text and whose figures are laid out by TALA — one Markdown file with a ```d2 fence per figure, compiled to a self-contained…
SkillAFreshness: AClaude Code +9 - 0.544score
diagnosing-bugs
hasegama
Diagnosis loop for hard bugs and performance regressions.
SkillAFreshness: AClaude Code +9 - 0.539score
domain-modeling
hasegama
Build and sharpen a project's domain model.
SkillAFreshness: AClaude Code +9 - 0.533score
ask-matt
hasegama
Ask which skill or flow fits your situation.
SkillAFreshness: AClaude Code +9 - 0.528score
blast-radius
hasegama
変更が差分の外に及ぼす影響を調べ、成立条件を実コードの実行で確認する。影響範囲や小さな差分の安全性をレビューするときに使う。
SkillAFreshness: AClaude Code +9 - 0.528score
architect
hasegama
型・関数シグネチャ・モジュール構成を設計し、独立した複数案を比較してから実装する。/architect や、構造の判断を伴う実装に使う。
SkillAFreshness: AClaude Code +9 - 0.528score
create-verification-skill
hasegama
アプリを利用者と同じ経路で検証するプロジェクト用スキルと機能マップを作る。/create-verification-skill や、検証手順をスキルにしたい依頼に使う。
SkillAFreshness: AClaude Code +9 - 0.525score
arena
hasegama
同じ課題に独立した複数候補を作り、評価して基準案に優れた部分を統合する。/arena や、設計・実装案の比較に使う。
SkillAFreshness: AClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 5, 2026 (24 days ago)
- Last release
- Oct 5, 2026 (24 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/hasegama/pstack-agents
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from hasegama
- 0.570score
explainer
hasegama
特定の読み手に向けて、概念・PR・設計を「冗長にならない水準」の速習資料として説明し、図と主張を道具で検証する。読み手のペルソナ(既に知っていること・知らないこと・読み方)を質問と公開情報から作り、その差分だけを書く。図は vlmkit-anim…
SkillAFreshness: AClaude Code +9 - 0.566score
explainer-book
hasegama
1 本の速習資料では収まらない、章立ての学習資料(topic-book/01-quickstart.md, 02-….md …)を、読み手のペルソナに合わせて設計・執筆・検証する。章ごとの学習目標と理解度チェックの対応、概念を導入より前に使わない順序、章の読了時間の予算、「未完成なら落ち、答えなら通る」演習、book…
SkillAFreshness: AClaude Code +9 - 0.565score
explanatory-animation
hasegama
Explain an algorithm, protocol, data structure, state machine, or architecture as a checked animation or still figure with `vlmkit-anim` — one JSON scene (a…
SkillAFreshness: AClaude Code +9 - 0.565score
explain-with-anim
hasegama
Answer "how does this work / how is this structured / what does this change" with a drawn figure and a narration that follows it — a module map from the…
SkillAFreshness: AClaude Code +9 - 0.560score
d2-slides
hasegama
Build a slide deck whose source is text and whose figures are laid out by TALA — one Markdown file with a ```d2 fence per figure, compiled to a self-contained…
SkillAFreshness: AClaude Code +9 - 0.544score
diagnosing-bugs
hasegama
Diagnosis loop for hard bugs and performance regressions.
SkillAFreshness: AClaude Code +9
Cite this page
d2-diagram skill. Agent Mart. https://agentmart.dev/skills/hasegama-d2-diagram (last updated 2026-10-24)