codex-imagegen
Skill1 starsChanged 3 months agoMITView on GitHub
Generate or edit raster images using Codex and its built-in imagegen capability. Use when the user asks to create, generate, draw, render, visualize, or edit an image, illustration, photo, texture, mockup, game asset, icon, or other bitmap asset.
- Reads credentials
7 other projects use a version of this.
Adopted by
Most recently taken up by
- mgiovani/cc-arsenaltheir own version, first seen Sep 25, 2026
- JunSeo99/claude-skill-codex-imagegentheir own version, first seen Sep 10, 2026
- hyperb1iss/hyperskillstheir own version, first seen Sep 5, 2026
- gongnyang/codex-fleettheir own version, first seen Jul 2, 2026
- luminary19/ateliertheir own version, first seen Jun 27, 2026
- zigzag-tech/codex-tui-imagegentheir own version, first seen Jun 25, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- gongnyang/codex-fleet★ 46same name
- hyperb1iss/hyperskills★ 35same name
- nathanonn/agent-skills★ 19same name
- JunSeo99/claude-skill-codex-imagegen★ 13same name
- mgiovani/cc-arsenal★ 8same name
- luminary19/atelier★ 2same name
- zigzag-tech/codex-tui-imagegen★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
Show its rules and text
We split this skill into the rules it gives an agent
25 rules. 0 are common, 13 are distinctive, and 12 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
13
Distinctive
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Do not generate SVG, HTML, CSS, or placeholder artwork instead of an actual raster image.
- Distinctive: line 18
Before doing anything else, confirm that Codex is available and how it is authenticated:
- Very specific: line 24
If codex is not found, stop and tell the user the Codex CLI is not installed.
- Very specific: line 26
If it reports API-key authentication instead, stop and ask the user before continuing.
- Very specific: line 31
Use Codex's built-in $imagegen skill, which drives the built-in image_gen tool.
- Very specific: line 33
Do NOT use OPENAI_API_KEY, and do NOT use the scripts/image_gen.py CLI fallback that Codex's own skill offers as a secondary path.
- Distinctive: line 35
Verify every path yourself: reference images before attaching them, and the delivered file after generation.
- Distinctive: line 41
If the user explicitly specifies an output path or filename, use it, and preserve a supplied filename when practical.
- Distinctive: line 52
Do not create a new top-level directory unless necessary.
- Distinctive: line 56
Do not ask the user to choose an output directory when the project structure provides enough context to decide.
- Distinctive: line 67
Create the parent directory.
- Very specific: line 68
If something is already at that path, do not overwrite it unless the user asked for replacement.
- Very specific: line 69
Make sure Codex can write there.
- Distinctive: line 91
Always pass the prompt through a quoted here-document:
- Very specific: line 122
Add -o <FILE> to capture Codex's final message.
- Very specific: line 123
If Codex fails with an unexpected-argument error, check codex exec --help rather than falling back to an API-key path.
- Very specific: line 128
Do NOT use -i <FILE> or --image <FILE> with a space.
- Very specific: line 143
Prefer --add-dir when the project should stay the working root.
- Distinctive: line 196
If the user requests an edit to an existing image:
- Distinctive: line 239
Do not rely on Codex's textual confirmation.
- Distinctive: line 251
If the expected file does not exist, or fails any check above:
- Very specific: line 253
Read the final message you captured with -o — Codex reports the path it actually wrote.
- Very specific: line 263
If Codex reports that its built-in image_gen capability is unavailable:
- Distinctive: line 265
do not silently switch to an API-key path
- Distinctive: line 267
do not charge API usage without explicit user approval
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Image Generation via Codex
Generate or edit images by delegating the task to the locally authenticated Codex CLI.
Do not generate SVG, HTML, CSS, or placeholder artwork instead of an actual raster image.
This skill runs entirely through Bash by design. Inspect the project with ls and find rather than reaching for file-reading tools.
Prerequisites
Before doing anything else, confirm that Codex is available and how it is authenticated:
command -v codex && codex --version && codex login status- If
codexis not found, stop and tell the user the Codex CLI is not installed. Do not fall back to an API-key path or to generating SVG/HTML. codex login statusmust reportLogged in using ChatGPT. That is the subscription-backed path this skill is built around.- If it reports API-key authentication instead, stop and ask the user before continuing. Generating in that mode bills their API account. Do not proceed on your own judgement, and never run
codex login --with-api-keyfor them. - The flag syntax below was verified against codex-cli 0.150.1. On any other version, check
codex exec --helpbefore invoking rather than assuming it still applies.
Non-negotiables
- Use Codex's built-in
$imagegenskill, which drives the built-inimage_gentool. - Stay on the subscription-backed built-in path, confirmed by
codex login status. - Do NOT use
OPENAI_API_KEY, and do NOT use thescripts/image_gen.pyCLI fallback that Codex's own skill offers as a secondary path. That fallback is wheregpt-image-2andgpt-image-1.5live; both are out of scope here. - One requested asset means one Codex call. For several distinct images, issue a separate call per image rather than asking for variants of a single prompt.
- Verify every path yourself: reference images before attaching them, and the delivered file after generation. See Validation.
Output path
This skill has no fixed destination convention: choose the location from the project structure, the image's intended use, and the user's request. (Codex itself does have a default staging directory — see Where Codex actually saves the image below.)
If the user explicitly specifies an output path or filename, use it, and preserve a supplied filename when practical.
Otherwise, before generating:
- Inspect the current working directory and relevant project structure.
- Reuse an existing appropriate directory when one exists — for example
assets/,assets/images/,public/,public/images/,src/assets/,images/,docs/images/, oroutput/. - Match the image's intended use to the project's existing conventions:
- application assets go with existing application assets
- web-served images go in the project's existing public or static asset location
- documentation images go near existing documentation assets
- generated deliverables follow the project's existing output convention
- Do not create a new top-level directory unless necessary.
- For temporary or exploratory generations with no obvious destination, pick a reasonable project-local temporary location without establishing a permanent convention.
- Choose a short, descriptive filename when the user does not provide one.
Do not ask the user to choose an output directory when the project structure provides enough context to decide.
Destination preflight
Once the path is chosen, and before invoking Codex:
mkdir -p "$(dirname "<OUTPUT_PATH>")"
test -e "<OUTPUT_PATH>" && echo "EXISTS: <OUTPUT_PATH>"- Create the parent directory. Codex will not create it for you.
- If something is already at that path, do not overwrite it unless the user asked for replacement. Pick a sibling versioned name instead, such as
hero-v2.pngoritem-icon-edited.png. - Make sure Codex can write there. Under
-s workspace-writeonly the working root is writable; see Working root below for destinations outside it.
Where Codex actually saves the image
The built-in image_gen tool does not take a destination argument. Codex saves what it generates under $CODEX_HOME/generated_images/..., where $CODEX_HOME defaults to ~/.codex.
So do not ask for an output path parameter. Instruct Codex to generate first and then move or copy the selected output to the path you chose. An image left only under $CODEX_HOME has not been delivered.
Generation workflow
Determine from the request:
- what image should be generated
- its intended use
- aspect ratio or dimensions, if specified
- whether transparency is requested
- desired filename and output path, if specified
- any reference images supplied by the user
- how many distinct images are wanted
Inspect the project structure, choose and preflight the destination, then delegate the generation to Codex.
Always pass the prompt through a quoted here-document:
codex exec -s workspace-write --skip-git-repo-check "$(cat <<'CODEX_PROMPT'
<PROMPT>
CODEX_PROMPT
)"The quoted <<'CODEX_PROMPT' delimiter is mandatory:
- A double-quoted prompt makes the shell expand
$imagegento an empty string, silently deleting the single most important instruction in the prompt. - A single-quoted prompt breaks apart as soon as the request contains an apostrophe (
a cat's toy,don't).
A quoted here-document is literal, so both survive intact. Do not use "..." or '...' for the prompt, even for short requests.
Image generation can take minutes. If your harness imposes a command timeout, raise it to at least 10 minutes for this call — in Claude Code, set the Bash tool's timeout to 600000 ms. A timeout is not a generation failure: check the intended output path before reporting anything to the user.
A stalled invocation looks nothing like a slow one. If the call is still running well past the timeout, check whether Codex ever started:
ls -t "${CODEX_HOME:-$HOME/.codex}"/sessions/*/*/*/*.jsonl 2>/dev/null | head -3If no session was written for this run — and neither the output file nor the -o message file exists — Codex never got as far as recording the prompt. That is a stuck process, not a long generation. Stop it, then report. Do not re-run blindly: a second invocation can hit the same block and bills again. Look for other codex processes and for stale locks under ${CODEX_HOME:-$HOME/.codex}/thread-writer-locks/, which Codex leaves behind when an earlier run is killed mid-flight.
Flag notes
--full-autowas removed. Use-s workspace-writeinstead.--approve-for-mecannot be combined with-s:error: the argument '--approve-for-me' cannot be used with '--sandbox <SANDBOX_MODE>'. This workflow does not need it — omit it. (Appending--helphides the conflict, so check with a real invocation.)--skip-git-repo-checkis required outside a Git repository, and harmless inside one.- Add
-o <FILE>to capture Codex's final message. Read it afterwards to recover the path Codex reports, instead of parsing the transcript. - If Codex fails with an unexpected-argument error, check
codex exec --helprather than falling back to an API-key path.
Reference images
- Give each file its own
--image=<FILE>, and quote the value:--image="./My Assets/ref.png". Do NOT use
-i <FILE>or--image <FILE>with a space. They are the same variadic option, and it greedily eats every bare token that follows — including your prompt. Only the=form leaves the prompt its own slot:$ codex debug prompt-input --image=/tmp/a.png ONE TWO error: unexpected argument 'TWO' found # one positional slot left, as intended $ codex debug prompt-input --image /tmp/a.png ONE TWO (accepted — ONE and TWO were both swallowed as image paths)- Check every file with
test -fbefore attaching it. Do not rely on Codex to reject a missing attachment: on 0.150.1 a nonexistent--image=path was observed to run to completion with no warning and no error, so a mistyped path yields an image generated without the reference while still looking like a success. - Attaching a file is not enough: the prompt must say what each one is for (style reference, composition reference, the subject to preserve).
Working root
-s workspace-writemakes only the working root writable. If the destination is outside it, pass--add-dir "<DIR>"to add that directory without moving the root.- Use
-C <DIR>only when Codex should run as if from another directory. Whenever you pass-C, resolve every path to an absolute one first — the destination, and each--image=attachment. Relative paths resolve against<DIR>for Codex but against your own directory for your checks, so the two disagree and a successful generation looks like a failure. - Prefer
--add-dirwhen the project should stay the working root; prefer-Cfor scratch work wholly outside the project.
Prompt contents
The prompt sent to Codex MUST explicitly instruct it to use $imagegen, MUST name the exact destination path, and MUST tell Codex to move or copy the generated image there.
If the user asked for a transparent background or a clean cutout, say so in the prompt, ask for actual transparency from the built-in image_gen tool, and require that the alpha channel be preserved when the file is written. Codex treats transparency as a distinct request — leave it out and you get an opaque background that merely looks light.
Example
codex exec -s workspace-write --skip-git-repo-check \
-o /tmp/codex-last-message.txt \
--image="./refs/style.png" --image="./refs/palette.png" \
"$(cat <<'CODEX_PROMPT'
Use the built-in $imagegen skill to generate the requested raster image.
IMPORTANT:
- Use the built-in `image_gen` tool.
- Do not use OPENAI_API_KEY.
- Do not use the `scripts/image_gen.py` CLI fallback.
- Generate the actual image rather than describing it.
- The built-in tool saves under $CODEX_HOME. After generating, move or copy the
selected image to the destination below, and report that final path.
Destination:
./assets/images/feature-card.png
Attached references, in the order given:
1. style.png — match its rendering style, lighting and texture.
2. palette.png — take colors from it only. Ignore its composition.
Image request:
A wide product card showing a single espresso cup on a matte surface,
2:1, no text.
CODEX_PROMPT
)"With no reference images, drop the --image= arguments and the "Attached references" block; everything else stays. The paths above are examples only — do not assume ./refs/ or ./assets/images/ exists or is appropriate.
User prompt handling
Hosts expose this skill differently — /codex-imagegen ... in Claude Code, /agent-skills:codex-imagegen ... when installed as a plugin, $codex-imagegen ... in Codex. Whatever the form, treat everything after the skill name as the authoritative image request:
$codex-imagegen 黒背景にMac Studioが置かれた未来的なAIオフィス。16:9。文字なし。Expand it into a sufficiently specific Codex request without changing the user's core visual intent. Requests arrive in any language — carry the details through faithfully rather than translating them away.
Editing images
If the user requests an edit to an existing image:
- Identify the source image from the user's request and the current project.
- Decide whether the result should replace the source or be written as a new file. Unless the user explicitly requests replacement, preserve the original and create a new appropriately named file.
- Choose and preflight the destination as above.
- Attach the source with
--image=<SOURCE>so Codex has the actual pixels, and still name the source and destination paths in the prompt so it knows which file on disk the attachment corresponds to.
Example
codex exec -s workspace-write --skip-git-repo-check \
-o /tmp/codex-last-message.txt \
--image="./assets/source.png" \
"$(cat <<'CODEX_PROMPT'
Use the built-in $imagegen skill to edit the attached image.
IMPORTANT:
- Use the built-in `image_gen` tool.
- Do not use OPENAI_API_KEY.
- Do not use the `scripts/image_gen.py` CLI fallback.
- Edit the actual image rather than describing the change.
- The built-in tool saves under $CODEX_HOME. After editing, move or copy the
result to the destination below, and report that final path.
The attachment is ./assets/source.png. Edit those pixels rather than
regenerating the subject from scratch.
Destination:
./assets/source-transparent.png
Requested changes:
- remove the background
- return actual transparency and preserve the alpha channel in the saved file
- preserve the character exactly
- do not change facial features
CODEX_PROMPT
)"The paths above are examples only. Choose actual paths from the current project context.
Validation
Do not rely on Codex's textual confirmation. Check the file itself:
test -s "<OUTPUT_PATH>" && file "<OUTPUT_PATH>"test -s requires the file to exist and be non-empty; file decodes the header. Confirm all of the following before reporting success:
filenames a real raster format (PNG image data,JPEG image data,RIFF ... WebP) — notempty, notdata, notASCII text.- The reported dimensions match what was requested.
- For a transparency request, the reported color type is
RGBA(or the format otherwise reports an alpha channel).RGBmeans the transparency was lost.
If the expected file does not exist, or fails any check above:
- Read the final message you captured with
-o— Codex reports the path it actually wrote. Otherwise look under Codex's default image location, newest first:
ls -t "${CODEX_HOME:-$HOME/.codex}"/generated_images/*/* 2>/dev/null | head- Move or copy a candidate to the requested destination only when it is clearly the image that was just generated.
- Report failures accurately rather than claiming generation succeeded. A file that exists but fails the format or alpha check is a failure, not a success, and a run that produced no output, no
-omessage and no session never generated anything at all.
If Codex reports that its built-in image_gen capability is unavailable:
- do not silently switch to an API-key path
- report that Codex image generation is unavailable in the current Codex session
- do not charge API usage without explicit user approval
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

