Codex imagegen

From htlin222/dotfiles · View interactive version

Codex imagegen is an AI agent skill from the GitHub repository htlin222/dotfiles. Generate an image via Codex CLI (OpenAI gpt-image-1) and save to a local path. Use when user asks to create/draw/generate an image AND save it (e.g. "draw X, save to images/y.png", "用 codex 生圖"). Requires `codex login` + `$OPENAI_API_KEY`.

How to use this skill

Skill file

codex-imagegen

Overview

This skill drives the Codex CLI agent (codex exec) and asks it to produce a PNG at a path the caller chooses. On this machine the agent does not invoke a built-in image_generation tool — instead it shells out to https://api.openai.com/v1/images/generations with model gpt-image-1, base64-decodes the response, and writes the PNG. The wrapper handles the friction: companion-env interception, sandbox/network confinement, path resolution, output verification.

When to use

Trigger when the user's request has both:

  1. An image-generation intent — "生圖 / 畫一張 / generate / draw / create an image of …", and
  2. A target file path — "存成 X.png", "save to X.png", or an output directory.

If only (1) is present, ask for the path before proceeding.

How to use

Run the bundled script. It takes the output path as the first argument and the description as the rest:

bash {SKILL_DIR}/scripts/imagegen.sh <output-path> <description...>

{SKILL_DIR} is this skill's folder. From inside Claude Code use the absolute path

/Users/htlin/.claude/skills/codex-imagegen/scripts/imagegen.sh (or the dotfiles

source /Users/htlin/.dotfiles/claude.symlink/skills/codex-imagegen/scripts/imagegen.sh).

The script:

Smoke test

The canonical smoke test from the article:

bash /Users/htlin/.claude/skills/codex-imagegen/scripts/imagegen.sh tmp/shiba.png 戴墨鏡的柴犬

Expected: a PNG (~1–3 MB, ~1024px square or larger) at tmp/shiba.png and a final line wrote /…/tmp/shiba.png (<bytes> bytes).

Notes

Things the wrapper does that aren't obvious from the article:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.