$npx -y skills add sordi-ai/skill-everything --skill svg-checkApply when editing, generating, or reviewing any SVG diagram. Pixel-perfect Playwright bbox-check is the acceptance test — eyeballing is not sufficient. Run on every SVG before declaring done.
| 1 | # Sub-Skill: SVG Check |
| 2 | |
| 3 | **Purpose.** Catch text-overflow and foreign-rect-intersection bugs in SVG diagrams *before* commit. LLM eyeball review at 4× zoom misses these bug classes consistently — measurement is the only reliable test. |
| 4 | |
| 5 | The acceptance test is the script output. Not your visual judgment. |
| 6 | |
| 7 | --- |
| 8 | |
| 9 | ## When to apply |
| 10 | |
| 11 | Apply this skill whenever: |
| 12 | |
| 13 | - you are editing an existing SVG (`*.svg` in any docs/diagrams folder), |
| 14 | - you are producing a new SVG from scratch, |
| 15 | - a designer agent reports an SVG as "clean" — verify with the script, |
| 16 | - you are reviewing a PR that touches `*.svg`. |
| 17 | |
| 18 | --- |
| 19 | |
| 20 | ## The two bug classes the script catches |
| 21 | |
| 22 | 1. **OVERFLOW (own-container)**: a `<text>` whose rendered bbox extends past the bounds of its containing `<rect>` (in the same `<g>`). Caught by `getBBox()` measurement, tolerance 2 px. |
| 23 | |
| 24 | 2. **FOREIGN-RECT INTERSECT**: a `<text>` whose viewport bbox intersects a `<rect>` that is *not* an ancestor of the text — i.e. a tagline ascender that touches a structural box above/below it. Caught by `getBoundingClientRect()` intersection, tolerance 2 px. |
| 25 | |
| 26 | Both classes filter false-positives: rects smaller than 40 × 18 (legend swatches) are not treated as containers; texts that start more than 5 px outside a rect's horizontal range are not treated as contained. |
| 27 | |
| 28 | --- |
| 29 | |
| 30 | ## How to run |
| 31 | |
| 32 | The script lives next to this file: [`overflow-check.js`](./overflow-check.js). It needs Playwright installed once per machine. |
| 33 | |
| 34 | ### One-time setup |
| 35 | |
| 36 | ```bash |
| 37 | # From the skill folder |
| 38 | cd skills/svg-check |
| 39 | bash setup.sh |
| 40 | ``` |
| 41 | |
| 42 | Or manually: |
| 43 | |
| 44 | ```bash |
| 45 | npm install playwright |
| 46 | npx playwright install chromium --with-deps |
| 47 | ``` |
| 48 | |
| 49 | ### Run on one SVG |
| 50 | |
| 51 | ```bash |
| 52 | node skills/svg-check/overflow-check.js path/to/diagram.svg |
| 53 | ``` |
| 54 | |
| 55 | ### Run on all SVGs in a folder |
| 56 | |
| 57 | ```bash |
| 58 | for svg in path/to/*.svg; do |
| 59 | out=$(node skills/svg-check/overflow-check.js "$svg" 2>&1) |
| 60 | if echo "$out" | grep -q "FOUND"; then |
| 61 | echo "FAIL: $svg"; echo "$out" | grep -E "FOUND| \[| \"" |
| 62 | fi |
| 63 | done |
| 64 | ``` |
| 65 | |
| 66 | The script exits non-zero when issues are found — suitable for use as a pre-commit gate or CI step. |
| 67 | |
| 68 | --- |
| 69 | |
| 70 | ## Acceptance criteria |
| 71 | |
| 72 | The script output **must** contain both of these lines, verbatim, for every SVG in scope: |
| 73 | |
| 74 | ``` |
| 75 | OVERFLOW: CLEAN — 0 text overflows past their containing rect |
| 76 | FOREIGN-RECT INTERSECT: CLEAN — 0 text-vs-foreign-rect intersections |
| 77 | ``` |
| 78 | |
| 79 | Anything else means **not done**. Fix the SVG (shorten text, widen rect, move element, change font-size) and re-run until both lines are CLEAN. |
| 80 | |
| 81 | In addition, after the script is CLEAN, render a Playwright screenshot in light + dark mode and visually cross-check for bug classes the script does not cover (see § *Limits* below). |
| 82 | |
| 83 | --- |
| 84 | |
| 85 | ## How to fix common overflow patterns |
| 86 | |
| 87 | | Pattern | Fix | |
| 88 | |---|---| |
| 89 | | Mono-tag text wider than its 200 px box | Move trailing content to a `mono-dim` line below, or drop the suffix entirely. Match the sibling-box pattern. | |
| 90 | | Tagline ascenders touch the rect above | Extend the SVG viewBox height (`500 → 520`) and move the tagline down. Other elements stay put. | |
| 91 | | Two-line label tight in a folder glyph | Move from `y=22/33` to `y=21/34` (13 px line-height instead of 11 px). | |
| 92 | | Annotation text overflowing a chip | Either widen the chip rect or shorten the annotation. Do **not** suppress the script — fix the SVG. | |
| 93 | |
| 94 | --- |
| 95 | |
| 96 | ## Examples |
| 97 | |
| 98 | See [`EXAMPLES.md`](./EXAMPLES.md) for real before/after fixes with script output. |
| 99 | |
| 100 | --- |
| 101 | |
| 102 | ## Limits — what the script does NOT catch |
| 103 | |
| 104 | These remain eyeball-only for now. When a missed bug class surfaces, extend the script with a new check class — do not rely on agent self-reporting. |
| 105 | |
| 106 | - **Text-vs-line overlaps**: a `<text>` crossing an `<line>` arrow. |
| 107 | - **≥12 px clearance** between text-baseline and the nearest line below it. |
| 108 | - **Sibling text overlaps**: two `<text>` elements at the same coords. |
| 109 | - **Color contrast ratio** in dark mode. |
| 110 | - **Glyph render quality** at small sizes (≤ 10 px). |
| 111 | |
| 112 | --- |
| 113 | |
| 114 | ## Why this skill exists (incident history) |
| 115 | |
| 116 | - **2026-05-11 #1**: a four-designer parallel review declared `architecture.svg` clean. The GEMINI CLI loader-tag overflowed its 200 px box by 42.6 px. No agent measured. |
| 117 | - **2026-05-11 #2**: a follow-up three-cycle eyeball review missed that the tagline ascenders intruded into the folder-strip border above. The fix was a 20 px viewBox extension; the bug was a 2 px overlap that the agents could not detect by sight. |
| 118 | |
| 119 | The script was built after the second miss. It catches both bug classes in under 5 seconds. |
| 120 | |
| 121 | The rule that follows from these incidents: **don't trust agent self-reports of "no issues at 4× zoom". Trust the measurement.** |
| 122 | |
| 123 | --- |
| 124 | |
| 125 | ## R |