codex-image-gen
/codex-image-gen
Generate or edit an image by delegating to the user's Codex CLI subscription. Use when the user requests "draw / render / generate / create / sketch / design an image of X" or similar. Returns a local PNG path which the Telegram channel will upload as a photo.
- Author
- techfreakworm ↗
- Repository
- claude-soma ↗
- Licence
- MIT
- Last repository change
- 22.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 22.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Generate or edit an image by delegating to the user's Codex CLI subscription. Use when the user requests "draw / render / generate / create / sketch / design an image of X" or similar. Returns a local PNG path which the Telegram channel will upload as a photo.
Triggers from the description
Original author description
Generate or edit an image by delegating to the user's Codex CLI subscription. Use when the user requests "draw / render / generate / create / sketch / design an image of X" or similar. Returns a local PNG path which the Telegram channel will upload as a photo.
How it works
- How Codex CLI handles image generation
- Process
- Sanitization
- Notes
SKILL.md preview
---
name: codex-image-gen
description: |
Generate or edit an image by delegating to the user's Codex CLI subscription.
Use when the user requests "draw / render / generate / create / sketch /
design an image of X" or similar. Returns a local PNG path which the
Telegram channel will upload as a photo.
allowed-tools: Bash(codex *), Bash(ls *), Bash(file *), Read
---
# codex-image-gen
When invoked, you have a `prompt` describing the desired image.
## How Codex CLI handles image generation
Codex CLI does NOT have a direct `--image-out` flag. Codex is an agentic
coding assistant authed via the user's ChatGPT subscription. To generate
an image, you instruct codex agentically — it then calls OpenAI's image
model on your behalf using its own ChatGPT auth (no API key needed).
`codex login status` should report "Logged in using ChatGPT" before this
skill runs; if it doesn't, fail fast with the explanation that auth is
missing — DO NOT assume the failure is anything else (e.g. missing
OPENAI_API_KEY is a wrong inference; codex doesn't use API keys for the
ChatGPT subscription path).
## Process
1. Pick an output path: `OUT=/tmp/codex_img_$(uuidgen | cut -c1-8).png`.
2. Invoke codex non-interactively with workspace-write sandbox so it can
actually save the file:
```bash
setsid timeout --kill-after=10 120 codex exec --skip-git-repo-check --sandbox workspace-write --cd /tmp \
"Generate an image: <THE USER'S PROMPT, single line>.
Save the PNG to $OUT and reply with only the absolute file path."
```
**Why the wrapper:** GNU `timeout` alone sends SIGTERM at the deadline but never
escalates — a Node CLI that traps SIGTERM can run indefinitely in cleanup, and any
setsid'd child helpers escape a killpg. `setsid` places timeout + codex + all initial
descendants into a new session so the outer process group contains everything launched
before codex itself calls setsid. The `--kill-after=10` flag fires SIGKILL 10 seconds
after SIGTERM if the process is still alive, giving a hard wall-clock ceiling of 130 s.
Exit code 124 signals the SIGTERM path; exit code 137 signals the SIGKILL path.
Notes on the flags:
- `--skip-git-repo-check` lets codex run outside a git repo (the bot
usually runs from `/opt/claude-soma`, but we're writing to `/tmp`).
- `--sandbox workspace-write` permits file writes inside `--cd`.
The default `read-only` blocks codex from saving the PNG.
- `--cd /tmp` makes `/tmp` codex's working root for this run.
3. Verify the file exists and looks like a real image:
```bash
ls -lh "$OUT" && file "$OUT"
```
Expect size 100 KB – 4 MB and `file` to say `PNG image data, ...`.
If size is < 5 KB or file type is wrong, codex likely returned a
description instead of saving — re-run with a more explicit save
instruction or fail with that diagnostic.
4. Reply to the user with the absolute `$OUT` path. The Telegram channel's
`mcp__plugin_telegram_telegram__reply` tool accepts a `files: [path]`
parameter and uploads PNGs as photos with inline preview (not as voice
notes, even if the request originated as a voice memo).
## Sanitization
- Strip newlines from the user's prompt before interpolating into the
codex exec instruction (a literal newline can break the shell quoting).
- If the user's prompt contains content-policy-likely terms (nudity,
violence, real-person likenesses, etc.), pass it through but be ready
to surface codex's policy refusal verbatim — don't paraphrase.
## Notes
- Codex uses the user's separate ChatGPT subscription — does NOT count
against Claude Max credits.
- For aspect-ratio / style / composition control, embed it in the prompt
(e.g. "16:9 cinematic, soft rim light, painterly").
- If codex returns text without writing the file, the most common cause
is the sandbox flag being wrong — verify `--sandbox workspace-write`
is present.
- ChatGPT Plus / Pro subscribers have limited image-gen quota; sustained
bursts may rate-limit.
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · techfreakworm/claude-soma | 100 | MIT |
| MrBogomips/skills | 100 | MIT |
| vickydotbat/vicky-skills | 100 | MIT |
| zazencodes/skills | 100 | MIT |
Database snapshot: 13.11.2026 · package version 4715d2ac5984 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100codex-imagegen
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`. - 95gpt-image-2
Generate or edit a raster image with OpenAI's gpt-image-2 through the Codex CLI, billed to the ChatGPT subscription rather than an API key. Use whenever the user asks for a photo, illustration, mockup, texture, marketing visual, or an edit to an existing image file, including… - 95gpt-image-gen
Use when the user asks to generate OR edit an image via GPT/Codex (e.g. 「叫 gpt 生圖」「幫我用 gpt 生圖」「gpt 畫一個 X」「幫我去背」「把這張圖的背景去掉」). The skill drafts a Chinese + English prompt pair and waits for explicit approval. After approval it uses the host-native executor: Codex calls its… - 100image-gen
Generate AI images from text prompts. Triggers on: "生成图片", "画一张", "AI图", "generate image", "配图", "create picture", "draw", "visualize", "generate an image". - 100gpt-image-2-skill
This skill should be used when the user asks to "generate an image", "create a logo", "draw an icon", "edit this photo", "change background to transparent", "remove background", "use GPT image", "use Codex to draw", "用 GPT image 生成图片", "用 Codex 画图", "帮我生成一张图", "改成透明背景",… - 100image-generation
Generate images from text prompts (and optionally edit/remix input images). Use when the user asks to create, generate, draw, render, or edit an image, illustration, logo, icon, diagram, or photo.