svg-primitives
БесплатноЗапускает вложенные скриптыНе проверенUse when the user asks to build a programmatic SVG schematic in Python: flowcharts, boxes and arrows, auto-fit SVG text, mm-precise diagrams, edge-snapped…
Об этом скилле
SVG Primitives
Build mm-precise SVG schematics in Python with three mechanical guarantees:
- Text never overflows its container — labeled shapes auto-size to fit measured text bbox + padding.
- Arrowheads stay tangent-correct — arrows emit
<marker orient="auto">so the renderer rotates the head along the path's terminal tangent; works on straight lines and cubic Beziers. - Paint order is deterministic — layers paint in registration order; connectors visibly pass under boxes without manual reordering.
The skill ships an end-to-end pytest suite (50+ tests) that renders SVGs and asserts these invariants on the rendered output, so the guarantees are enforced by construction rather than by hand-checking each figure.
When to use this skill
Reach for svg-primitives when:
- The figure is a schematic (boxes, arrows, labels) and you're driving it from Python — e.g. nodes come from a YAML config, or the layout depends on data.
- You need the boxes to auto-fit their labels (no hand-tuning widths).
- The figure has curved arrows that must point cleanly at their targets.
- You want deterministic z-order so connectors sit under shapes without manual element reordering.
- The output will be composed into a multi-panel figure as a panel SVG that
scientific-figure/compose.pyloads.
Reach for a different tool when:
- The figure is plotted from numbers (matplotlib/seaborn/plotnine) → use
figures:plot-styling. - The figure is a photographic / pictorial substrate (a brain scene, microscope setup) → use
figures:ai-full-figurefor the substrate and overlay labels via Arrow/LabeledBox here. - The figure is hand-authored SVG or the patterns are reference material for hand-authoring → use
figures:svg-figure(this skill's library-agnostic counterpart).
Quick start
from svg_primitives import Canvas, LabeledBox, Arrow
c = Canvas(width_mm=183, height_mm=80)
boxes = c.layer("boxes")
arrows = c.layer("connectors")
raw = boxes.add(LabeledBox(x=10, y=20, text="Raw EEG", font_size=7))
band = boxes.add(LabeledBox.next_to(raw, side="E", gap=10, text="Bandpass\nfilter", font_size=7))
ica = boxes.add(LabeledBox.next_to(band, side="E", gap=10, text="Independent component\nanalysis", font_size=7))
arrows.add(Arrow.connect(raw, band)) # straight, snapped to edges
arrows.add(Arrow.connect(band, ica)) # straight
arrows.add(Arrow.connect(ica, raw, curve="cubic", bow=14, # feedback arc
stroke="#C45146")) # red — gets its own red marker
c.save("eeg.svg", output_png=True)
examples/eeg_pipeline.py is the canonical reference; run it to see the full output:
uv run --with drawsvg --with svgpathtools --with Pillow --with fonttools --with cairosvg \
python plugins/figures/skills/svg-primitives/examples/eeg_pipeline.py
Primitive reference
Canvas(width_mm, height_mm, background=None)
The root drawing surface. User units equal mm; the viewBox is set so coordinates inside the SVG are in mm and font-size is emitted in mm regardless of the input pt size.
.layer(name) -> Layer— gets or creates a named layer. Subsequent.layer("boxes")calls return the same layer..add_layer(Layer) -> Canvas— explicit insertion when registration order matters..save(path, output_png=False, png_width=1800)— writes the SVG; withoutput_png=True, also writes a sibling PNG via cairosvg.
Layer paint order is the order layers were first registered. Typical convention: background → connectors → boxes → labels.
Layer(name)
An ordered bucket of elements. .add(element) appends and returns the element so calls chain.
LabeledBox(x, y, text, font_size=7, padding=2, ...)
Auto-sized rounded rectangle with centered text. The width and height are computed from the measured text bbox (via fontTools) plus padding on every side, clamped by min_width / min_height. Multi-line text (newline-separated) stacks with line_spacing em between baselines.
anchor="top-left"(default) —x, yis the top-left corner.anchor="center"—x, yis the centroid..anchor_point("N"|"S"|"E"|"W") -> complex— exposed forArrow.connect..outline_path() -> svgpathtools.Path— used internally for arrow edge snapping..next_to(other, side, gap, **kwargs)(classmethod) — build a sibling positioned relative to an existing box.
font_size is in pt for ergonomics (font_size=7 matches "7 pt Helvetica" in typographic terms). The emitted SVG font-size attribute is in mm (pt × 25.4 / 72).
Pill(...) and Diamond(...)
Variants of LabeledBox:
Pill— corner radius equalsheight/2after auto-sizing → flat-sided capsule. Good for terminal nodes.Diamond— rhombus. Width and height are doubled after the text + padding measurement so the inscribed text rectangle fits. Outline is a 4-edge polygon.
`Arrow.connect
Установить svg-primitives в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл svg-primitives?
Use when the user asks to build a programmatic SVG schematic in Python: flowcharts, boxes and arrows, auto-fit SVG text, mm-precise diagrams, edge-snapped arrows, tangent-correct curve arrowheads, orthogonal or Manhattan routing, deterministic z-order layers, labeled groups, bracket groupings, leader-line annotations, or strict Canvas.save validation for text overflow. Use figure-qa instead for after-the-fact validation of arbitrary hand-authored or exported SVGs. Built on drawsvg, svgpathtools, and fontTools; output SVGs can be composed by scientific-figure.
Как установить скилл svg-primitives?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл svg-primitives запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic