skills/nano-banana-image-gen/SKILL.md
Generate images with Google's Nano Banana family (Gemini 2.5 Flash Image, Nano Banana 2, Nano Banana Pro) using character and style references. Use when the user mentions "nano banana", "gemini image", any "gemini-*-image*" model id, character consistency for image generation, style transfer with Gemini, or multi-reference image composition. NOT for Ideogram (use existing Ideogram scripts), Qwen on Apple Silicon (see ~/.claude/QWEN_IMAGE_GUIDE.md), generic prompt engineering, or non-image Gemini calls.
npx skillsauth add curiositech/windags-skills nano-banana-image-genInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate editorial illustrations, marketing assets, and product mockups with Google's Gemini image-generation models, using character sheets and style templates as references.
✅ Use for:
gemini-2.5-flash-image, gemini-3.1-flash-image-preview, gemini-3-pro-image-preview❌ NOT for:
next-app/scripts/gen-*.py scripts and the IDEOGRAM_API_KEY pattern~/.claude/QWEN_IMAGE_GUIDE.md (use v0.6.0)computer-vision-pipeline)flowchart TD
S0[Request] --> S1{Need character<br/>or style consistency?}
S1 -->|No, simple scene| M25[Use gemini-2.5-flash-image]
S1 -->|Yes| MPRO[Use gemini-3-pro-image-preview]
M25 --> CFG
MPRO --> CFG[Set image_config.aspect_ratio<br/>response_modalities=IMAGE]
CFG --> REFS{How many<br/>references?}
REFS -->|0| P1[Prompt only]
REFS -->|1| P1
REFS -->|2+| P2[Label each ref's role<br/>character / style / lighting / etc]
P1 --> SCENE[Write scenario:<br/>Refs + Relationship + Scene]
P2 --> SCENE
SCENE --> POS[Use POSITIVE framing<br/>describe what SHOULD be there<br/>negatives do not work]
POS --> CALL[POST to generateContent]
CALL --> OUT{Image OK?}
OUT -->|Drift / wrong aspect| FIX[See troubleshooting.md]
OUT -->|Yes| DONE[Save + convert to webp]
FIX --> CALL
| Model ID | Marketing name | Status | Use when |
|---|---|---|---|
| gemini-3-pro-image-preview | Nano Banana Pro | Preview | Default for character/style work. Studio-quality, reliable text suppression, complex layouts. |
| gemini-3.1-flash-image-preview | Nano Banana 2 | Preview | High volume + extreme aspect ratios (1:4, 4:1, 1:8, 8:1). Up to 14 reference objects, 4 characters. |
| gemini-2.5-flash-image | Nano Banana | GA | Cheap/fast scratch generations. Simple non-character scenes. Avoid for editorial illustration with strict style adherence — it drifts. |
Full comparison: references/model-selection.md.
The aspect ratio MUST be set in the generation config. Putting "16:9" in the prompt does not work.
config = {
"responseModalities": ["IMAGE"],
"imageConfig": {"aspectRatio": "16:9"}, # ← non-negotiable
}
Supported ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9. Nano Banana 2 adds 1:4, 4:1, 1:8, 8:1.
Endpoint: POST https://generativelanguage.googleapis.com/v1beta/models/{MODEL}:generateContent with header x-goog-api-key: $GEMINI_API_KEY.
Reference images attach as inline-data parts in contents[0].parts:
parts = [
{"inlineData": {"mimeType": "image/png", "data": base64_of_char_sheet}},
{"inlineData": {"mimeType": "image/png", "data": base64_of_style_ref}},
{"text": prompt_with_role_labels},
]
A complete runnable example: scripts/generate.py.
[Reference images] + [Relationship instruction] + [New scenario]
The relationship instruction is the load-bearing piece — explicitly label what role each reference plays. Without role labels, the model partly absorbs and partly ignores the reference.
Worked example for an editorial hero illustration:
Reference image 1 is the CHARACTER SHEET — preserve the man's face,
build, hair, and teal hoodie exactly.
Reference image 2 is the STYLE TEMPLATE — match its graphic-novel rendering,
warm leather-and-amber palette, atmospheric lighting, and cinematic composition.
Generate a new scene where: [scene description].
Wide cinematic 16:9 framing, character occupies the left third.
Laptop screens display abstract glowing UI shapes with no readable typography,
indistinct soft-blurred interface.
Deep dive on the formula and more variants: references/prompt-formula.md.
Three techniques, in order of impact:
Details + edge cases: references/character-consistency.md.
For matching an existing visual style, attach two images with explicit roles:
Single-reference style transfer drifts. Dual-reference with role labels is the documented pattern. See references/style-references.md for the full pattern and when to use 3+ refs.
There is no negative prompt. Two things that work:
Novice: "I asked for a 16:9 wide editorial illustration in the prompt — Gemini gave me a square."
Expert: Aspect ratio belongs in generationConfig.imageConfig.aspectRatio, never in prompt text. The model ignores prompt-level dimensions. The default is square.
Timeline: This config field landed with the 2.5-flash-image GA release in late 2025. Earlier docs and tutorials often omit it; verify against the current docs.
Novice: "I attached the character sheet and asked for the same style — Gemini gave me 16-bit pixel art."
Expert: A single illustrated reference is ambiguous about role. The model treats it as a loose mood board and may hallucinate aesthetic interpretations that aren't in the source. Attach two references with explicit role labels (Reference 1 is the CHARACTER, Reference 2 is the STYLE TEMPLATE). Character fidelity and style fidelity are different jobs.
Timeline: This became necessary with the move from Imagen-style "one ref + style flag" pipelines (Ideogram V3) to Gemini's reference-as-context model. Pre-2026 patterns don't transfer.
Novice: "I added 'no text, no labels, no watermarks' but Gemini still wrote 'CONCERT TICKETS' across the screen." Expert: Gemini does not honor negative prompts the way Ideogram or Stable Diffusion do. Describe what should be there instead — abstract shapes, blurred interface, plain surface. Or upgrade to Nano Banana Pro, whose text architecture is precise enough to reliably not generate text on command. Timeline: This is a structural property of Gemini's image head, not a temporary limitation. It applies to all current models in the family.
gemini-2.5-flash-image for character workNovice: "I'll save money by using 2.5-flash for the editorial hero illustration." Expert: 2.5-flash is the weakest character-consistency model in the family and unreliable for strict style adherence. Pro is the right tool for character/style work; 2.5-flash is for cheap simple scenes. The cost difference is rarely worth the regeneration loop. Timeline: Pro became available (preview) in early 2026. Before that, the choice was between 2.5-flash and external tools like Ideogram.
Consult these for deep dives — they are NOT loaded by default:
| File | Consult When |
|------|-------------|
| references/model-selection.md | Choosing between 2.5-flash, 3.1-flash, and 3-pro for a given task |
| references/prompt-formula.md | Writing reference-grounded prompts, role-labeling patterns, edge cases |
| references/character-consistency.md | Multi-scene generation with the same character; iterative re-feeding |
| references/style-references.md | Style transfer pattern, dual-ref vs triple-ref, matching existing illustrated work |
| references/troubleshooting.md | Output is square, contains text, drifted style, ignored references |
| references/comparison-ideogram-qwen.md | When to use Nano Banana vs Ideogram V3 vs Qwen on M4 Max |
| scripts/generate.py | Runnable Python example with two refs + aspect ratio + role-labeled prompt |
When this skill is invoked inside the jbuds4life repo:
experiments/blog-image-styles/character-sheets/ (alex, jordan, marcus, mei, sofia — all *-v3-sheet.png)next-app/public/images/blog/*.webpnext-app/.env.local as GEMINI_API_KEYcwebp -q 85, then place at next-app/public/images/blog/{slug}-hero.webpog_image_url: /images/blog/{slug}-hero.webp is what's served as the OG imagedata-ai
license: Apache-2.0 NOT for unrelated tasks outside this domain.
development
Use when designing caching strategies (cache-aside, write-through, write-behind), implementing distributed locks, building rate limiters, leaderboards, real-time streams (XADD/consumer groups), pub/sub, or tuning eviction policies. Triggers: thundering-herd on cache miss, dogpile on key expiry, Redlock vs SET-NX-PX choice, sliding-window rate limiter, hot-key on a single cluster slot, big-key blowup, MULTI/EXEC across slots, KEYS in production. NOT for Redis Cluster operations/admin (different domain), embedded KV (SQLite, leveldb), in-process LRU caches, or Memcached.
tools
Drawing the `'use client'` boundary correctly in React Server Components apps (Next.js App Router, RSC frameworks) — leaf-pushing, slot composition, serialization rules, and environment poisoning prevention. Grounded in react.dev and Next.js 16 docs.
development
Use when designing rate limiting for an API, choosing between token bucket / sliding window / leaky bucket / fixed window, implementing it in Redis, deciding edge (Cloudflare/Upstash) vs origin enforcement, sizing per-user vs per-IP vs per-endpoint quotas, returning the right 429 response with Retry-After, or fixing the boundary-burst bug in fixed-window limiters. Triggers: 429 too many requests, INCR + EXPIRE, ZADD + ZREMRANGEBYSCORE + ZCARD, X-RateLimit-Remaining header, Cloudflare WAF rate limiting rules, Upstash @upstash/ratelimit, leaky bucket shaping vs policing, distributed rate limiter consistency. NOT for DDoS mitigation specifically (different scale), CAPTCHA / bot management, full WAF design, or per-user quota billing.