A cross-runtime image skill for Claude Code and GitHub Copilot CLI that uses the bundled GPT Image CLI as the default path, with an explicit Codex mode when the user asks for it.
- CLI-first generation - Use the bundled
scripts/image_gen.pyby default for generation and editing - Explicit Codex mode - Use Codex's built-in image workflow only when the user explicitly wants Codex/native generation
- Image editing - Support direct edits, reference-guided generation, and compositing flows
- Batch generation in CLI mode - Use
generate-batchfor many prompts in the default CLI workflow - Shared prompting system - Reuse the same prompt structure across both modes
| Mode | When to use | Backend | Needs OPENAI_API_KEY |
|---|---|---|---|
| Explicit CLI (default) | Normal generation/edit requests unless the user explicitly asks for Codex/native generation | scripts/image_gen.py |
Yes |
| Codex mode | User explicitly asks for Codex, native generation, or Codex CLI | codex exec -> Codex built-in image workflow |
No |
- Python environment with the bundled script available
- OpenAI Python package
OPENAI_API_KEYexported locally
Install dependencies if needed:
pip install openai # or use uv pip install openai
pip install pillow # optional, for downscaling only- Codex CLI installed via
npm i -g @openai/codex - Codex authenticated via
codex login - This skill available to Claude/Copilot in the runtime's custom skill path
Quick checks:
codex --help
codex exec --helpCopy this directory into your Claude skills directory:
mkdir -p ~/.claude/skills/gpt-image
cp -R /path/to/gpt-image/. ~/.claude/skills/gpt-image/Keep the gpt-image folder in the location your Copilot-style runtime exposes through the skill tool. The exact path depends on the host integration, but the folder must include:
SKILL.mdREADME.mdreferences/scripts/image_gen.py
Unless the user explicitly asks for Codex/native generation, use the bundled CLI directly.
Set stable paths:
export GPT_IMAGE_SKILL="/absolute/path/to/gpt-image"
export IMAGE_GEN="$GPT_IMAGE_SKILL/scripts/image_gen.py"Generate:
python "$IMAGE_GEN" generate \
--prompt "A minimal modern blog header about AI agents" \
--size 1536x1024 \
--out output/gpt-image/blog-header.pngEdit:
python "$IMAGE_GEN" edit \
--image input.png \
--prompt "Replace only the background with a soft blue gradient; keep the subject unchanged" \
--out output/gpt-image/input-edited.pngBatch:
python "$IMAGE_GEN" generate-batch \
--input tmp/gpt-image/prompts.jsonl \
--out-dir output/gpt-image/batchAsk for missing parameters before running. At minimum, do not silently assume model, size, quality, text inclusion/exact copy, or edit fidelity/mask behavior unless the user explicitly says to use defaults.
Use this only when the user explicitly asks for:
- Codex mode
- native generation
- Codex CLI
- Codex's built-in image workflow
Recommended pattern:
codex exec -C "$PWD" --skip-git-repo-check \
"Generate a blog header image for a post about AI agents. Save the selected final to output/gpt-image/blog-header.png and report the final path. Use Codex's built-in image workflow, not scripts/image_gen.py."For local edit targets or reference images, attach files with -i:
codex exec -C "$PWD" --skip-git-repo-check -i input.png -i style-ref.png \
"Image 1 is the edit target. Image 2 is a style reference. Replace only the background, keep the subject unchanged, and save the final to output/gpt-image/input-edited.png."Notes:
- Use
-C "$PWD"so Codex works in the current workspace. - Add
--skip-git-repo-checkwhen you are outside a Git repo. - Ask Codex to move or copy the selected final into your workspace if the image is project-bound.
- Codex may first write images under
$CODEX_HOME/generated_images/...; do not leave project assets there permanently.
Once installed, the skill should activate for requests like:
- "Make me a blog header"
- "Create a product mockup for this bottle"
- "Edit this image to remove the background"
- "Generate three visual directions for a landing-page hero"
- "Use CLI mode and make a transparent PNG"
- Default to explicit CLI mode.
- Switch to Codex mode only after explicit user opt-in.
- Never ask the user to paste API keys into chat.
- Ask about missing image parameters before execution, unless the user explicitly says to use defaults.
- For project assets, save finals under
output/gpt-image/.
For non-trivial requests, use a short labeled spec:
Use case: <taxonomy slug>
Asset type: <where the image will be used>
Primary request: <main instruction>
Input images: <Image 1: role; Image 2: role> (optional)
Scene/backdrop: <environment>
Subject: <main subject>
Style/medium: <photo/illustration/3D/etc.>
Composition/framing: <wide/close/top-down; placement>
Lighting/mood: <lighting + mood>
Color palette: <palette notes>
Materials/textures: <surface details>
Text (verbatim): "<exact text>"
Constraints: <must keep / must avoid>
Avoid: <negative constraints>
See:
references/prompting.mdreferences/sample-prompts.md
- Finals:
output/gpt-image/ - Temporary scratch files:
tmp/gpt-image/
- Codex may initially save images under
$CODEX_HOME/generated_images/... - Move or copy selected finals into the workspace before finishing
- Prefer
output/gpt-image/for project assets
| Problem | What to do |
|---|---|
codex not found |
Install Codex CLI and verify codex --help works |
| Codex not authenticated | Run codex login |
OPENAI_API_KEY missing |
Export it locally in your shell, not in chat |
Use OPENAI_BASE_URL to choice third part api provider |
Export it locally in your shell, not in chat |
openai package missing |
Run uv pip install openai |
| Missing model / size / quality / text settings | Ask the user before running, or use defaults only if they explicitly allow it |
Need masks / quality / input_fidelity / background control |
Use explicit CLI mode |
| Need a predictable workspace output path in Codex mode | Tell Codex to save the selected final into output/gpt-image/ |
SKILL.md- runtime-facing instructions for CLI-first mode selection and Codex opt-inreferences/prompting.md- shared prompting guidancereferences/sample-prompts.md- copy/paste prompt recipesreferences/cli.md- default CLI usagereferences/image-api.md- explicit CLI/API parameter referencescripts/image_gen.py- bundled CLI implementation