Help us improve
Share bugs, ideas, or general feedback.
From handbook-nano-banana
Generates images and AI art using Gemini API via inline Python scripts run with uv. Handles image editing, quick scripting, and one-off Python tasks without files.
npx claudepluginhub nikiforovall/claude-code-rules --plugin handbook-nano-bananaHow this skill is triggered — by the user, by Claude, or both
Slash command
/handbook-nano-banana:nano-bananaThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Python scripting with Gemini image generation using uv. Write small, focused scripts using heredocs for quick tasks—no files needed for one-off operations.
Generates or edits images using Google Gemini API via nanobanana.py Python script. Supports prompts, aspect ratios like 9:16, models such as gemini-3.1-flash, and resolutions up to 4K.
Generates or edits images using Google Gemini API via nanobanana Python script. Supports prompts, aspect ratios, resolutions up to 4K, models like gemini-3.1-flash-image-preview, and image inputs for editing.
Generates or edits images via Google Gemini from text prompts or up to 14 reference images for text-to-image and multi-image editing.
Share bugs, ideas, or general feedback.
Python scripting with Gemini image generation using uv. Write small, focused scripts using heredocs for quick tasks—no files needed for one-off operations.
Quick image generation: Use heredoc with inline Python for one-off image requests.
Complex workflows: When multiple steps are needed (generate -> refine -> save), break into separate scripts and iterate.
Scripting tasks: For non-image Python tasks, use the same heredoc pattern with uv run.
Execute Python inline using heredocs with inline script metadata for dependencies:
uv run - << 'EOF'
# /// script
# dependencies = ["google-genai", "pillow"]
# ///
from google import genai
from google.genai import types
client = genai.Client()
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents=["A cute banana character with sunglasses"],
config=types.GenerateContentConfig(
response_modalities=['IMAGE']
)
)
for part in response.parts:
if part.inline_data is not None:
image = part.as_image()
image.save("tmp/generated.png")
print("Image saved to tmp/generated.png")
EOF
The # /// script block declares dependencies inline using TOML syntax. This makes scripts self-contained and reproducible.
Why these dependencies:
google-genai - Gemini API clientpillow - Required for .as_image() method (converts base64 to PIL Image) and saving imagesOnly write to files when:
uv run - << 'EOF'
# /// script
# dependencies = ["google-genai", "pillow"]
# ///
from google import genai
from google.genai import types
client = genai.Client()
# Generate image
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents=["YOUR PROMPT HERE"],
config=types.GenerateContentConfig(
response_modalities=['IMAGE']
)
)
# Save result
for part in response.parts:
if part.text is not None:
print(part.text)
elif part.inline_data is not None:
image = part.as_image()
image.save("tmp/output.png")
print("Saved: tmp/output.png")
EOF
Follow this pattern for complex tasks:
Configure aspect ratio and resolution:
config=types.GenerateContentConfig(
response_modalities=['IMAGE'],
image_config=types.ImageConfig(
aspect_ratio="16:9", # "1:1", "16:9", "9:16", "4:3", "3:4"
image_size="2K" # "1K", "2K", "4K" (uppercase required)
)
)
gemini-3-pro-image-preview - Fast, general purpose image generationgemini-3-pro-image-preview - Advanced, professional asset production (Nano Banana Pro)Default to gemini-3-pro-image-preview (Nano Banana Pro) for all image generation unless:
Nano Banana Pro provides higher quality results and should be the recommended choice.
To receive both text explanation and image:
config=types.GenerateContentConfig(
response_modalities=['TEXT', 'IMAGE']
)
Edit existing images by including them in the request:
uv run - << 'EOF'
# /// script
# dependencies = ["google-genai", "pillow"]
# ///
from google import genai
from google.genai import types
from PIL import Image
client = genai.Client()
# Load existing image
img = Image.open("input.png")
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents=[
"Add a party hat to this character",
img
],
config=types.GenerateContentConfig(
response_modalities=['IMAGE']
)
)
for part in response.parts:
if part.inline_data is not None:
part.as_image().save("tmp/edited.png")
print("Saved: tmp/edited.png")
EOF
If a script fails:
For complex workflows including thinking process, Google Search grounding, multi-turn conversations, and professional asset production, load references/guide.md.