---
name: image-gen
description: Generate character art and image variations using AI image generation (Google Gemini) with reference images for style and character consistency. Use this skill when the user asks to generate new character poses, mascot variations, art assets, illustrations, or any AI-generated images — especially when maintaining consistency with an existing character or style.
user_invocable: true
title: image-gen
canonical_url: https://skilld.dev/gh/peterkrueck/claude-code-development-kit/image-gen
last_updated: 2026-10-01T00:04:23.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [scripts/generate.ts](https://skilld.dev/api/skills-raw/peterkrueck/claude-code-development-kit/image-gen/scripts/generate.ts).
>
> If the user asked to install this Skill, run `npx skilld install peterkrueck/claude-code-development-kit/image-gen`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/image-gen`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/peterkrueck/claude-code-development-kit/image-gen) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/image-gen`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/image-gen --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/image-gen --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# AI Image Generation (Gemini)

Generate image variations using Google's Gemini image generation model with reference images for style and character consistency. The model supports up to 14 reference images per request and can maintain consistency across multiple characters.

## Prerequisites

- **GEMINI_API_KEY** environment variable must be set
  - Get a key at https://aistudio.google.com/apikey
  - The key needs billing enabled for image generation (~$0.067/image at 1K resolution)
- **Deno** runtime installed (for the generation script)

## Workflow

### Step 1 — Understand what the user wants

Clarify the subject, pose, expression, context, and where the asset will be used (app screen, social media, website, etc.). This context helps craft the right prompt and choose the right aspect ratio.

### Step 2 — Select reference images

Always use **1-2 reference images** for consistency:

1. **Primary reference (always first):** The most canonical image of the character/subject. This anchors identity — face shape, color palette, defining features.

2. **Style/pose reference (second, optional):** Pick the closest existing approved asset to the target pose. This anchors proportions and art style.

The primary reference anchors identity; the style reference anchors proportions. Both together produce the most consistent results.

### Step 3 — Craft the prompt

Write a detailed prompt that describes the exact pose, expression, and style:

1. **Character/subject description** — physical traits that define the character (so the model doesn't drift)
2. **Pose and expression** — what the character is doing
3. **Style directives** — art style, line style, shading approach
4. **Background** — color, scene, or transparent
5. **Framing** — full body, bust, three-quarter view, etc.

**Prompt template:**
```
[CHARACTER_DESCRIPTION]. [POSE_AND_EXPRESSION]. [STYLE_DIRECTIVES]. [BACKGROUND]. [VIEW/FRAMING].
```

**Tips:**
- Be specific about what each hand/arm is doing — vague descriptions lead to random poses
- Always specify the background explicitly
- Include style keywords consistently (e.g., "flat color fills", "3D render", "watercolor")

### Step 4 — Generate variations

Run the bundled generation script:

```bash
deno run --allow-env --allow-read --allow-write --allow-net \
  .claude/skills/image-gen/scripts/generate.ts \
  --prompt "your prompt here" \
  --ref path/to/primary-reference.png \
  --ref path/to/style-reference.png \
  --output-dir /tmp/image-gen \
  --variants 4 \
  --aspect "<choose based on use case>" \
  --size "2K"
```

**Parameters:**
| Flag | Default | Options |
|------|---------|---------|
| `--variants` | 4 | 1-8 (each is a separate API call) |
| `--aspect` | 1:1 | 1:1, 3:4, 4:3, 9:16, 16:9, 2:3, 3:2 |
| `--size` | 1K | 512, 1K, 2K, 4K |

**Always default to `2K` for size** — higher resolution gives better quality and can always be downscaled.

**Choose aspect ratio based on use case:**
| Use Case | Aspect Ratio |
|----------|-------------|
| Full-body character poses | `3:4` |
| App icons, avatars, social profiles | `1:1` |
| Mobile screens, in-app cards | `9:16` or `3:4` |
| Banner/header images, OG images | `16:9` or `4:3` |
| Bust/upper-body portraits | `1:1` or `4:3` |

**Cost:** ~$0.10/image at 2K = ~$0.40 for 4 variants.

### Step 5 — Pick the best variant

Use the Read tool to visually inspect all generated images. Score each on:

**Consistency (most important):**
- Does it match the reference images — face, proportions, colors, style?
- Is the art style consistent (not drifting to photorealistic, 3D, etc.)?

**Quality (tiebreaker):**
- Does the image have personality and visual appeal?
- Would this work well as a production asset?

**Pick the single best variant** and copy it to the project's assets directory with a descriptive name. Briefly explain why you picked it.

If none are good enough, explain what went wrong and offer to regenerate with prompt adjustments.

### Step 6 — Post-process

After picking the best variant:
- Copy the chosen file to the appropriate assets directory
- Clean up: delete the rejected variants and the temp output directory
- Use the **image-edit** skill if the user needs a different crop or size

## Rate Limits

If some variants fail with 429 errors: wait 60 seconds, then rerun with only the missing number of variants. Don't retry all — just fill in the gaps.

If all fail with 429: wait 60 seconds and try again. If it keeps failing, the daily quota may be exhausted — try later or enable billing for higher limits.

## Troubleshooting

- **"GEMINI_API_KEY not set"** — Get a key at https://aistudio.google.com/apikey
- **"Billing not enabled" or 403** — Enable billing in Google AI Studio for image generation
- **429 rate limit** — Wait 60 seconds and retry
- **Character looks wrong** — Be more specific about physical traits, ensure both reference images are included
- **Style drifted** — Reinforce style keywords more strongly in the prompt
- **Pose is wrong** — Be extremely specific about what each arm/hand is doing
