Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

claude-imagegen

Image generation for Claude Code.

Claude Code can't generate images. This skill fixes that by borrowing the image generator that ships with the Codex CLI, so you can ask Claude for a hero image, a social card, a game sprite, or a mockup, and get a real PNG on disk.

It runs on the ChatGPT plan you already pay for. No OPENAI_API_KEY, no per-image billing, no third-party service.

you:     make me a hero image for the landing page
claude:  [asks 2 quick questions, generates, shows you the PNG]

What you get

Real files PNGs on disk, exactly where you asked for them.
Text that works Renders legible text inside images, accented languages included.
Format control Ask for 16:9, 1080×1350, 4K. It honors it.
Consistency Point at an image and keep one visual identity across a series.
Editing Change one thing in an image you already have.
Transparent PNGs Real alpha channel, for logos and icons.
A skill that thinks Claude asks a couple of sharp questions first, instead of guessing.

Examples further down.


Requirements (read this part)

1. A paid ChatGPT plan. The Codex CLI signs in with a ChatGPT account and supports Plus, Pro, Business, Edu, or Enterprise. The free tier is not supported by Codex login. (You can use an OpenAI API key instead, but then you're paying per image and this project's whole point goes away.)

2. Claude Code. Obviously.

3. macOS or Linux. Windows via WSL should work but is untested.

That's it. No API key to create, no new account to sign up for, no third-party service in the middle.


Setup, step by step

Step 1: install the Codex CLI

Pick whichever you prefer:

# Homebrew (macOS / Linux)
brew install --cask codex

# or npm
npm install -g @openai/codex

# or the install script
curl -fsSL https://chatgpt.com/codex/install.sh | sh

Check it worked:

codex --version
# codex-cli 0.144.2   (any recent version is fine)

If you get command not found, your shell can't see it yet. Close the terminal, open a new one, try again.

Step 2: log in with your ChatGPT account

codex login

This opens your browser. Sign in with the ChatGPT account that has your Plus/Pro plan. Come back to the terminal when it says you're done.

Verify:

codex login status

Step 3: install the plugin

Inside Claude Code, run these two:

/plugin marketplace add FernandoGomes83/claude-imagegen
/plugin install imagegen@claude-imagegen

Nothing to clone, nothing to symlink. Claude Code copies the plugin into its own cache, so it never depends on a folder you might move or delete.

Later on: /plugin marketplace update claude-imagegen to pull updates, and /plugin uninstall imagegen@claude-imagegen to remove it.

Step 4: use it

Open Claude Code and just ask, in your own words:

generate a cover image for my blog post about slow mornings

That's the whole interface. Claude picks up the skill, asks a question or two if the request is thin, generates, and shows you the file.

Each image takes 1 to 2 minutes.

Step 5: if something breaks

codex doctor      # diagnoses your Codex install, auth, and runtime

Most problems are Step 2 not actually finishing. Run codex login status and confirm.


What you can ask for

All of it in plain language. Claude works out the rest.

A series that looks like one series

"generate an owl in the same style as fox.png"

Reference Result

Same background, palette, composition and grain. Only the animal changed. It works for people too: point at a photo and ask for that person somewhere else.

The one thing worth saying out loud is what must stay the same. A reference on its own drifts; "same background, same palette, only the animal changes" doesn't.

This image, but with one thing different

"take mug.png and replace the wood table with white marble"

Before After

The cup, the crema, the handle, the wall, the angle and the light all survive. Only the table changed, from a six-word request.

Don't bother spelling out what to preserve, it's already handled. Doing it by hand actually makes it worse: the same edit with a written-out paragraph of invariants left 5.4% of the cup altered, against 1.7% for the short version.

A cutout with no background

"make me a rocket icon with a transparent background"

What gets generated What you get back
Flat #00ff00 background, added to your prompt for you Real alpha channel, antialiased edges, no green fringe

Describe the subject; the chroma-key dance is handled and the intermediate is cleaned up. Good for logos, icons, sprites and product cutouts. Hair, fur, smoke and glass key badly, and there it fails loudly instead of handing back a bad cutout.

Needs the chroma-key helper that ships with the Codex CLI, plus either uv (it fetches Pillow on the fly) or Pillow already installed. Both are checked before generating, so a missing one costs a second instead of two minutes.

Text inside the image

"a quote card that says 'A graça de Deus não é mérito', elegant serif, centered"

Quote the words exactly and it renders them, accents included. Long copy is where it gets fragile, so look at what came out.

Examples

All generated through this skill, unretouched, first try.

red fox sleeping curled up, flat minimalist illustration, beige background, no text
blue coffee cup on light wood table, product photography, soft studio light
An ads-marketing banner with verbatim text, landscape 16:9, negative space on the right third. Text renders clean.
Accented Portuguese, rendered correctly first try: "A graça de Deus não é mérito — é presença, perdão e compaixão." Every accent and the em dash landed right.

How it works

Claude Code  ──►  codex-image.sh  ──►  codex exec (headless)  ──►  image_gen
                                                                      │
     Read  ◄──────  /your/path.png  ◄─────────────────────────────────┘

The skill shells out to codex exec, Codex runs its built-in image_gen tool, and the PNG lands at the path you named. Claude then reads that file to actually look at the result.

The one non-obvious trick: you have to name the destination path inside the prompt. Codex's imagegen skill treats an unnamed-destination request as preview-only and "renders it inline", which doesn't exist in a headless run. Without a dictated path, the run exits 0, prints an empty message, and writes no file at all. Silent failure.

So the script dictates the output path and then verifies the file on disk. It never trusts the exit code or the model's answer. The file is the source of truth.


Limitations

  • 1 to 2 minutes per image. It's not instant. Nothing to be done about that.
  • Aspect ratio is honored, not guaranteed. There's no size flag on the built-in tool. If you need exactly 1200×630, verify and resize.
  • Transparency is chroma-keyed, not native. See above. Clean opaque subjects cut out well; hair, fur, smoke and glass don't.
  • Editing regenerates, it doesn't patch. The untouched parts come back very close, but not byte-identical. Great for backgrounds, lighting and materials. It is not masked inpainting.
  • Text is the fragile part. It's very good, but always look at the result. Long copy raises the risk.

FAQ

Does this cost anything per image? No. It uses the Codex CLI on your existing ChatGPT plan. There's no API key and no metered billing. Your plan's usage limits still apply.

Does it work on the free ChatGPT tier? No. Codex login supports Plus, Pro, Business, Edu, and Enterprise. That's OpenAI's requirement, not this project's.

Does it send my code to OpenAI? It sends your prompt to Codex, same as any Codex run. It doesn't read your repo to build the prompt.

Why not just use an image API? You can. Codex ships a fallback CLI for that, and it needs OPENAI_API_KEY plus per-image billing. This project exists to avoid exactly that.

Windows? Untested. WSL should be fine. PRs welcome.


License

MIT, see LICENSE.

Built by @FernandoGomes83.

About

Image generation for Claude Code. Borrows the Codex CLI's built-in image_gen tool — runs on your existing ChatGPT plan, no API key, no per-image billing.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages