---
name: create-svg
description: Create an SVG from an image prompt by generating a high-contrast raster image with the harness image-generation tool or an installed image-creation skill, then tracing it with swift-potrace. Use for prompt-to-SVG artwork, silhouettes, illustrations, and marks.
---

# Create SVG

Turn the user's image idea into an actual SVG through image generation followed by `potrace` conversion. The input is an image prompt, not a command string. Complete both stages; a generated PNG alone is not the deliverable.

## Inputs and defaults

- Accept the user's image prompt, any reference images, and supplied composition, aspect ratio, text, or destination constraints.
- Preserve the subject, exact requested text, and supplied file names and identifiers. Ask only for missing information that blocks the work.
- If no destination is supplied, choose a descriptive, unused `.svg` path in the current workspace and retain the generated source PNG beside it. Preserve existing files unless replacement was requested.
- This workflow produces monochrome traced shapes. Do not promise full-colour reproduction; clarify if preserving multiple colours is essential to the request.

## 1. Check the converter

Check `command -v potrace` and `potrace --help`. Confirm this is **swift-potrace**, whose CLI accepts PNG via `--input` and SVG output via `--output`. Another implementation named `potrace` may have different input formats and options.

If missing or incompatible, follow the current [swift-potrace installation instructions](https://richardstelling.com/swift-potrace/docs/): download the linked prebuilt archive matching the execution host's OS and architecture, unpack it, and place the executable on PATH in an appropriate writable location. The documented macOS archive example is `tar -xzf potrace-macos-arm64.tar.gz`; choose the actual archive from the page for the current host. Verify the installed executable with `--help` before conversion. Do not replace an unrelated existing binary; use the newly installed executable's absolute path if necessary.

Read the live instructions when installation is needed rather than inventing a package-manager recipe or download URL. If no compatible build or usable installation route is available, report the concrete limitation.

## 2. Generate a high-contrast PNG

Use the harness's built-in image-generation capability by default. Where an installed image-creation skill supplies the workflow, read and follow it; use another available installed image-creation capability when appropriate. Respect that capability's fallback and authorization rules. Do not require an API key when the harness already provides image generation, invent a replacement generator, or hand-author an SVG in place of this workflow.

Retain the user's intent and add tracing guidance to the generation prompt:

> Create this as high-contrast black artwork on a plain white background, ready for bitmap-to-vector tracing. Use solid shapes or clear, sufficiently thick linework, crisp contours, and distinct negative space. Avoid gradients, shadows, grey washes, noisy textures, and tiny isolated details. Preserve the requested subject, composition, and exact text; add no unrequested lettering or objects.

Adapt this guidance to explicit user constraints. Prefer black on opaque white because dark regions become the traced shapes; avoid a dark background that would become one large filled region. Keep enough margin to avoid unintended cropping.

Generate the raster image and obtain its actual local output path from the tool. Request PNG where supported; if the output format differs, use an available format-conversion capability to save a real PNG rather than renaming the extension. Follow the image-generation tool's save-path rules, then copy the selected source into the workspace as needed.

Inspect the generated image before tracing. If the subject or contrast is unsuitable, make a focused correction with the same image-generation workflow. Do not proceed with an obviously blank or unusable source.

## 3. Convert with potrace

Run the verified executable with the actual source and destination paths, quoting them safely:

```sh
potrace --input "source.png" --output "result.svg"
```

The example names are placeholders, not required filenames. Construct the command from the generated PNG and chosen destination; the user does not need to supply it. Keep stderr and diagnostics separate from SVG content, and require a successful exit and a newly produced, nonempty file.

Start with the converter defaults. If inspection shows a specific tracing defect, use supported options from `--help` or the linked docs: `--turdsize` suppresses small speckles, `--alphamax` adjusts corner rounding, and `--anti-alias` smooths pixelated edges. Use `--invert` only when the foreground/background polarity requires it. Avoid parameter sweeps without a demonstrated need.

## 4. Validate, inspect, and deliver

- Validate well-formed XML with an `svg` root in `http://www.w3.org/2000/svg`. Allow XML declarations, comments, whitespace, and DOCTYPEs; disable external resource resolution. An opening-tag or MIME check alone is insufficient.
- Render or preview the SVG with an available viewer and inspect the actual traced result against the source: recognizable subject, retained holes and linework, no unexpected filled background, blank output, or clipping. XML validity alone does not establish visual quality. If preview is unavailable, disclose that limit.
- Correct a demonstrated problem at its source: regenerate for image/composition issues or adjust supported tracing options for conversion issues, then validate and inspect again. Report unresolved problems rather than claiming success.
- Deliver the actual SVG file with a clickable absolute path and preview where supported. Keep the validated converter output unchanged; do not replace it with a raster embedded in SVG. Retain and link the source PNG when useful.
- Briefly report the image-generation capability used and any material limitations. Follow that capability's requirements for reporting the final prompt. Report generation, installation, conversion, validation, and delivery failures accurately.
