Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Generate beautiful code snippet images using ray.so. This skill should be used when the user asks to create a code image, code screenshot, code snippet image, or wants to make their code look pretty for sharing. Saves images locally to the current working directory or a user-specified path.
.claude/skills/mkurman-ray-so-code-snippet/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 33% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 140% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 92% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 30% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 241% | 0% |
-----|--------|---------| | theme | Any theme from list | breeze | | padding | 16, 32, 64, 128 | 64 | | background | true, false | true | | darkMode | true, false | true | | language | Any language from list, or "auto" | auto | | lineNumbers | true, false | false | | title | URL-encoded string | (none) | | width | Number (pixels) | auto | | code | Base64-encoded, then URL-encoded | (required) |
Note on width: Do NOT include the width parameter unless you specifically need a fixed width. Without it, ray.so auto-sizes the frame to fit the code content, avoiding unnecessary empty space.
Example URL construction:
bash# For code: for i in range(23):\n print(i) # Theme: midnight, Padding: 64, Dark mode: true, Background: true, Language: python, Title: test.py CODE='for i in range(23): print(i)' CODE_BASE64=$(echo -n "$CODE" | base64) CODE_ENCODED=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$CODE_BASE64'))") TITLE_ENCODED=$(python3 -c "import urllib.parse; print(urllib.parse.quote('test.py'))") URL="https://ray.so/#theme=midnight&padding=64&background=true&darkMode=true&language=python&title=${TITLE_ENCODED}&code=${CODE_ENCODED}" echo "$URL"
MUST use agent-browser (verified in Step 1). This approach uses the html-to-image library (same as ray.so's internal export) with high pixelRatio for crisp, sharp text rendering.
IMPORTANT: Always use a unique session name with --session to avoid stale session issues.
bash# Generate unique session name SESSION="rayso-$(date +%s)" # 1. Set viewport agent-browser --session $SESSION set viewport 1400 900 # 2. Open the URL agent-browser --session $SESSION open "$URL" # 3. Wait for the page to fully render agent-browser --session $SESSION wait --load networkidle agent-browser --session $SESSION wait 3000 # 4. Load html-to-image library (same library ray.so uses internally) agent-browser --session $SESSION eval 'new Promise((r,e)=>{const s=document.createElement("script");s.src="https://cdn.jsdelivr.net/npm/html-to-image@1.11.11/dist/html-to-image.js";s.onload=r;s.onerror=e;document.head.appendChild(s)})' # 5. Capture at 4x resolution using html-to-image (produces crisp text) agent-browser --session $SESSION eval 'htmlToImage.toPng(document.querySelector("#frame > div"),{pixelRatio:4,skipAutoScale:true})' > /tmp/rayso-dataurl-$SESSION.txt # 6. Close the browser agent-browser --session $SESSION close # 7. Convert data URL to PNG file DATAURL=$(cat /tmp/rayso-dataurl-$SESSION.txt | tr -d '"' | tr -d '\n') echo "$DATAURL" | sed 's/data:image\/png;base64,//' | base64 -d > /path/to/output.png # 8. Clean up temp file rm /tmp/rayso-dataurl-$SESSION.txt
Critical notes:
html-to-image library which is what ray.so uses for its own export featurepixelRatio: 4 produces high-DPI images with crisp, sharp text (4x native resolution)Report the saved file location to the user. The task is complete - do not perform any additional checks, explorations, or verifications after the screenshot is saved.
User: "Create a code snippet image of this Python function"
pythondef fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
which agent-browser - confirmed availablebashcurl -s "https://raw.githubusercontent.com/raycast/ray-so/main/app/(navigation)/(code)/store/themes.ts" | grep -oE 'id:\s*"[^"]+"' | sed 's/id:\s*"//;s/"//' | sort -u
bashCODE='def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)' CODE_BASE64=$(echo -n "$CODE" | base64) CODE_ENCODED=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$CODE_BASE64'))") URL="https://ray.so/#theme=midnight&padding=64&background=true&darkMode=true&language=python&code=${CODE_ENCODED}"
bashSESSION="rayso-$(date +%s)" agent-browser --session $SESSION set viewport 1400 900 agent-browser --session $SESSION open "$URL" agent-browser --session $SESSION wait --load networkidle agent-browser --session $SESSION wait 3000 # Load html-to-image library agent-browser --session $SESSION eval 'new Promise((r,e)=>{const s=document.createElement("script");s.src="https://cdn.jsdelivr.net/npm/html-to-image@1.11.11/dist/html-to-image.js";s.onload=r;s.onerror=e;document.head.appendChild(s)})' # Capture at 4x resolution agent-browser --session $SESSION eval 'htmlToImage.toPng(document.querySelector("#frame > div"),{pixelRatio:4,skipAutoScale:true})' > /tmp/rayso-dataurl-$SESSION.txt agent-browser --session $SESSION close # Save as PNG DATAURL=$(cat /tmp/rayso-dataurl-$SESSION.txt | tr -d '"' | tr -d '\n') echo "$DATAURL" | sed 's/data:image\/png;base64,//' | base64 -d > ./fibonacci.png rm /tmp/rayso-dataurl-$SESSION.txt
This skill uses the html-to-image library with pixelRatio: 4 to produce high-quality images with crisp, sharp text. This is the same rendering approach that ray.so uses for its built-in export feature.
Output quality:
Adjusting resolution:
pixelRatio:4 to pixelRatio:2 in the eval commandpixelRatio:6 (same as ray.so's "6x" export option)Forcing a specific width:
&width=NUMBER to the URL if you need a fixed width (e.g., for consistent sizing across multiple images)#title=filename.py&code=...#frame > div may have changed; inspect the page structure--session flag| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 17,940 | 7,403 | -59% | 1 | 1 | 0% | 3,492 | 2,466 | -29% | 0 | 0 | — |
case-02 | fail→fail | 12,577 | 6,872 | -45% | 1 | 1 | 0% | 2,591 | 2,819 | +9% | 0 | 0 | — |
case-03 | fail→fail | 13,667 | 5,959 | -56% | 1 | 1 | 0% | 2,498 | 2,633 | +5% | 0 | 0 | — |
case-04 | fail→pass | 12,167 | 3,084 | -75% | 1 | 1 | 0% | 2,134 | 2,844 | +33% | 0 | 0 | — |
case-05 | pass→pass | 13,603 | 4,588 | -66% | 1 | 1 | 0% | 2,500 | 3,105 | +24% | 0 | 0 | — |
case-06 | pass→pass | 7,650 | 2,535 | -67% | 1 | 1 | 0% | 1,313 | 2,727 | +108% | 0 | 0 | — |
case-07 | fail→pass | 5,923 | 1,968 | -67% | 1 | 1 | 0% | 1,089 | 2,619 | +140% | 0 | 0 | — |
case-08 | fail→pass | 9,097 | 2,977 | -67% | 1 | 1 | 0% | 1,411 | 2,713 | +92% | 0 | 0 | — |
case-09 | fail→pass | 14,301 | 3,567 | -75% | 1 | 1 | 0% | 2,249 | 2,915 | +30% | 0 | 0 | — |
case-10 | pass→pass | 6,542 | 1,724 | -74% | 1 | 1 | 0% | 1,058 | 2,556 | +142% | 0 | 0 | — |
case-11 | pass→pass | 4,161 | 2,217 | -47% | 1 | 1 | 0% | 642 | 2,577 | +301% | 0 | 0 | — |
case-12 | pass→pass | 7,587 | 3,332 | -56% | 1 | 1 | 0% | 1,427 | 2,897 | +103% | 0 | 0 | — |
case-13 | fail→pass | 4,918 | 1,716 | -65% | 1 | 1 | 0% | 743 | 2,533 | +241% | 0 | 0 | — |
case-14 | pass→pass | 7,329 | 6,982 | -5% | 1 | 1 | 0% | 1,285 | 3,511 | +173% | 0 | 0 | — |
case-15 | fail→pass | 12,944 | 5,314 | -59% | 1 | 1 | 0% | 2,185 | 3,308 | +51% | 0 | 0 | — |
case-16 | fail→pass | 7,686 | 2,236 | -71% | 1 | 1 | 0% | 1,211 | 2,587 | +114% | 0 | 0 | — |
case-17 | pass→pass | 9,588 | 2,848 | -70% | 1 | 1 | 0% | 1,728 | 2,807 | +62% | 0 | 0 | — |
case-18 | pass→pass | 11,447 | 4,553 | -60% | 1 | 1 | 0% | 2,004 | 2,997 | +50% | 0 | 0 | — |
case-19 | pass→fail | 9,653 | 4,929 | -49% | 1 | 1 | 0% | 1,815 | 2,412 | +33% | 0 | 0 | — |
case-20 | pass→pass | 10,226 | 8,444 | -17% | 1 | 1 | 0% | 1,632 | 3,056 | +87% | 0 | 0 | — |
case-21 | pass→pass | 4,150 | 3,014 | -27% | 1 | 1 | 0% | 674 | 2,713 | +303% | 0 | 0 | — |
case-22 | fail→pass | 10,969 | 2,587 | -76% | 1 | 1 | 0% | 1,760 | 2,683 | +52% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 18 counted toward the lift figure. The other 4 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +32 percentage points is the difference between those two pass rates over the 18 comparable cases. 2 cases got worse with the skill loaded, and they are included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.