Social preview generator
Produce social-preview.png (exactly 1280×640) in the repo root, ready for manual
upload at GitHub → repo Settings → General → Social preview. There is no API
for that upload — always end by reminding the user to do it by hand.
1. Gather material
- Read
README.md (and package.json description or similar) to learn what the
project is. Distill a very short tagline — one line, roughly ≤ 60 characters.
The project name comes from the repo/package name unless the README uses a
nicer display name.
- Detect whether this is a webapp: look for
public/, index.html, stylesheets,
framework configs, templates. If so, read its CSS/HTML for theme colors,
fonts, and layout idioms and echo that visual language in the card.
- Only render the real app for reference if it costs nothing: a static
index.html you can open directly, or a dev server that is already running.
Never install dependencies or start builds just for this skill.
- Not a webapp (CLI, library)? Fall back to a tasteful typographic card derived
from the README's tone and any logo/badge assets in the repo.
- Byline name: ask the user which name to credit via an AskUserQuestion
tool call. Offer
git config user.name as the recommended first option, plus
a "No byline" option; the user can type any other name via "Other". Ask once,
here — never re-ask during the iteration loop.
2. Write the throwaway HTML
Write social-preview.html in the session scratchpad directory (not the repo).
Rules for the page:
- Canvas is exactly 1280×640:
html,body{margin:0} and a single
1280×640 container with overflow:hidden. No scrollbars, no page margins.
- Safe area: keep the name, tagline, and anything essential at least 40pt
from every edge (GitHub's own template rule — edges get cropped on some
surfaces). At CSS 96dpi that is ~53px on the 1280×640 canvas; use ≥ 54px
insets. Decorative elements may bleed to the edges.
- Default composition: project name large, the tagline under it, plus a
decorative motif in the project's visual language (shapes, gradients,
patterns echoing the app's theme). No GitHub logo, no URL, no clutter.
- Attribution: include a small, quiet byline with the name chosen in
step 1 (omit the byline entirely if the user chose none). Small type, muted
color, inside the safe area, never competing with the name/tagline.
- Legibility at half size: the 1280×640 canvas is typically displayed at
~640×320 CSS pixels (retina/2×), so every text size is effectively halved.
Keep even the smallest text (byline, captions) at ≥ 28px on the 1280-wide
canvas so it stays readable at 640×320.
- Fonts: prefer fonts shipped in the repo or the font stack its CSS declares
(system fonts are fine). Only pull a webfont (e.g. Google Fonts
<link>) when
the project's identity hinges on it — headless Chrome will fetch it.
3. Screenshot with headless Chrome
Find a Chrome binary, first hit wins:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
command -v google-chrome || command -v chromium || command -v chromium-browser
Then:
"$CHROME" --headless --disable-gpu \
--screenshot="<repo-root>/social-preview.png" \
--window-size=1280,640 \
--force-device-scale-factor=1 \
--hide-scrollbars \
--virtual-time-budget=5000 \
"file:///<scratchpad>/social-preview.html"
(--virtual-time-budget gives webfonts time to load before capture.)
Verify the output: sips -g pixelWidth -g pixelHeight social-preview.png must
report 1280×640. If not, fix the HTML/flags — do not ship a wrong-size image.
4. Approval loop, then clean up
- Send the PNG to the user (SendUserFile) and ask for reactions.
- Iterate: tweak the HTML, re-run the same screenshot command, resend. Keep
social-preview.html alive during this loop.
- Once the user approves: delete the throwaway HTML, leave
social-preview.png
in the repo root, and do not commit it unless asked.
- Close with the reminder: upload it manually at GitHub → Settings → General →
Social preview (minimum 640×320, this file is the recommended 1280×640).
1---2name: social-preview3description: Generate a GitHub social preview image (1280×640 PNG) for the current repo. Builds a throwaway social-preview.html styled after the project's own look (webapp theme colors, fonts, layout) with a minimal tagline from the README, screenshots it with headless Chrome, and iterates with the user until approved. Use when the user asks for a social preview, OG image, open-graph image, or repo card image.4license: MIT5---67# Social preview generator89Produce `social-preview.png` (exactly 1280×640) in the repo root, ready for manual10upload at GitHub → repo **Settings → General → Social preview**. There is no API11for that upload — always end by reminding the user to do it by hand.1213## 1. Gather material1415- Read `README.md` (and `package.json` description or similar) to learn what the16 project is. Distill a **very short tagline** — one line, roughly ≤ 60 characters.17 The project name comes from the repo/package name unless the README uses a18 nicer display name.19- Detect whether this is a webapp: look for `public/`, `index.html`, stylesheets,20 framework configs, templates. If so, read its CSS/HTML for **theme colors,21 fonts, and layout idioms** and echo that visual language in the card.22- Only render the real app for reference if it costs nothing: a static23 `index.html` you can open directly, or a dev server that is already running.24 Never install dependencies or start builds just for this skill.25- Not a webapp (CLI, library)? Fall back to a tasteful typographic card derived26 from the README's tone and any logo/badge assets in the repo.27- **Byline name**: ask the user which name to credit via an **AskUserQuestion**28 tool call. Offer `git config user.name` as the recommended first option, plus29 a "No byline" option; the user can type any other name via "Other". Ask once,30 here — never re-ask during the iteration loop.3132## 2. Write the throwaway HTML3334Write `social-preview.html` in the **session scratchpad directory** (not the repo).3536Rules for the page:3738- Canvas is exactly 1280×640: `html,body{margin:0}` and a single39 `1280×640` container with `overflow:hidden`. No scrollbars, no page margins.40- **Safe area**: keep the name, tagline, and anything essential at least **40pt41 from every edge** (GitHub's own template rule — edges get cropped on some42 surfaces). At CSS 96dpi that is ~53px on the 1280×640 canvas; use **≥ 54px**43 insets. Decorative elements may bleed to the edges.44- Default composition: project **name** large, the **tagline** under it, plus a45 **decorative motif in the project's visual language** (shapes, gradients,46 patterns echoing the app's theme). No GitHub logo, no URL, no clutter.47- **Attribution**: include a small, quiet byline with the name chosen in48 step 1 (omit the byline entirely if the user chose none). Small type, muted49 color, inside the safe area, never competing with the name/tagline.50- **Legibility at half size**: the 1280×640 canvas is typically displayed at51 ~640×320 CSS pixels (retina/2×), so every text size is effectively halved.52 Keep even the smallest text (byline, captions) at ≥ 28px on the 1280-wide53 canvas so it stays readable at 640×320.54- Fonts: prefer fonts shipped in the repo or the font stack its CSS declares55 (system fonts are fine). Only pull a webfont (e.g. Google Fonts `<link>`) when56 the project's identity hinges on it — headless Chrome will fetch it.5758## 3. Screenshot with headless Chrome5960Find a Chrome binary, first hit wins:61621. `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`632. `command -v google-chrome || command -v chromium || command -v chromium-browser`6465Then:6667```sh68"$CHROME" --headless --disable-gpu \69 --screenshot="<repo-root>/social-preview.png" \70 --window-size=1280,640 \71 --force-device-scale-factor=1 \72 --hide-scrollbars \73 --virtual-time-budget=5000 \74 "file:///<scratchpad>/social-preview.html"75```7677(`--virtual-time-budget` gives webfonts time to load before capture.)7879Verify the output: `sips -g pixelWidth -g pixelHeight social-preview.png` must80report 1280×640. If not, fix the HTML/flags — do not ship a wrong-size image.8182## 4. Approval loop, then clean up8384- Send the PNG to the user (SendUserFile) and ask for reactions.85- Iterate: tweak the HTML, re-run the same screenshot command, resend. Keep86 `social-preview.html` alive during this loop.87- Once the user approves: delete the throwaway HTML, leave `social-preview.png`88 in the repo root, and do **not** commit it unless asked.89- Close with the reminder: upload it manually at GitHub → **Settings → General →90 Social preview** (minimum 640×320, this file is the recommended 1280×640).