Generates and edits images via Gemini 3.1 Flash Image Preview. Handles text-to-image, image editing, multi-turn refinement, and batch generation.
Ships in designskills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Foundational skill for generating and editing images using Google's Gemini 3.1 Flash Image Preview model. All graphic design skills reference this skill for the generation pipeline.
pip install google-genai Pillow
export GEMINI_API_KEY="your-api-key"
Read .agents/design-context.md if it exists and pull the hex colors, style archetype, and typography description into the prompt. If it doesn't exist, use the design-context defaults and tell the user the output isn't brand-matched yet. If the user has a logo or product photo, pass it as an --image reference rather than describing it — the model reproduces references far more faithfully than descriptions.
| Mode | When to Use | Input |
|---|---|---|
| Text-to-Image | Creating from scratch — posters, graphics, illustrations | Text prompt only |
| Image Edit | Product shots, mockups, style transfer, adding elements | Image + text prompt |
| Multi-Turn | Iterative refinement, exploring variations | Chat session |
| Batch | High-volume asset generation (social sets, ad variants) | Multiple prompts via Batch API |
Every prompt should follow this hierarchy:
[FORMAT] + [SUBJECT] + [STYLE] + [COMPOSITION] + [COLOR] + [TYPOGRAPHY] + [MOOD] + [NEGATIVE]
Example — product social post:
Create a square social media graphic for a premium headphone launch. The headphones are centered on a deep navy (#0d1b2a) to electric blue (#00b4d8) diagonal gradient background. Bold white sans-serif text "HEAR EVERYTHING" spans the top third. Small coral (#ff6b6b) subtext "Available March 20" below. Subtle geometric triangles in the background at 10% opacity. Clean, modern, premium feel. No borders, no clip art.
| Style | Prompt Additions |
|---|---|
| Minimalist | "generous whitespace, single accent color, clean sans-serif, no decorative elements" |
| Bold/Vibrant | "saturated colors, large impactful typography, geometric shapes, high contrast" |
| Luxurious | "dark background, gold or champagne accents, serif typography, subtle texture, elegant" |
| Playful | "bright palette, rounded shapes, hand-drawn feel, casual handwriting font" |
| Corporate | "structured grid, professional, blue tones, clean hierarchy, balanced composition" |
| Retro | "halftone dots, muted vintage palette, serif headlines, film grain texture" |
| Brutalist | "raw, high contrast black and white, unconventional layout, oversized type" |
from google import genai
from google.genai import types
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.1-flash-image-preview",
contents="[your structured prompt]",
config=types.GenerateContentConfig(
response_modalities=["TEXT", "IMAGE"],
image_config=types.ImageConfig(aspect_ratio="1:1", image_size="2K"),
),
)
# A response can contain text parts and image parts in any order —
# never assume parts[0] is the image.
def save_first_image(response, path):
for part in response.parts or []:
if part.inline_data is not None:
part.as_image().save(path)
return True
print("No image returned:", response.text) # usually a refusal or clarifying question
return False
save_first_image(response, "output.png")
The core workflow: user provides a product photo, you generate a complete graphic around it.
from PIL import Image
product = Image.open("product.png")
response = client.models.generate_content(
model="gemini-3.1-flash-image-preview",
contents=[
product,
"Transform this product photo into a premium social media graphic. "
"Place the product on a gradient background (#1a1a2e to #16213e). "
"Add bold white headline 'JUST DROPPED' above. "
"Add price '$299' in coral (#e94560) below. "
"Modern, clean, high-end feel. Square format."
],
config=types.GenerateContentConfig(
response_modalities=["TEXT", "IMAGE"],
),
)
chat = client.chats.create(
model="gemini-3.1-flash-image-preview",
config=types.GenerateContentConfig(response_modalities=["TEXT", "IMAGE"]),
)
# Generate
r1 = chat.send_message([product_image, "Create a launch graphic for this product..."])
save_first_image(r1, "v1.png")
# Refine colors — change ONE thing per turn and say what to keep
r2 = chat.send_message("Keep the layout and text exactly as is. Make the background warmer, shift to sunset tones")
save_first_image(r2, "v2.png")
# Refine text
r3 = chat.send_message("Keep everything else. Make the headline larger and add a subtle drop shadow")
save_first_image(r3, "v3.png")
The skill ships its scripts in scripts/. Below, <image-generation> means this skill's directory (the base directory shown when the skill loads; skills/image-generation in a clone of the repo). Run them from the user's project so outputs land there.
# Text-to-image
python <image-generation>/scripts/gemini-generate.py --prompt "..." --output graphic.png
# Product image + prompt
python <image-generation>/scripts/gemini-generate.py --image product.png --prompt "..." --output graphic.png
# Multiple reference images (product + logo + style reference), up to 14
python <image-generation>/scripts/gemini-generate.py --image product.png --image logo.png --prompt "..." --output graphic.png
# Aspect ratio and resolution
python <image-generation>/scripts/gemini-generate.py --prompt "..." --aspect-ratio 4:5 --size 2K --output feed.png
# Exact pixel size: generate at the nearest supported ratio, then center-crop + resize
python <image-generation>/scripts/gemini-generate.py --prompt "..." --aspect-ratio 8:1 --resize 728x90 --output leaderboard.png
# Long prompts: keep them in a file
python <image-generation>/scripts/gemini-generate.py --prompt-file prompt.txt --aspect-ratio 16:9 --output hero.png
# Multi-turn (--then is repeatable; outputs default to v1_2.png, v1_3.png ...)
python <image-generation>/scripts/gemini-generate.py --prompt "Create a poster..." --output v1.png \
--then "Change to dark mode" --then "Make the date larger"
The script exits non-zero when no image comes back (refusal, safety block, or the model answered with text only) and prints the model's text — read it, adjust the prompt, and retry.
# Social set, ad set, or named presets; --focus keeps the subject in frame (x,y as 0-1)
python <image-generation>/scripts/export-sizes.py master.png --group social --out exports/
python <image-generation>/scripts/export-sizes.py master.png --presets og,youtube-thumbnail --focus 0.5,0.4 --out exports/
python <image-generation>/scripts/export-sizes.py master.png --size 300x250 --size 728x90 --out ads/
python <image-generation>/scripts/export-sizes.py --list # all presets and groups
It warns when a crop keeps under half of the master or has to upscale -- generate extreme ratios (8:1, 1:4) separately with the matching --aspect-ratio instead. Read a few exports to confirm nothing important was cropped.
Supported ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, 1:8, 8:1. Anything else (e.g. 300x250, 1200x628) must be generated at the nearest ratio and cropped with --resize.
| Use Case | Ratio | Final size | Notes |
|---|---|---|---|
| Instagram feed (portrait) | 4:5 | 1080x1350 | Best feed real estate; grid preview crops to 3:4 center |
| Instagram feed (square) | 1:1 | 1080x1080 | Keep text ~100px from edges |
| Instagram / TikTok Story, Reels | 9:16 | 1080x1920 | Keep text out of top ~250px and bottom ~340px (UI overlays) |
| X / Twitter post | 16:9 | 1600x900 | Text readable at small preview size |
| LinkedIn post | 1:1 or 4:5 | 1200x1200 / 1080x1350 | Link previews are ~1.91:1 (1200x627) — generate 16:9 + --resize |
| Facebook / Open Graph link image | 16:9 → crop | 1200x630 | Generate 16:9, --resize 1200x630 |
| Pinterest pin | 2:3 | 1000x1500 | Vertical, scroll-stopping |
| YouTube thumbnail | 16:9 | 1280x720 | High contrast, readable at 168x94px; avoid bottom-right (timestamp) |
| Web banner (leaderboard) | 8:1 | 728x90 | Minimal text, strong CTA |
| Medium rectangle ad | 5:4 → crop | 300x250 | --resize 300x250 |
| Poster / flyer | 2:3 or 3:4 | print size | See poster-design for bleed and DPI; 4K for print |
Never deliver an image you haven't viewed. Open every generated file (e.g. with the Read tool on the PNG) and inspect it at full size and at the size it will actually be seen (a thumbnail, a feed card).
Text is the most common failure. To reduce errors:
headline "HEAR EVERYTHING"Change "EVERYTHNG" to "EVERYTHING". Change nothing else.graphic-design).Before delivering any generated image:
If any check fails, use multi-turn refinement to fix specific issues — one change per turn, and say what must stay the same. Report to the user which checks you verified and any compromises (e.g. "text added as overlay because the model kept misspelling it").
Also mention that Gemini output carries an invisible SynthID watermark, so it can be identified as AI-generated.
| Feature | Gemini 3.1 Flash |
|---|---|
| Max input images | 14 (10 objects + 4 characters) |
| Output resolutions | 512, 1K, 2K, 4K |
| Aspect ratios | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, 1:8, 8:1 |
| Text rendering | Supported (specify explicitly in prompt) |
| Thinking mode | On by default, improves complex compositions |
| Batch API | Supported for high-volume generation |
| Watermark | SynthID automatically applied |
This skill is referenced by all graphic design skills:
graphic-design → primary generation pipelinesocial-media-graphic → platform-specific generationposter-design → poster/flyer generationthumbnail-design → thumbnail generationad-creative-design → ad variant generationproduct-mockup → product shot generationbanner-design → banner generationinfographic → infographic generationEach skill adds domain-specific prompt patterns on top of this foundational generation workflow.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
image-generation, text-to-image, gemini, ai-image, image-editing
/designskills:image-generationfrom designskills
npx claudepluginhub arnavpuri/designskills --plugin designskills28 skills in this plugin
/ad-creative-designPaid advertising creative: IAB display banners (300x250, 728x90, etc.), Google Display and Performance Max assets, and paid social ads (Meta, LinkedIn, X), via Gemini 3.1 Flash image generation, HTML/CSS, or HTML5 animated ads. Covers exact-size cropping, CTA design, value proposition hierarchy, A/B variations, and platform ad specs. Use whenever the creative will be bought as ad inventory; for organic posts use social-media-graphic, for on-site hero or email banners use banner-design. Trigger phrases: "design an ad", "create a banner ad", "display ad", "ad creative", "Google Display ad", "Meta ad", "ad banner", "create ad variations", "HTML5 ad".
/banner-designBanner graphics for owned channels: website hero/section banner images, email header images, event and conference banners, sidebar house promos, and announcement bars, via Gemini 3.1 Flash image generation (default) or HTML/CSS. Covers standard sizes, Gemini ratios and cropping, CTA placement, responsive art direction, and email constraints. For paid display/IAB ads use ad-creative-design; for a coded above-the-fold section use hero-section; for a full email template use email-design. Trigger phrases: "design a banner", "create a website banner", "hero banner image", "email header", "event banner", "promotional banner", "web banner", "sidebar banner", "announcement bar", "Eventbrite banner".
/brand-identityBuild a complete visual identity from scratch or refresh one: logo mark and variations (SVG), brand color roles, brand fonts, patterns, favicons/app icons, social avatars, and a brand guidelines page. Use when the user needs the brand itself, not just one ingredient. Trigger phrases: "brand identity", "logo design", "brand guidelines", "visual identity", "brand system", "favicon", "logo variations", "brand pattern", "rebrand". For only a palette use color-palette; only fonts use typography; UI tokens/components use design-system.
/card-designIndividual card components and card grids: anatomy, grid/masonry/carousel layouts, hover effects, and ready patterns for product, feature, testimonial, blog, expandable, and flippable cards plus skeleton loaders. Use when the user asks to "design a card", "build card layout", "create a product card", "make a card grid", "design a testimonial card", "blog post card", "feature card", "pricing card", or any card-based UI component. For the full page section around the cards use landing-page-design; for KPI/stat tiles use dashboard-design; for general components use ui-design.
/color-paletteGenerate accessible color palettes: OKLCH shade scales (50-950), tinted neutrals, semantic colors, WCAG contrast checks, dark-mode color remaps, gradients, and CSS/Tailwind color output. Use when the task is ONLY about color. Trigger phrases: "color palette", "color scheme", "generate colors", "shade scale", "color tokens", "color system", "accessible colors", "contrast ratio", "semantic colors", "palette from hex". For logo + fonts + guidelines use brand-identity; for full token/component systems (spacing, radius, components) use design-system; for complete dark themes use dark-mode.
/dark-modeDark theme design and implementation for web UIs: surface elevation, desaturated brand colors, text/border tokens, color-scheme, system-preference detection, a no-flash theme toggle, and Tailwind dark variants. Use when the user asks to "add dark mode", "create a dark theme", "dark mode support", "implement dark/light toggle", "theme switcher", "prefers-color-scheme", "design for dark background", "night mode", or any dark theme work. For dark mode in HTML email use email-design; for building the full color palette use color-palette.
Other plugins' skills for the same job