google-image-gen
npx skills add https://github.com/ypfaff/google-image-gen-skill --skill google-image-gen
Agent 安装分布
Skill 文档
Google Image Generation Skill
Generate images from text prompts using Google’s Gemini API.
First-Time Setup (Once Per Context)
Run these commands once at the start of a session:
.claude/skills/google-image-gen/scripts/check_env.sh
cd .claude/skills/google-image-gen && uv sync && cd -
If the environment check fails, the user needs to create .env in the skill directory with their API key from https://aistudio.google.com/apikey
Usage
Important: Run the script from the skill directory. Use ../../../ to save images to the project root.
cd .claude/skills/google-image-gen && uv run python main.py ../../../<output_path> "<prompt>" [options]
Project root path: ../../../ (relative to skill directory)
Note: If the user specifies a custom output path (e.g., images/photo.png), they likely mean relative to the project root. Always prepend ../../../ to such paths (e.g., ../../../images/photo.png).
Options
| Option | Short | Description |
|---|---|---|
--style |
-s |
Style template (.md file with {subject} placeholder) |
--ref |
-r |
Reference image for style (repeatable, max 14) |
--edit |
-e |
Edit existing image instead of generating |
--aspect |
-a |
Aspect ratio: 1:1, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
Examples
All examples assume you run from the skill directory (cd .claude/skills/google-image-gen).
Simple Generation (saves to project root)
cd .claude/skills/google-image-gen && uv run python main.py ../../../output.png "A red apple on a wooden table"
Save to subdirectory in project root
cd .claude/skills/google-image-gen && uv run python main.py ../../../images/output.png "A red apple"
With Aspect Ratio
cd .claude/skills/google-image-gen && uv run python main.py ../../../thumb.png "Mountain landscape" --aspect 16:9
Edit Existing Image
cd .claude/skills/google-image-gen && uv run python main.py ../../../output.png "Change the sky to sunset" --edit ../../../input.png
With Reference Image
cd .claude/skills/google-image-gen && uv run python main.py ../../../output.png "Same style but with a car" --ref ../../../reference.png
Multiple Variations
Generates numbered outputs (output_1.png, output_2.png, etc.):
cd .claude/skills/google-image-gen && uv run python main.py ../../../output.png "cat" "dog" "bird"
Workflow
- First use in context: Run setup commands (check_env.sh + uv sync)
- Generate images as needed
- Report output paths to user
Notes
- Paid API tier recommended (free tier has strict rate limits)
- Output directories are created automatically
- Default aspect ratio is 16:9