ModsCode / Claude Code Mods / Ranking / diagrams
diagrams
Pins the diagrams Claude draws to a chip above the prompt: expand it in place, open it full screen or in the browser, and see it as a rendered picture
What it does
- Draws a band above the prompt, a pane, toasts
- Adds /diagrams
- Watches mcp__diagrams__show_diagram calls and can refuse them
- Hooks prompt.compose, session.start, turn.complete, turn.start and 1 more
- Starts processes
Good points
- No network calls
- Written in TypeScript
- Handles errors
Code to start from
A starter ModsCode writes from the drawing it read, and the mod's own lines that draw, where there are any.
Starter (register.tsx)
import type { Register } from 'claude-code'
// Drawn like diagrams by Tomas Varga (pane, band, toast), as ModsCode read it from the mod's code:
// https://modscode.com/claude-mods/mods/tomasvarga-diagrams/
// Written by ModsCode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
// the band above the prompt; what else goes there is drawn under it
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const { Box, Text, Button } = $.ui.resolve(e)
const title = '…'
const hidden = '…'
const label = '…'
return (
<Box flexDirection="column">
<Box justifyContent="flex-end">
<Box flexDirection="column" borderStyle="round">
<Box gap={1} paddingX={1}>
<Text>
◉
</Text>
<Text bold wrap="truncate-end">
{title}
</Text>
</Box>
<Box flexDirection="column" paddingX={1} paddingY="0">
<Text wrap="truncate-end">
{" "}
</Text>
<Text wrap="truncate-end">
{" "}
</Text>
<Text wrap="truncate-end">
{" "}
</Text>
</Box>
<Text>
{` … ${hidden} more lines in full screen`}
</Text>
<Box justifyContent="space-between" paddingX={1}>
<Box flexShrink={0}>
<Text>
{" "}
</Text>
</Box>
<Box gap={1} flexShrink={0}>
<Text>
·
</Text>
<Button label={`${label}`} plain />
<Text>
·
</Text>
<Button label={`${label}`} plain />
<Text>
·
</Text>
<Button label={`${label}`} plain />
</Box>
</Box>
</Box>
</Box>
{await next(e)}
</Box>
)
})
// the pane: open it with $.ui.open({ id: 'my-pane', title: "Diagram" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Button } = $.ui.resolve(e)
const title = '…'
const left = '…'
const widest = '…'
const label = '…'
return (
<Box flexDirection="column">
<Box gap={1} paddingX={1}>
<Text>
◉
</Text>
<Text bold wrap="truncate-end">
{title}
</Text>
</Box>
<Box flexDirection="column" flexGrow={1}>
<Box flexDirection="column" paddingX={1} paddingY="1">
<Text wrap="truncate-end">
{" "}
</Text>
<Text wrap="truncate-end">
{" "}
</Text>
<Text wrap="truncate-end">
{" "}
</Text>
</Box>
</Box>
<Box justifyContent="space-between" paddingX={1}>
<Box gap={1} flexShrink={0}>
<Button label="◀" plain />
<Text>
{"columns "}
{`${left}1`}
–
{left}
{" of "}
{widest}
</Text>
<Button label="▶" plain />
</Box>
<Box gap={1} flexShrink={0}>
<Text>
·
</Text>
<Button label={`${label}`} plain />
<Text>
·
</Text>
<Button label={`${label}`} plain />
<Text>
·
</Text>
<Button label={`${label}`} plain />
</Box>
</Box>
</Box>
)
})
on('session.start', async ($, e, next) => {
const title = '…'
await $.ui.toast(`Could not render "${title}" as a picture; showing the text`)
await $.ui.toast(`Diagram opened in your browser`)
return next(e)
})
}
The mod's own code
Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.
hooks/register.tsx lines 206–339 · Band
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const all = await read($, list)
const at = clamp(await read($, index), all.length)
const diagram = all[at]
if (!diagram || e.props.hasSurvey) {
return next(e)
}
const elements = $.ui.resolve(e)
const { Box, Button, Text } = elements
// Pictures draw only where the surface has Image (the terminal); elsewhere the text.
const Image = 'Image' in elements ? elements.Image : undefined
const step = (by: number) => () => update($, index, i => clamp(i + by, all.length))
const showsPicture = isPictures && !!Image && !!diagram.picture && !(await read($, isText))
const toggle: Action[] = isPictures && diagram.picture
? [{ key: 'view', label: showsPicture ? '⌗ text' : '▦ picture', onPress: () => update($, isText, text => !text) }]
: []
const expand = () => update($, isOpen, () => true)
const collapse = () => update($, isOpen, () => false)
const fullScreen = async () => {
await collapse()
await openPane($)
}
const navigation = all.length > 1 && (
<Box gap={1} flexShrink={0}>
{/* Words beside the arrows: a one-cell arrow is too small to hit. */}
<Button key="prev" label="‹ prev" plain onPress={step(-1)} />
<Text {...S.muted}>
{at + 1}/{all.length}
</Text>
<Button key="next" label="next ›" plain onPress={step(1)} />
</Box>
)
// While Claude works the chip is a bare symbol, out of the way, that still expands.
if (e.props.isWorking && !(await read($, isOpen))) {
return (
<Box justifyContent="flex-end">
<Box borderStyle="round" {...S.rule} paddingX={1} gap={1}>
<Button key="open-symbol" label={PULSE[(await read($, pulse)) % PULSE.length]!} plain onPress={expand} />
{all.length > 1 && <Text {...S.muted}>{all.length}</Text>}
<Button key="open" label="⤢" plain onPress={expand} />
</Box>
</Box>
)
}
if (await read($, isOpen)) {
return <Box justifyContent="flex-end">{expandedCard()}</Box>
}
// Full screen is open: the chip says so and closes it.
if (await read($, isFull)) {
return (
<Box justifyContent="flex-end">
<Box borderStyle="round" {...S.highlight} paddingX={1} gap={1}>
<Text {...S.accent}>⛶</Text>
<Text bold {...S.text} wrap="truncate-end">
{diagram.title}
</Text>
<Text {...S.muted}>in full screen</Text>
<Button key="close-full" label="close" onPress={() => closePane($)} />
</Box>
</Box>
)
}
const shown = await read($, reveal)
const title = shown < 0 ? diagram.title : diagram.title.slice(0, shown)
return (
<Box justifyContent="flex-end">
<Box borderStyle="round" {...S.rule} paddingX={1} gap={1}>
<Text {...S.accent}>◆</Text>
{/* The whole title expands too, not only the small button at the end. */}
<Button key="open-title" label={title || ' '} plain onPress={expand} />
{shown < 0 && navigation}
<Button key="open" label="expand" variant="primary" onPress={expand} />
</Box>
</Box>
)
// The chip grown into a card in place. Painting it over the chat (an absolute
// Box above the band) left the chat garbled in a fullscreen terminal, so it takes
// its rows; a diagram taller than the band's room is cut, with full screen offered.
function expandedCard() {
const lines = diagram!.source.split('\n')
// One width for every diagram in the history, so switching doesn't move the controls.
const widest = Math.max(...all.flatMap(one => one.source.split('\n').map(line => [...line].length)), 56)
// Wide enough for every diagram's text and, with pictures on, its picture at actual size.
const pictured = isPictures ? Math.max(0, ...all.map(one => (one.picture ? Math.ceil(one.picture.width / PIXELS_PER_COLUMN) : 0))) : 0
const width = Math.min(e.props.bodyColumns, Math.max(widest, pictured) + 4)
// The band's rows less the card's own: two border rows, the title bar, the footer
// and the "more lines" note; more than that and the band scrolls, cutting off the top.
const room = Math.max(4, e.props.maxRows - 5)
const hidden = Math.max(0, lines.length - room)
return (
<Box flexDirection="column" width={width} borderStyle="round" {...S.highlight} backgroundColor={S.background}>
<Box gap={1} paddingX={1} backgroundColor={S.surface}>
<Text {...S.accent} backgroundColor={S.surface}>
◉
</Text>
<Text bold {...S.text} backgroundColor={S.surface} wrap="truncate-end">
{diagram!.title}
</Text>
</Box>
{showsPicture ? (
pictureBox(S, Box, Image!, diagram!, width - 4, room)
) : (
diagramLines(S, Box, Text, hidden > 0 ? lines.slice(0, room) : lines, 0)
)}
{!showsPicture && hidden > 0 && (
<Text {...S.muted} backgroundColor={S.background}>
{` … ${hidden} more lines in full screen`}
</Text>
)}
{/* Every control on the bottom row, which sits on the prompt and so stays put. */}
<Box justifyContent="space-between" paddingX={1} backgroundColor={S.background}>
<Box flexShrink={0}>{navigation || <Text backgroundColor={S.background}> </Text>}</Box>
{actions(S, Box, Button, Text, [
...toggle,
{ key: 'full', label: '⛶ full', onPress: fullScreen },
{ key: 'browser', label: '↗ browser', onPress: () => openInBrowser($, diagram!) },
{ key: 'copy', label: '⧉ copy', onPress: press => copy($, diagram!, press.surface, showsPicture) },
{ key: 'close', label: '✕ close', onPress: collapse },
])}
</Box>
</Box>
)
}
})hooks/register.tsx lines 456–471 · Band
function pictureBox(S: Palette, Box: Elements['Box'], Image: TerminalImage, diagram: Diagram, columns: number, rows: number, grows = false) {
const picture = diagram.picture!
const rowsPerColumn = (picture.height / picture.width) * CELL_ASPECT
const wide = Math.min(255, grows ? columns : picture.width / PIXELS_PER_COLUMN, columns, rows / rowsPerColumn)
return (
<Box paddingX={1} justifyContent="center" backgroundColor={S.background}>
<Image
source={{ file: picture.path, format: 'png' }}
columns={Math.max(1, Math.round(wide))}
rows={Math.max(1, Math.min(255, Math.round(wide * rowsPerColumn)))}
alt={diagram.title}
/>
</Box>
)
}hooks/register.tsx lines 410–420 · Band
function diagramLines(S: Palette, Box: Elements['Box'], Text: Elements['Text'], lines: readonly string[], paddingY: number) {
return (
<Box flexDirection="column" paddingX={1} paddingY={paddingY} backgroundColor={S.background}>
{lines.map((line, row) => (
<Text key={`line-${row}`} {...S.text} backgroundColor={S.background} wrap="truncate-end">
{line || ' '}
</Text>
))}
</Box>
)
}hooks/register.tsx lines 595–604 · Band
function actions(S: Palette, Box: Elements['Box'], Button: Elements['Button'], Text: Elements['Text'], list: readonly Action[]) {
return (
<Box gap={1} flexShrink={0}>
{list.flatMap((action, at) => [
...(at > 0 ? [<Text key={`dot-${action.key}`} {...S.muted} backgroundColor={S.background}>·</Text>] : []),
<Button key={action.key} label={action.label} plain onPress={action.onPress} />,
])}
</Box>
)
}hooks/register.tsx lines 342–403 · Pane
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
const S = fullS
const diagram = await current($)
const elements = $.ui.resolve(e)
const { Box, Button, Text } = elements
const Image = 'Image' in elements ? elements.Image : undefined
if (!diagram) {
return <Text {...S.muted}>No diagrams yet.</Text>
}
const lines = diagram.source.split('\n')
// The pane's width less its padding; a wider diagram pans sideways instead of being cut.
const visible = Math.max(10, e.props.bodyColumns - 2)
const widest = Math.max(...lines.map(line => [...line].length))
const maxPan = Math.max(0, widest - visible)
const left = Math.min(await read($, pan), maxPan)
const panBy = (by: number) => () => update($, pan, at => Math.max(0, Math.min(at + by, maxPan)))
const step = Math.max(10, Math.floor(visible / 2))
const showsPicture = isPictures && !!Image && !!diagram.picture && !(await read($, isText))
// At least the pane's height, so the palette fills it and the footer sits at its
// bottom; a taller diagram makes it longer and the person scrolls with the arrows.
return (
<Box flexDirection="column" width={e.props.bodyColumns} minHeight={e.props.scroll.bodyRows} backgroundColor={S.background}>
<Box gap={1} paddingX={1} backgroundColor={S.surface}>
<Text {...S.accent} backgroundColor={S.surface}>
◉
</Text>
<Text bold {...S.text} backgroundColor={S.surface} wrap="truncate-end">
{diagram.title}
</Text>
</Box>
<Box flexDirection="column" flexGrow={1} backgroundColor={S.background}>
{showsPicture
? pictureBox(S, Box, Image!, diagram, visible, Math.max(4, e.props.scroll.bodyRows - 4), true)
: diagramLines(S, Box, Text, lines.map(line => [...line].slice(left, left + visible).join('')), 1)}
</Box>
<Box justifyContent="space-between" paddingX={1} backgroundColor={S.background}>
{!showsPicture && maxPan > 0 ? (
<Box gap={1} flexShrink={0}>
<Button key="left" label="◀" plain onPress={panBy(-step)} />
<Text {...S.muted} backgroundColor={S.background}>
columns {left + 1}–{Math.min(left + visible, widest)} of {widest}
</Text>
<Button key="right" label="▶" plain onPress={panBy(step)} />
</Box>
) : (
<Text backgroundColor={S.background}> </Text>
)}
{actions(S, Box, Button, Text, [
...(isPictures && diagram.picture
? [{ key: 'view', label: showsPicture ? '⌗ text' : '▦ picture', onPress: () => update($, isText, text => !text) }]
: []),
{ key: 'browser', label: '↗ browser', onPress: () => openInBrowser($, diagram) },
{ key: 'copy', label: '⧉ copy', onPress: press => copy($, diagram, press.surface, showsPicture) },
{ key: 'close', label: '✕ close', onPress: () => closePane($) },
])}
</Box>
</Box>
)
})Licence text (MIT)
MIT License Copyright (c) 2026 Tomas Varga Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
How to build this: Pane (panel), Deny a tool call
What its code calls
runs programswrites filesenv varstool calls
What its code shows
Read from the source at commit 0a27085d3783 on 2026-10-11. The first group decides whether a mod is listed; the rest is for you to weigh. A later commit is not read until the next crawl.
| Decides the listing: code you can check | |
|---|---|
| Entry read | Every module hooks/hooks.json names was read.hooks/register.tsx |
| Parses | Every file parses as TypeScript or JavaScript.1 files parsed |
| All its code is in the mod | Every import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod |
| Readable | No minified lines, no eval or new Function, no import of a computed path, no encoded blobs.no minified code, no eval, no encoded blobs |
| Calls in the open | Network and programs are reached as $.http.fetch and $.process.run in place, never passed around.every call outside goes through $ in the open |
| For you to weigh before installing | |
| Where it draws | The terminal, the desktop app, both, or nothing (hooks only: a guard or a prompt rewriter), as its code says. Shown, never a reason to leave a mod out.draws in the terminal and the desktop app, the same in both |
| Install line | Whether its repository's own .claude-plugin/marketplace.json lists it, so it installs from that marketplace with the lines on its page.listed in its repository's .claude-plugin/marketplace.json: installs from there |
| Programs on Windows | Whether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks |
| Network | Whether every fetch names its https host in the code.no network |
| Programs | Whether every program it starts is named in the code and is not a shell, an interpreter or a network tool.hooks/register.tsx:481 a program named at run time; hooks/register.tsx:544 a program named at run time; hooks/register.tsx:576 a program named at run time; hooks/register.tsx:620 a program named at run time; hooks/register.tsx:869 a program named at run time |
| Reads and sends | Whether it both reads something of yours (files, environment variables, the transcript, settings) and reaches outside (the network, an MCP server, another session, telemetry).reads environment variables, files, but reaches nothing outside |
| Keys in the source | Whether the source holds what looks like an API key or a private key.no keys in the source |
| Licence | An open licence (MIT, Apache-2.0, BSD, ISC, Unlicense, 0BSD, CC0) with its text lets ModsCode show its code; otherwise the code is linked.MIT |
| Settings hooks | Hooks declared in hooks/hooks.json or plugin.json beside the module: a command (a shell when it has no args), an HTTP request, an MCP tool or a model prompt at an event. They run outside $.no settings hooks: its function hooks alone |
| Servers it ships | MCP servers (a program, or a URL; a headersHelper is a shell command; a .mcpb bundle is unpacked at run time), LSP servers, monitors (a shell command for the whole session) and bin/ (on the PATH of the Bash tool).ships no MCP or LSP server, no monitor, no bin/ |
| Skills, commands, agents | What its Markdown declares beyond text: allowed-tools granted for the turn, hooks added when a skill is invoked, a command run before Claude reads the skill.no skills, commands, agents or workflows |
| Tools and MCP | Whether every tool it calls through $.tool.call and $.mcp.call is named in the code, and none is a shell (Bash through the tool runs a shell without $.process).calls no tool, MCP server or command |
| Asks of the model | Completions it runs ($.model.complete, fork, classify), subagents it spawns, prompts it submits as you, and the tools, commands and agents it adds.adds command diagrams |
| Events it hooks | By what a hook there can do: gates (refuse a tool call, a prompt, a setting, another plugin), shapes (what the model reads: the system prompt, tool descriptions, each request), reads (your input, the events of the settings hooks, every event with *), and the rest.gates: tool.call (mcp__diagrams__show_dia…), command.run (diagrams) · shapes: prompt.compose · also: session.start, turn.start, turn.complete, ui.close (+1) · timers: clock.every, clock.after |
| Reads, by name | The environment variables and files it names, and whether it reads the transcript, settings.json, the prompt box or the mouse selection.env: TMPDIR, HERDR_PANE_ID, HERDR_BIN_PATH, TMUX_PANE; files: ….png, a path computed at run time |
| Writes, by name | The files and environment variables it names, and whether it changes settings, the prompt box, the clipboard, the conversation (a row the model reads) or another session.files: ….mmd, …/claude-diagram-….html; the clipboard |
This is a reading of the code text, not a security review: it does not run the mod, and it cannot see what a program the mod starts does. The check before installing is yours. How mods are chosen
Install it
Check it yourself before you install it. Mods run unsandboxed, with your permissions, and ModsCode does not vouch for what this code does. Read its code (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.
From its marketplace
Its repository is its marketplace. Add that marketplace (in the terminal with these commands, or in the desktop app's plugin settings) and install the mod from it:
/plugin marketplace add tomasvarga/claude-code-diagrams/plugin install diagrams@claude-code-diagrams/reload-pluginsThis installs the marketplace's latest commit, which may not be the one read here (0a27085d3783). Compare them before you install. /reload-plugins loads it into a session that is already open.
Try the commit ModsCode read
No marketplace needed. In a terminal, clone the repository, check out the commit read, validate the mod, and load it for one session:
git clone https://github.com/tomasvarga/claude-code-diagramsgit -C claude-code-diagrams checkout 0a27085d378367c9525ee9f32ff20dd6cc2ecad4claude plugin validate claude-code-diagramsclaude --plugin-dir claude-code-diagramsThe validate line lists the events the mod hooks and what it asks Claude Code to do, without running it. The last line loads the mod for this session only and writes nothing to your settings. If the author has rewritten history, the commit may no longer exist.
Ask Claude about it
With the ModsCode connector added, Claude can read this mod's code and what it reaches, and build on them. Ask it like this:
Read the ModsCode mod "tomasvarga-diagrams" with its code and make me one like itSearch them from Claude: the MCP connector
Similar mods
- code-modernizationAnthropic★ 37,653
- crit-tuiTomasz Tomczyk★ 1,196
- ai-maestro-secrets23blocks-OS★ 817
- remctlFederico Viticci★ 595
- task-orchestrator-modJeff Picklyk★ 208
- agent-radarHamza Zafar★ 184
Badge for your README
If this is your mod, paste this into your README. It links to this page.
[](https://modscode.com/claude-mods/mods/tomasvarga-diagrams/)