Automated summary
Generates images with the gpt-image-2 model through Codex CLI's built-in image_gen tool, relying on ChatGPT OAuth login instead of an API key.
Strengths
- No API key needed — reuses the existing Codex OAuth login
- Supports size, quality, image count (1–10) and output directory flags
- Checks Codex installation and login status first, with clear error messages
- Timestamped filenames prevent overwriting existing files
Limitations
- Fully dependent on a working, logged-in Codex CLI install
- Requires workspace-write permissions and a 2-minute timeout
- Cannot bypass Codex by calling the OpenAI REST API directly (returns 401)
Use it to quickly produce illustrations or visual assets inside a project from Claude Code without setting up an OpenAI API key.
Avoid it when Codex CLI isn't installed or logged in, or when you need reproducible, scripted output through the official REST API.
Security analysis
CautionThe skill is not malicious and contains no obvious exfiltration or destructive commands, but it runs an external authenticated coding agent with workspace-write permission and passes user prompts into that agent. That is legitimate for image generation but warrants caution.
- •Invokes `codex exec` with `-s workspace-write`, giving an authenticated AI agent write access to the workspace and network access; powerful but appropriate for saving generated images.
- •The user-supplied prompt is embedded into a natural-language instruction for Codex, so prompt-injection could influence the agent to perform unintended file operations within the workspace.
- •`--out` accepts arbitrary directory paths without validation; a user could direct writes outside the project, though this is user-controlled and not hidden.
- •Relies on third-party `codex` OAuth credentials being managed by the CLI; no direct secret exfiltration is present, but the skill depends on an authenticated external agent.
Examples
/codex-image cherry blossom hanok/codex-image --size 1024x1536 --quality high space cat/codex-image -n 3 --out ./assets seoul night skylinename: codex-image description: | Generate images via Codex CLI's built-in image_gen tool (gpt-image-2). OAuth auth — no API key needed. Codex CLI의 내장 image_gen 도구로 이미지 생성. OAuth 인증으로 API 키 불필요. Usage: /codex-image cherry blossom hanok, /codex-image --size 1024x1536 space cat, /codex-image --quality high seoul night argument-hint: "[--size <WxH>] [--quality low|medium|high] [--out <path>] [-n <count>] <image prompt>" allowed-tools:
- Bash
- Read
- AskUserQuestion
codex-image — AI Image Generation via Codex OAuth
Generate images using OpenAI's gpt-image-2 model through Codex CLI.
No API key required — uses Codex OAuth (ChatGPT login) authentication.
OpenAI Codex CLI의 내장 image_gen 도구를 통해 gpt-image-2 모델로 이미지를 생성한다.
API 키 불필요 — Codex OAuth(ChatGPT 로그인) 인증 사용.
How it works / 동작 원리
User prompt → Claude Code (/codex-image)
→ codex exec (OAuth token auto-managed)
→ built-in image_gen tool (gpt-image-2)
→ ~/.codex/generated_images/<session>/
→ copy to project root
Important: OAuth tokens cannot call OpenAI REST API directly (returns 401). Must go through
codex execwhich handles auth internally.OAuth 토큰으로 OpenAI REST API 직접 호출 불가 (401 반환). 반드시
codex exec경유 — Codex가 내부적으로 인증 처리.
Step 1 — Verify Codex CLI & Auth / Codex CLI 및 인증 확인
which codex 2>/dev/null && codex --version 2>/dev/null || echo "NOT_FOUND"
If NOT_FOUND, stop:
"Codex CLI not installed. Run
npm install -g @openai/codexthencodex login." "Codex CLI 없음.npm install -g @openai/codex후codex login실행해."
codex login status 2>&1
If not "Logged in":
"Codex login required. Run
codex loginin terminal. OAuth login enables image generation without API key." "Codex 로그인 필요. 터미널에서codex login실행. OAuth 로그인하면 API 키 없이 이미지 생성 가능."
Step 2 — Parse Arguments / 인자 파싱
Extract from $ARGUMENTS:
| Flag | Values | Default | Description |
|------|--------|---------|-------------|
| --size | 1024x1024, 1024x1536, 1536x1024, auto | 1024x1024 | Image dimensions / 이미지 크기 |
| --quality | low, medium, high, auto | auto | Generation quality / 생성 품질 |
| --out | directory path | project root | Save location / 저장 위치 |
| -n | 1–10 | 1 | Number of images / 생성 장수 |
Remaining text → image prompt / 나머지 텍스트 → 이미지 프롬프트
If prompt is empty, ask via AskUserQuestion:
"What image should I generate? Enter a prompt." "어떤 이미지를 생성할까? 프롬프트를 입력해줘."
Step 3 — Determine Save Path / 저장 경로 결정
_PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
_OUT_DIR="${_PROJECT_ROOT}"
_TIMESTAMP=$(date +%Y%m%d-%H%M%S)
_FILENAME="codex-image-${_TIMESTAMP}"
- If
--outspecified, use that path /--out지정 시 해당 경로 사용 - Single image:
codex-image-<timestamp>.png - Multiple (
-n > 1):codex-image-<timestamp>-1.png,-2.png, ... - Never overwrite existing files / 기존 파일 덮어쓰기 금지
Step 4 — Generate Image / 이미지 생성
codex exec "Perform the following tasks:
1. Use the built-in image_gen tool to generate an image.
2. Prompt: '${_PROMPT}'
3. Size: ${_SIZE}
4. Quality: ${_QUALITY}
5. Count: ${_N}
6. Copy the generated image to '${_OUT_DIR}/${_FILENAME}.png'. For multiple images use -1.png, -2.png suffix.
7. Print the saved file path and size." \
-C "${_PROJECT_ROOT}" \
-s workspace-write \
-c 'model_reasoning_effort="medium"' \
--skip-git-repo-check \
2>&1
timeout: 120000ms (2 min)
Required flags / 필수 플래그
-s workspace-write— file write permission / 파일 쓰기 권한--skip-git-repo-check— works outside git repos / git 레포 외부에서도 실행 가능
Internal flow (Codex side) / 내부 동작 흐름
- Codex calls built-in
image_gentool (gpt-image-2) - Image saved to
~/.codex/generated_images/<session-id>/ig_*.png - Codex copies file to specified project path
- Reports file path and size
Step 5 — Display Result / 결과 출력
═══════════════════════════════════════════════
IMAGE GENERATED / 이미지 생성 완료
═══════════════════════════════════════════════
Prompt: <prompt used>
Size: <size>
Quality: <quality>
Count: <n>
Auth: OAuth (ChatGPT)
───────────────────────────────────────────────
<saved file path(s)>
═══════════════════════════════════════════════
Always display the generated image using the Read tool. 생성된 이미지를 반드시 Read 도구로 표시한다.
Step 6 — Follow-up / 후속 안내
- "Run
/codex-imageagain to generate another image." - For Next.js projects: suggest moving to
public/images/if needed.
Error Handling / 에러 처리
| Error | Message |
|-------|---------|
| Auth expired | "Codex OAuth expired. Run codex login again." / "OAuth 인증 만료. codex login 다시 실행." |
| Model access denied | "No access to gpt-image-2. Check your OpenAI plan." / "gpt-image-2 접근 권한 없음. OpenAI 플랜 확인." |
| Timeout (>2min) | "Generation timed out. Try --quality low." / "생성 시간 초과. --quality low로 재시도." |
| Rate limit | "API rate limited. Wait and retry." / "API 호출 제한. 잠시 후 재시도." |
| Trust error | Check --skip-git-repo-check flag or add project to ~/.codex/config.toml |
Rules / 규칙
- Always use the Read tool to display generated images / 생성된 이미지는 반드시 Read로 표시
- Never overwrite existing files — always use timestamped filenames / 기존 파일 덮어쓰기 금지
- OAuth only — do not attempt direct REST API calls with OAuth token (returns 401) / OAuth 토큰으로 REST API 직접 호출 금지
- Verify prompt intent before generating / 생성 전 프롬프트 의도 확인
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/image-generation-via-codex-cli-msl9cepz/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/image-generation-via-codex-cli-msl9cepz' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/image-generation-via-codex-cli-msl9cepz/download' --output '.skill-downloads/image-generation-via-codex-cli-msl9cepz/SKILL.md.part' && mv '.skill-downloads/image-generation-via-codex-cli-msl9cepz/SKILL.md.part' '.skill-downloads/image-generation-via-codex-cli-msl9cepz/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/image-generation-via-codex-cli-msl9cepz/SKILL.md' && test -s '.skill-downloads/image-generation-via-codex-cli-msl9cepz/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/codex-image' && cp -R '.skill-downloads/image-generation-via-codex-cli-msl9cepz' '.claude/skills/codex-image'Codex
test -f '.skill-downloads/image-generation-via-codex-cli-msl9cepz/SKILL.md' && test -s '.skill-downloads/image-generation-via-codex-cli-msl9cepz/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/codex-image' && cp -R '.skill-downloads/image-generation-via-codex-cli-msl9cepz' '.agents/skills/codex-image'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/image-generation-via-codex-cli-msl9cepz'openskills read 'image-generation-via-codex-cli-msl9cepz'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/image-generation-via-codex-cli-msl9cepz/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
Writing Fragments
Content
Mine raw writing fragments through a relentless interview, without imposing structure. Capture ideas, quotes, and leading words for later use.
UI Copywriting & Auditing
Content
Write or audit user-facing UI copy including buttons, errors, empty states, and tooltips across the monorepo, following the design system source of truth.
Music MIDI Extraction
Content
Extracts the MIDI or score from an existing music production via the CogMusic MCP tool and confirms availability.