Skip to content
FramesField
SKILL.md Developer / Local Tooling SKILL.md
Verified Nov 30, 2026

SVG Optimization and Brand Icon System Skill

How to install this SKILL.md

Install into .claude/skills/, .cursor/skills/, or .agents/skills/ so your coding agent sanitizes, compresses, and normalizes every brand .svg icon or spot illustration automatically.

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.

Compatible agent hosts
Claude Code Cursor Codex
Target tool: Recraft / Figma / SVGO · License: MIT
  1. STEP 01
    Install the SVG & Icon System skill

    Pick Claude Code, Cursor, or Codex below and download the raw SKILL.md into your skills directory.

  2. STEP 02
    Drop raw Recraft or Figma SVGs into a folder

    Ask your agent to clean ./raw-svgs/, strip white backdrop boxes, and convert UI icon strokes to currentColor.

  3. STEP 03
    Ship lightweight, dark-mode-safe vectors

    Outputs 4–18 KB SVGO-optimized vectors with crisp viewBox, uniform optical padding, and semantic ARIA attributes.

1. Install for your tool

Pick the app you use below for the exact verified command or config—zero manual guessing.

Direct raw file (SKILL.md) ↓
Claude Code (.claude/skills/) bash
Installs into .claude/skills/svg-brand-icon-system/SKILL.md for automated SVG sanitization and icon architecture.
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

2. Inspect or download the full SKILL.md file

This is the exact raw file served at /raw/skills/svg-optimization-and-icon-system-skill.

SVG Optimization and Brand Icon System Skill SKILL.md
---
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.

3. Test it right away (sample prompt & result)

Sample prompt / input
"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."
What happens when it runs
- 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.

What you need & known limits

Requirements

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

Watch out for

  • 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

Frequently Asked Questions

Why do raw AI or Figma SVGs sometimes collide visually when inlined on the same page?
Vector exporters frequently generate generic CSS class names like .cls-1 or clipPath IDs like id='a' inside every file. When two inline SVGs share the same DOM document, the second file's styles overwrite the first unless SVGO converts classes to inline attributes or prefixes IDs.
Should I inline every SVG or load SVGs via img tags?
Inline small UI icons (under 4 KB) that need CSS currentColor theme adaptation or hover states. Serve larger editorial illustrations via external img elements with explicit width and height attributes so the browser caches them separately and keeps HTML payloads lean.
Use this page in AI tools or notes
raw .md