agentleFS
ranchengrancheng/my_claude_skills/skills/codex-imagegen/SKILL.md

codex-imagegen

Skill1 starsChanged 7 months agoMITView on GitHub

Generate or edit images by invoking OpenAI's gpt-image-2 ("image 2") through headless `codex exec`. Trigger when the user asks to create, generate, draw, design, or edit an image, logo, icon, illustration, banner, sprite sheet, placeholder art, or any visual asset — and they have not specified a different generator (Stable Diffusion, Midjourney, DALL·E API directly, etc.). Also use when the user wants to transform or extend a reference image they have provided locally.

  • Reads credentials

15 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use orchestrate and implement.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • varun29ankuSSkill

    orchestrate

    This skill should be used when the user asks to 'orchestrate a task', 'break down work into parallel agents', 'coordinate subtasks', 'run agents in parallel', or mentions 'multi-agent'. Decomposes complex tasks into tracked subtasks, dispatches parallel subagents, and coordinates until completion.

    Also in 3 projects that use this

  • Hugging FaceSkill

    implement

    Make tests pass. Invoke after /write-tests produces failing tests.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 14 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run the bundled helper script.

    line 18
  2. Very specific:

    Display the result: After success, use the Read tool on the output PNG so the image renders inline for the user.

    line 35
  3. Distinctive:

    When the user provides a source image and wants it modified:

    line 40

“Common” is measured: kept by at least 6 in 10 of the 14 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

codex-imagegen

Generates images via the gpt-image-2 model (the "image 2" model) by invoking the Codex CLI in non-interactive mode. The Codex CLI's built-in image_gen skill handles the actual model call; this skill is the bridge that lets Claude Code drive it headlessly and place the result inside the user's workspace.

Prerequisites (verify only if invocation fails)

  • codex is on PATH (which codex).
  • The user is logged in (~/.codex/auth.json exists) or OPENAI_API_KEY is set in the environment.
  • Image generation consumes Codex usage credits (3–5× faster than a text turn). Mention this only if the user expresses cost concerns.

How to invoke

Run the bundled helper script. It owns all the flags, the $imagegen prefix, the stdout-parse, and the bwrap-sandbox workaround.

~/.claude/skills/codex-imagegen/imagegen.sh <output.png> "<prompt>" [reference_image ...]
  • <output.png> — absolute or workspace-relative path where the final PNG should land.
  • <prompt> — the image description. Be specific about subject, style, composition, palette, and background. The script auto-prepends $imagegen so Codex routes to the built-in image skill.
  • [reference_image ...] — zero or more local image files to attach as references (passed through codex exec -i). Use these when the user wants to transform, restyle, or extend an existing asset.

The script writes the final file to <output.png> and prints wrote <output.png> (source: <codex-cache-path>) on success.

Standard workflow

  1. Clarify the prompt only if it is genuinely ambiguous. A one-line user request like "make me a logo" warrants a quick check on style / palette / use case; "minimalist flat icon of a robot painter" does not. Don't over-question.
  2. Pick a sensible output filename in the current working directory (e.g. logo.png, hero.png). Don't put it in /tmp unless the user asks.
  3. Run the script via Bash. Allow up to ~120s for generation.
  4. Display the result. After success, use the Read tool on the output PNG so the image renders inline for the user. This is the verification step — never claim success without doing it.
  5. Report briefly: filename, dimensions (from file <out> if useful), and the prompt actually used. Skip filler.

Editing / reference-image flow

When the user provides a source image and wants it modified:

~/.claude/skills/codex-imagegen/imagegen.sh out.png \
  "Redraw this scene in watercolor, soft pastel palette, preserve composition" \
  ./input.jpg

Codex will receive the reference via -i and the prompt should describe the transformation, not redescribe the source.

Failure modes & recovery

  • bwrap: Failed RTM_NEWADDR: Operation not permitted — Linux sandbox blocks codex's own copy step. The helper already works around this by parsing the source path from stdout and copying it itself, so this should not surface to the user. If it does, the image was still generated; rerun the script or grep ~/.codex/generated_images/ for the most recent file.
  • could not locate generated image in codex output — codex exec failed before producing a file. Re-read the captured stderr (the script prints the full log on failure) to diagnose: auth issues, rate limits, content-policy refusals.
  • Wrong content / refusal — adjust the prompt and rerun. Don't try to bypass content policy.

What this skill does NOT do

  • It does not call the OpenAI Images API directly with curl / the SDK. If the user explicitly wants the raw API (e.g. for batch generation, custom params not exposed by Codex), say so and write a small Python/Node script instead.
  • It does not run inside the Codex container — it runs codex exec from the user's shell.
  • It does not manage Codex auth. If auth.json is missing and OPENAI_API_KEY is unset, tell the user to run codex login themselves; do not attempt it for them (it's interactive).

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.