---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://framesfield.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
title: "SVG Optimization and Brand Icon System Skill"
description: "Installable SKILL.md teaching Claude Code, Cursor, and Codex how to clean raw Recraft or Figma SVG exports via SVGO, strip unwanted opaque background rects, enforce uniform integer viewBox grids, replace hardcoded black fills with CSS currentColor for dark-mode safety, and wire accessible icon components."
canonical: "https://framesfield.com/skills/svg-optimization-and-icon-system-skill"
---

# SVG Optimization and Brand Icon System Skill

> Installable SKILL.md teaching Claude Code, Cursor, and Codex how to clean raw Recraft or Figma SVG exports via SVGO, strip unwanted opaque background rects, enforce uniform integer viewBox grids, replace hardcoded black fills with CSS currentColor for dark-mode safety, and wire accessible icon components.

- **Canonical URL:** https://framesfield.com/skills/svg-optimization-and-icon-system-skill
- **Raw Payload URL:** https://framesfield.com/raw/skills/svg-optimization-and-icon-system-skill
- **Asset Type:** SKILL.md
- **Compatible Hosts:** Claude Code, Cursor, Codex
- **Target Creative Tool:** Recraft / Figma / SVGO
- **License:** MIT
- **Last Verified:** 2026-11-30
- **Source Reference:** https://github.com/svg/svgo

## Setup & Install

```bash
mkdir -p .claude/skills/svg-brand-icon-system
curl -fsSL https://framesfield.com/raw/skills/svg-optimization-and-icon-system-skill -o .claude/skills/svg-brand-icon-system/SKILL.md

```

## Copyable Asset (SKILL.md)

````markdown
---
name: svg-brand-icon-system
description: Clean, optimize, and standardize Recraft or Figma SVG icons and spot illustrations using SVGO, stripping opaque background rects, preserving explicit viewBox grids, binding monochrome strokes to currentColor, and enforcing accessible inline or external embedding rules.
---

# SVG Optimization & Brand Icon System Protocol

Whenever creating, cleaning, or embedding `.svg` brand icons, pictograms, or editorial spot illustrations in a web repository, apply these deterministic engineering rules:

## 1. Mandatory Raw SVG Sanitization (Recraft / Figma Exports)
Before committing any newly generated or exported SVG:
1. **Strip stray canvas backgrounds:** Inspect the root `<svg>` children and remove any full-bleed white/off-white background `<rect>` (`fill="#fff"`, `#ffffff`, `#F7F7F5`) that turns icons into opaque squares on colored or dark surfaces.
2. **Preserve `viewBox` (NEVER strip it):** Confirm every `<svg>` carries an explicit integer `viewBox="0 0 W H"`. Remove fixed pixel `width`/`height` only when inlining responsive UI icons; keep explicit `width` and `height` when rendering via `<img src="...svg">` (`CLS = 0`).
3. **Run SVGO safely with `removeViewBox` disabled:**
   ```bash
   npx svgo -f ./raw-svgs -o ./public/images/icons --multipass --precision=2
   ```
   Ensure SVGO never strips `viewBox`, `role`, or `aria-label`.

## 2. Theme-Safe Color Mapping (`currentColor` & Brand Tokens)
- **Monochrome UI icons (16px–32px):** Replace hardcoded dark fills/strokes (`#000`, `#000000`, `#111`, `#111111`) with `currentColor` so components control color cleanly via semantic CSS classes (`text-ink`, `text-ink-muted`).
- **Duotone brand marks / spot illustrations:** Bind primary ink strokes to `currentColor` and brand accent fills to `var(--accent-signal, #E04420)` so theme flips stay automatic.
- **Never** embed `<style>` blocks with colliding generic class names (`.cls-1`, `.st0`) across multiple inline SVGs on the same page—inline attributes cleanly or prefix IDs uniquely.

## 3. Inline vs. External `<img src>` Decision Rule
- **Inline `<svg>` (`<= 4 KB`, needs `currentColor` or hover transitions):** Add `aria-hidden="true" focusable="false"` for decorative icons beside text labels; add `role="img" aria-label="..."` for standalone icon-only buttons.
- **External `<img src="/images/illustrations/name.svg">` (`> 4 KB` editorial diagrams or multi-color marks):** Always specify exact numeric `width`, `height`, and descriptive `alt` so browsers cache the file cleanly with zero layout shift.

## 4. Verification Gate
After cleaning an icon batch, verify:
- File sizes reduced cleanly (typically `1–4 KB` UI icons, `4–25 KB` spot illustrations).
- Zero `#000000` / `#111111` hardcoded strokes remain on monochrome UI icons.
- Zero unescaped `<script>` tags or external `<image href="data:image/png;base64,...">` raster wrappers disguised inside `.svg` files.
````

## Example Input

```text
"Clean the 12 new Recraft SVGs in ./raw-svgs, delete white backdrop rects, convert #111111 strokes to currentColor, optimize with SVGO, and wire an accessible Icon.astro helper."
```

## Expected Output

```text
- Removes full-canvas white <rect> layers from all 12 SVGs, runs SVGO (--multipass --precision=2) shrinking total set from 412 KB to 68 KB.
- Converts primary strokes to currentColor while preserving var(--accent-signal) accent dots and integer viewBox attributes.
- Emits accessible inline SVG helper with aria-hidden="true" when decorative and explicit role="img" + aria-label when standalone.
```

## Requirements

- Node.js (`npx svgo` or `svgo` devDependency)
- Claude Code (`.claude/skills/`), Cursor (`.cursor/skills/`), or Codex (`.agents/skills/`)

## Known Limits

- Never auto-trace complex photographic PNGs into SVGs—use Recraft native vector output ($0.08/SVG on V4.1 and V3) or keep photos in WebP/AVIF
- Always inspect cleaned SVGs visually at both 24px UI size and dark background mode to confirm no interior counter-shapes turned solid

## Implementation Notes

## Pair with native SVG generation and design workflows

Generate locked brand icon packs upfront with [Workflow 11: Brand Icon and Editable SVG Illustration Kit](/workflows/brand-icon-and-illustration-kit-pipeline) using [Recraft V4.1](/specs/recraft-v4-1) (API default, `$0.08/SVG`) or [Recraft V3](/specs/recraft-v3) (when using V3's curated `vector_illustration` preset), and review the complete format matrix in [Guide 09: AI Image Craft, Vector SVGs and Brand Design Systems](/guides/ai-image-and-brand-design-systems-guide).
