cssmagic/agent-skills/fix-svg-aspect-ratio
Claude Code and agent skill by cssmagic/agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Use when SVG files render with a distorted aspect ratio, especially vector SVG assets exported by Figma Desktop MCP.
Install
npx vskill@latest install cssmagic/agent-skills/fix-svg-aspect-ratioSKILL.md
The same SKILL.md was published earlier as cssmagic/agent-skills/fix-svg-aspect-ratio.
Fix SVG Aspect Ratio
Purpose
Fix SVG files whose root <svg> attributes can make the artwork stretch instead of preserving its natural aspect ratio.
This skill is intentionally small and script-backed so other skills can call it as an atomic utility.
Required Input
Each run needs one path:
- A single SVG file.
- A directory tree containing SVG files.
If the path is missing or ambiguous, ask the user for it before running commands.
Normalize ~ and relative paths to absolute paths before reporting or running the script.
Defaults
When given a directory, scan .svg files recursively and case-insensitively.
Modify files in place.
Output a non-interactive report every run. This is safe for atomic calls because the script never prompts for input.
Do not infer dimensions from paths, CSS, rendered output, or child elements. If a file has no valid viewBox, report it as unsupported.
Fixes Applied
For each valid SVG root with a valid viewBox, set these root <svg> attributes:
preserveAspectRatio="xMidYMid meet"widthfrom the thirdviewBoxnumberheightfrom the fourthviewBoxnumber
Also remove display: block from the root style attribute. If the style attribute has other declarations, keep them.
Do not modify internal SVG content such as <g>, <path>, <defs>, gradients, ids, or fill values.
Workflow
Set the path from the user's provided input:
Run the bundled script from this skill directory:
The script validates each SVG before writing, writes to a temporary file beside the source, then atomically replaces the original file.
Reporting
The script outputs every SVG file grouped by result type:
Fixed- processing succeeded and the file was changed.Already Correct- the SVG already matched the expected root attributes.Unsupported- the SVG was readable but not safe to process, such as a missing or invalidviewBox.Failed- the script could not read, parse, or write the file.
Example output:
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/fix-svg-aspect-ratio/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cssmagic/agent-skills/fix-svg-aspect-ratio)