/splitbrain:pixel-to-svgfrom splitbrain
Redraws raster graphics (game backgrounds and sprites, icons, logos, comics, diagrams, maps, UI mockups, low resolution illustrations) as clean SVG files that scale without loss. The SVG is built from shapes and shared objects, not from traced pixels. Use when asked to convert, vectorize, trace or redraw a raster image as SVG, or to review and fix such an SVG.
Ships in splitbrain. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
The result must look like the artwork at any size, with few nodes. Tracing the pixels gives wobbly outlines, gaps and thousands of nodes, and users reject it. Read the image like the artist drew it instead: find the layers and the objects, understand what each object is, and draw it again from primitives. Objects that occur more than once get one canonical form that every copy uses.
The user expects an acceptable result in one pass, without having to point out faults. Review your own work as strictly as the user would, and fix every fault you find before you report.
Node guide: a rectangle is one element; a circle or an ellipse is one element; a smooth curve
needs about one cubic segment per 90 degrees of turning; an organic outline needs about one
node per lobe, tip or notch; a repeated object costs one <use> per copy. The SVG is usually
smaller than a PNG of the same artwork.
Choose the result from the kind of source. Ask the user only when the source leaves a real choice (true pixel art) or when this method does not fit (photos).
The tools are in the tools folder next to this file. TOOLS.md describes each tool. They
need python3 with numpy, scipy, scikit-image, opencv and pillow, node with Playwright and its
Chromium, and ImageMagick (magick). Set PLAYWRIGHT to the Playwright module path if
import('playwright') does not find it. Render with Chromium (or the target renderer of the
project), because other renderers differ in small ways.
Keep the work in a project folder: the source images, one composition module per image with
build(scene), a library package with the canonical objects, a catalog file that lists each
object with its origin, orientation and the images that use it, and an out folder. Render a
sheet with every library object and check it after each change. Show results to the user as
images.
The tools here cover common jobs. Every source has its own structures, and specialized tools pay off fast: write them in the project folder as soon as you measure the same kind of thing twice. Good tools measure parameters of a known form and never output traced pixels. Examples of tools that were worth writing:
cv2.fitEllipse, or a least
squares fit of the pixels to several ellipses at once)Build each tool on draw.py and render.mjs, so that it uses the same primitives and the
same renderer as the result.
Print the palette (palette.py) and use these exact colors. Run regions.py to list the flat
color regions and the groups of regions that look alike, which are candidates for repeated
objects. Look at the whole image at 2x to 3x and at each region at 4x to 6x. Write an
inventory: the layers, every object, what it is, what it connects to, and which objects repeat.
With a set of images, survey all of them first, because objects repeat across images.
Then look at each object at 6x to 8x with gridzoom.sh and write an object record in the
project folder (objects.md). For each object, write down:
Draw from this record, and correct the record when the source shows that it is wrong.
Ask the user about content that must change (people, logos, copyrighted characters). Agree on replacements before you draw them, and show a design image of any new object first.
Choose the technique by the kind of background:
<use> or an SVG
<pattern>. Measure the period exactly.curvefit.py edge), continued under the objects in front.Line networks: run lines.py for a first draft of the network file. The draft is wrong in
typical ways. It holds pieces of objects drawn in the line color, it misses lines behind
objects, and it can put dots on line crossings. Curate it by hand with netview.py and
gridzoom.sh, region by region at scale 5 or more. Delete pieces of objects, join lines that
continue behind objects (as a straight continuation, a corner or a T onto another line, with
the hidden end under the object), and keep only real dots. The rough polylines need only about
2 px accuracy, because the build refits every segment to the line pixels. Lines seen through a
tinted layer have another color and must be placed by hand. Run linecheck.py until nothing
is blue and every red place is an object.
For each object, write a library function with a docstring that states the origin and the
orientation of its local coordinates. Draw the form once (scene.define) and place every copy
with scene.use and a transform. Fit transforms to measured points with fit.py: a similarity
fit (with mirroring) for clean copies, an affine fit for hand drawn copies that are slightly
skewed. Use parameters instead of non-uniform scaling when a form must be flatter or longer,
because a squashed template distorts circles and line widths.
draw.curve (cubic segments with a direction and handle lengths per node)
for every smooth line and outline, and fit the handles with curvefit.py: along a stroke
(wires, hair, contour lines) or along the edge of a filled area (blobs, hills, bodies). A loop
in the source is a closed loop in the SVG.back(scene).network.draw_network defines the network without a color for this).The review decides whether the result is acceptable. Do all of it before you report anything.
tiles.sh at scale 4 or more, and look at every tile.
A region that looks right at 2x can still be wrong.compare.sh on a small box). No background shows through.linecheck.py IMAGE NET.py OUT.svg: every listed place is an object
edge or removed content, or it is fixed.review.md): the tile, the object and the fault. Fix
all of them.Differences in shading do not keep the review going. Differences in shapes and objects do.
These faults passed weak reviews and the user found them:
Report only after a review pass without faults. Show the full comparison image (source left, SVG right) at 2x or 3x, and list the differences that remain, such as simplified shading or hidden parts that you completed. Do not give an unreviewed draft to the user, and do not ask the user to find faults. Ask the user only about decisions that are theirs: content changes, and the kind of result when the source leaves a real choice. Offer options as rendered images when the user must decide on new content. When the user sends review notes, apply them in the project files, rebuild every image that uses a changed library object, and do the full review again.
A set of images is a long job. Write a brief for sub-agents in the project folder: the user's standards, the content decisions, the tools, the file layout, the review checklist and the report format. Then give each image fresh agents for its steps, strictly one at a time, for example one for the background, one for the objects and one that only reviews and fixes. After each agent, do the full review of step 4 yourself and send back what is wrong. Typical faults: traced shapes with dozens of points, wrong concepts (leaves instead of splashes, a blob instead of an animal), invented details, and library changes that break earlier images.
TOOLS.md (opens in a new tab)tools/build.py (opens in a new tab)tools/compare.sh (opens in a new tab)tools/curvefit.py (opens in a new tab)tools/draw.py (opens in a new tab)tools/fit.py (opens in a new tab)tools/gridzoom.sh (opens in a new tab)tools/linecheck.py (opens in a new tab)tools/lines.py (opens in a new tab)tools/netlib.py (opens in a new tab)tools/netview.py (opens in a new tab)tools/network.py (opens in a new tab)tools/palette.py (opens in a new tab)tools/polys.py (opens in a new tab)tools/regions.py (opens in a new tab)tools/render.mjs (opens in a new tab)tools/tiles.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub splitbrain/agent-skills --plugin splitbrain3 skills in this plugin
/fix-commentsReview the project's inline comments and doc blocks against the comment rules, and fix what violates them. Use when asked to check, clean up or update comments or docblocks, or before committing a finished change./writing-rulesRules to adhere to for any technical writing, may it be documentation, inline comments, git commits or PR descriptions