This skill should be used when the user asks to "generate social preview", "create social image", "github social preview", "repository preview image", "og image", "social media card", "create repo...
Generate social preview images for GitHub repositories by analyzing project intent, purpose, and spirit. Create images that capture what a project does and why it matters.
This skill analyzes a project's codebase, documentation, and configuration to understand its purpose, then generates:
All generated images must meet GitHub's social preview requirements:
.github/social-preview.svg - Editable source file.github/social-preview.jpg - Always generated for GitHub uploadIMPORTANT: GitHub's social preview setting requires a raster image (JPG/PNG). SVG generation MUST ALWAYS also produce a JPG file.
Look for optional settings file at .claude/github-social.local.md.
If file exists, parse YAML frontmatter for:
provider: Image generation provider (svg, dalle-3, gemini, manual) - default: svgapi_key_env: Environment variable name containing API key (for dalle-3 or gemini)svg_style: SVG style preference (minimal, geometric, illustrated) - default: minimaldark_mode: Dark mode support (false, true, both) - default: falseoutput_path: Where to save the imagedimensions: Image dimensions (default: 1280x640)include_text: Whether to include project name in imagecolors: Color scheme preference (auto, dark, light, custom)upload_to_repo: Whether to upload the image to the GitHub repositoryCommand-line overrides (highest priority):
--provider=svg|dalle-3|gemini|manual--dark-mode (generates dark variant or both)--upload (upload to repository)If no config exists, use defaults: provider: svg, svg_style: minimal.
Gather project context by reading available files:
Primary sources (check in order):
README.md - Project description, features, purposepackage.json / Cargo.toml / pyproject.toml / go.mod - Name, description, keywordsCLAUDE.md - Project context and guidelines.github/FUNDING.yml - Project goals/sustainability infoSecondary sources (if primary insufficient):
Extract these elements:
Based on analysis, design a visual concept that:
Represents the domain visually
Captures the project's spirit
Applies style preferences
Route to appropriate generation method based on provider setting.
When provider: svg or not configured, generate a clean SVG file directly.
SVG Design Principles:
SVG Template Structure:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 640">
<defs>
<!-- Optional: gradients, patterns -->
<linearGradient id="bg-gradient" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:[color1]"/>
<stop offset="100%" style="stop-color:[color2]"/>
</linearGradient>
</defs>
<!-- Background -->
<rect width="1280" height="640" fill="url(#bg-gradient)"/>
<!-- Domain-specific visual elements (3-15 shapes based on svg_style) -->
<!-- Project name (if include_text: true) -->
<text x="640" y="340"
font-family="-apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif"
font-size="72" font-weight="700"
text-anchor="middle" fill="[text-color]">
[PROJECT-NAME]
</text>
<!-- Optional tagline -->
<text x="640" y="400"
font-family="-apple-system, BlinkMacSystemFont, 'Inter', sans-serif"
font-size="24" font-weight="400"
text-anchor="middle" fill="[secondary-text-color]" opacity="0.8">
[tagline]
</text>
</svg>
SVG Style Guidelines:
Minimal (default):
Geometric:
Illustrated:
Domain-Specific SVG Patterns:
See references/svg-templates.md for complete templates by domain.
Dark Mode Support:
If dark_mode: true or dark_mode: both:
both: save as [name].svg and [name]-dark.svgSave SVG and Convert to JPG:
output_path (default: .github/social-preview.svg)# Convert SVG to JPG at 1280x640, quality 90
convert .github/social-preview.svg -resize 1280x640! -quality 90 -background white -flatten .github/social-preview.jpg
dark_mode: both, generate dark variant SVG and JPG:.github/social-preview-dark.svg.github/social-preview-dark.jpgNote: The JPG is the file to upload to GitHub's social preview setting. The SVG is kept as an editable source.
When provider: dalle-3:
Verify API key: Check $OPENAI_API_KEY or configured api_key_env
Craft optimized prompt (see Step 4d for prompt structure)
Call DALL-E API:
curl -s https://api.openai.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "dall-e-3",
"prompt": "[generated prompt]",
"n": 1,
"size": "1792x1024",
"quality": "hd",
"response_format": "b64_json"
}'
# Decode base64 and resize to 1280x640
echo "[base64_data]" | base64 -d > temp_image.png
convert temp_image.png -resize 1280x640! -quality 90 .github/social-preview.png
When provider: gemini:
Verify API key: Check $GEMINI_API_KEY or configured api_key_env
Select model:
gemini-2.5-flash-image - Fast, efficient (default)gemini-3-pro-image-preview - Higher quality with reasoning, better text renderingCraft optimized prompt (see Step 4d for prompt structure)
Call Gemini API:
curl -X POST \
"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"parts": [{"text": "[generated prompt]"}]
}],
"generationConfig": {
"responseModalities": ["IMAGE"],
"imageConfig": {
"aspectRatio": "16:9"
}
}
}'
When provider: manual or API generation fails:
Prompt structure:
[Style description], [Main subject/concept], [Visual elements representing project],
[Color palette], [Composition notes], [Technical specs]
Negative prompt: [Elements to avoid]
Example prompt for a CLI tool:
Abstract geometric composition, terminal-inspired design with command line aesthetics,
interconnected nodes representing automation workflows, dark background with cyan and
magenta accent gradients, centered composition with depth layers, clean professional
tech aesthetic, 1280x640 pixels, high contrast, modern minimalist
Negative prompt: text, watermarks, realistic photos, cluttered, busy patterns
Include project name in prompt if include_text: true:
... with stylized text "PROJECT-NAME" integrated into design ...
For SVG output (always accompanied by JPG):
.github/social-preview.jpgFor AI-generated image output (PNG/JPG from DALL-E/Gemini):
Report success with:
If upload_to_repo: true is configured (or --upload flag provided):
Detect repository info:
git remote get-url origin to extract owner and repo namegit branch --show-currentPrepare upload (upload BOTH files):
Check for existing files:
Upload via GitHub MCP tool (both SVG and JPG):
# Upload JPG (for GitHub social preview)
owner: [detected owner]
repo: [detected repo]
path: .github/social-preview.jpg
content: [base64 encoded JPG]
message: "chore: update social preview image"
branch: [current or default branch]
sha: [existing file SHA if updating]
# Upload SVG (editable source)
owner: [detected owner]
repo: [detected repo]
path: .github/social-preview.svg
content: [base64 encoded SVG]
message: "chore: update social preview source SVG"
branch: [current or default branch]
sha: [existing file SHA if updating]
Report upload status:
Note: To set as actual social preview, users must:
.github/social-preview.jpg)DevTools/CLI:
AI/ML:
Web/Frontend:
Data/Analytics:
Security:
Infrastructure:
No README or project files found: Ask user to describe the project purpose, then proceed with that information.
API key not found (for dalle-3 or gemini): Fall back to SVG generation or prompt-only output with instructions.
Image generation fails:
SVG file too large (>100KB):
references/svg-templates.md - Complete SVG templates by domainreferences/prompt-patterns.md - Detailed prompt patterns by domainreferences/provider-apis.md - API documentation for supported providersexamples/config-svg.md - Example SVG configuration (default)examples/config-dalle.md - Example DALL-E configurationexamples/config-gemini.md - Example Gemini configuration