agentleFS
zigzag-techzigzag-tech/codex-tui-imagegen/SKILL.md

codex-imagegen

Skill0 starsChanged 5 months agoMITView on GitHub

Generate illustrations/images for free using Codex's built-in image_gen tool (OpenAI's latest image model) by driving a Codex TUI inside a tmux pane. Use when you need raster images — slide illustrations, hero images, concept art, mockups, textures, sprites — and want to avoid paid APIs (fal-ai, gpt-image API). No OPENAI_API_KEY needed. Triggers: "generate an image/illustration", "make a picture", "用 codex 生成图片/插图", "give the deck some illustrations", "draw me a ...".

  • Reads credentials

19 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 4 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

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 17 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

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

    Call gen in a loop — the same TUI session is reused, so start happens once:

    line 72

“Common” is measured: kept by at least 6 in 10 of the 17 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 image generation (via tmux pane)

Codex ships a system imagegen skill that exposes a built-in image_gen tool — OpenAI's latest image model, free, no OPENAI_API_KEY, no fal-ai. This is the preferred way to make raster illustrations.

The one gotcha that defines this whole skill

The native image_gen tool only exists in the interactive Codex TUI. codex exec (headless) cannot see it and will fall back to writing code or refusing. So the only reliable path is: keep a real Codex TUI alive in a tmux pane and feed it prompts with tmux send-keys. That's what the helper script automates.

Other hard-won facts:

  • codex -p is --profile, not a prompt flag. Don't use it to pass prompts.
  • Long/multiline prompts get captured by the TUI as a single [Pasted Content] chunk that does not auto-submit — you must send an extra Enter. The script always does this.
  • Output lands at ~/.codex/generated_images/<session-uuid>/, named either exec-*.png (older Codex) or ig_*.png (newer image_gen tool). The helper matches both globs; if you copy by hand, glob both. (A stale exec-*-only match is what made gen hang forever while the pane already showed "Generated".)
  • A batch of N images can take ~7–15 min; each single image ~30–120s of inference — but a flaky connection can add 1–2 min of stream reconnects before inference starts, so the per-image wait defaults to 360s. If a gen times out but the pane shows "Generated Image", the connection dropped the image bytes mid-download — just re-run gen (a fresh start clears a wedged reconnect state).
  • Codex must launch in a trusted cwd (see ~/.codex/config.toml, trust_level = "trusted") so full-auto/YOLO needs no approval prompt. /tmp and ~ are already trusted.

Quick start

SKILL=~/xc-setup/skills/codex-imagegen/scripts/codex-imagegen.sh

# 1. spin up the long-lived Codex TUI (idempotent — safe to call repeatedly)
"$SKILL" start

# 2. generate one image and copy it to a named path
"$SKILL" gen "A friendly cartoon robot reading a paper receipt, flat vector \
style, warm gold-on-black palette, minimal background" \
  /home/ubuntu/myproject/assets/ill-robot.png

# 3. when done with the whole batch
"$SKILL" stop

gen prints the destination path on stdout (or the raw exec-*.png path if you omit the destination), so you can capture it:

OUT=$("$SKILL" gen "a glowing terminal window, isometric, gold accents" /tmp/term.png)

Generating a batch

Call gen in a loop — the same TUI session is reused, so start happens once:

"$SKILL" start
declare -A imgs=(
  [ill-engine]="a stylized engine block labeled LLM, gold-on-black, flat vector"
  [ill-context]="a window filling up with colored blocks, memory metaphor, gold-on-black"
  [ill-verify]="a magnifying glass over a checklist, gentle humor, gold-on-black"
)
for name in "${!imgs[@]}"; do
  "$SKILL" gen "${imgs[$name]}" "/home/ubuntu/myproject/assets/${name}.png"
done
"$SKILL" stop

Verify what you got — don't trust it blind

The model can crop, misread, or stylize wrong. Always look at the output before wiring it into a deck/page. Either open it with the Read tool (it renders images) or, for slides, render the page and view it with agent-browser. A common failure: a landscape image placed in a ![bg right:N%] Marp slot gets cover-cropped — check for cut-off subjects and switch to a contained ![w:...] two-column layout if so.

Style consistency

For a themed deck, repeat the palette/style clause in every prompt (e.g. warm gold #f8ba00 on near-black background, flat vector, minimal). The model has no memory of earlier images across calls beyond the conversation in the pane, so being explicit each time keeps a batch coherent.

Troubleshooting

SymptomFix
gen times out, no new PNGtmux attach -t codex-imagegen and look — likely an approval prompt (cwd not trusted) or the model answered in prose. Add the cwd to ~/.codex/config.toml as trusted, or re-run start with CIG_CWD=/tmp.
Prompt sat as [Pasted Content], never ranThe script's extra-Enter handles this; if attaching manually, press Enter twice.
Model wrote code instead of an imageThe prompt must say use the image_gen tool; the script forces this.
Picks up an old imageThe script gates on mtime newer than the pre-existing newest PNG, so this shouldn't happen; if confused, stop then start fresh.

Detach from an attached pane with Ctrl-b d (never Ctrl-c — that kills Codex).

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.