# Gemini Image

> Use when the user requests image generation, illustration, icon, logo, photo, visual content creation, or image editing - any task requiring AI-generated or AI-edited images

- Skill: `kosthi/gemini-image` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add kosthi/gemini-image`
- Raw SKILL.md: https://api.skillmd.com/api/skills/kosthi/gemini-image/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Design & Media
- Author: kosthi (https://skillmd.com/u/kosthi)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/kosthi/gemini-image

---


# Gemini Image Generation Skill

You generate images by calling Gemini CLI with the **nanobanana** extension. Follow these rules precisely.

## Model Selection

| Condition | Model | How |
|-----------|-------|-----|
| Default / `/gemini-image` / `/gemini-image quick` | `gemini-2.5-flash-image` | No extra env var needed (nanobanana default) |
| `/gemini-image hq` or user says "high quality", "4K", "professional", "detailed", "best quality" | `gemini-3-pro-image-preview` | Prepend `NANOBANANA_MODEL=gemini-3-pro-image-preview` to the command |

## Nanobanana Commands

Nanobanana provides these slash commands inside the Gemini CLI prompt:

| Command | Use Case |
|---------|----------|
| `/generate "prompt"` | Text-to-image generation |
| `/edit file.png "instructions"` | Modify existing image |
| `/restore file.png "instructions"` | Repair/enhance old photos |
| `/icon "prompt" --sizes="64,128,256"` | App icons, favicons |
| `/pattern "prompt" --type=seamless` | Seamless patterns/textures |
| `/story "prompt" --steps=4` | Sequential narrative images |
| `/diagram "prompt" --type=flowchart` | Technical diagrams |

## File Output

Nanobanana saves images to `nanobanana-output/` in the current working directory with auto-generated filenames. After generation, rename the file to match our naming convention:

Format: `{subject}-{style}-{timestamp}.png`

- **subject**: 1-5 word kebab-case description (e.g. `orange-cat`, `tech-logo`)
- **style**: abbreviated style tag:
  - `photo` — realistic photograph
  - `illus` — illustration / digital art
  - `logo` — logo / icon design
  - `pixel` — pixel art
  - `water` — watercolor
  - `flat` — flat design / vector style
  - `3d` — 3D render
  - `sketch` — pencil / line sketch
  - `anime` — anime / manga style
  - `abstract` — abstract art
- **timestamp**: `YYYYMMDDHHMMSS` format

Example: `orange-cat-water-20260219150030.png`

When retrying or iterating on the same image, reuse the same filename to overwrite.

## Generating an Image

1. Read `references/prompt-guide.md` from the skill directory for prompt engineering guidance.

2. Craft an effective English prompt based on the user's request and the prompt guide. Even if the user writes in another language, the prompt sent to Gemini must be in English.

3. Get the current timestamp for the output filename:
   ```bash
   date +%Y%m%d%H%M%S
   ```

4. Run the generation command (timeout 180s):
   ```bash
   # Default (quick) mode:
   gemini -e nanobanana -p '/generate "<english_prompt>"' --yolo --sandbox false

   # HQ mode:
   NANOBANANA_MODEL=gemini-3-pro-image-preview gemini -e nanobanana -p '/generate "<english_prompt>"' --yolo --sandbox false
   ```

5. Find and verify the output:
   ```bash
   ls -lt nanobanana-output/*.png | head -1
   file nanobanana-output/<filename>.png
   ```

6. Rename to our naming convention:
   ```bash
   mv nanobanana-output/<generated_name>.png nanobanana-output/<subject>-<style>-<timestamp>.png
   ```

7. Report the result to the user: show the image using Read tool, confirm the file path, and briefly describe what was generated.

## Editing an Existing Image

When the user wants to modify an existing image:

1. Confirm the source image path exists. If the image is not in `nanobanana-output/`, copy it there first.

2. Run the edit command (timeout 180s):
   ```bash
   gemini -e nanobanana -p '/edit <filename_in_nanobanana_output> "<edit_instructions>"' --yolo --sandbox false
   ```

3. Verify, rename, and report as above.

## Specialized Commands

### Icons
```bash
gemini -e nanobanana -p '/icon "<description>" --sizes="64,128,256" --type=app-icon --style=modern' --yolo --sandbox false
```

### Patterns
```bash
gemini -e nanobanana -p '/pattern "<description>" --type=seamless --style=geometric' --yolo --sandbox false
```

### Diagrams
```bash
gemini -e nanobanana -p '/diagram "<description>" --type=flowchart --complexity=detailed' --yolo --sandbox false
```

## Error Handling

- If Gemini returns a safety filter error, inform the user and suggest rephrasing.
- If the model is unavailable, fall back to the other model and retry once.
- If the first `generate_image` call fails, nanobanana typically retries automatically. If it still fails, retry the entire command once.
- If the command times out, inform the user and suggest simplifying the prompt.
- If no output file appears in `nanobanana-output/`, check for error messages in stderr.

## Important Notes

- Always use `-e nanobanana` to load the extension.
- Always use `--yolo` flag — required for headless auto-approval of tool calls.
- Always use `--sandbox false` — ensures Gemini can write to the working directory.
- Nanobanana calls the Gemini image API directly via its MCP server — it does NOT use Gemini CLI's built-in `write_file`.
- The `NANOBANANA_GEMINI_API_KEY` env var must be set for the extension to work.

