一键导入
image-generation
Generate or edit images via Codex CLI — with prompt refinement, vision validation, retry loop, and error handling.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate or edit images via Codex CLI — with prompt refinement, vision validation, retry loop, and error handling.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Audit code quality against KB-defined properties, invariants, and naming conventions.
Quality and compliance audit — combines code-quality and spec-compliance into one actionable report.
Periodic friction analysis — proposes new skills, deterministic tools, and adaptations.
Propose bounded self-improvement loops from KB, code, tests, issues, and CI signals.
Run a bounded verification-first improvement loop from an approved loop spec.
Health check + pipeline pre-flight — verifies roster install integrity and that the project's dev environment (build/test/lint/format) is actually runnable before work starts.
| name | image-generation |
| description | Generate or edit images via Codex CLI — with prompt refinement, vision validation, retry loop, and error handling. |
| when_to_use | Use to generate or edit images via the Codex CLI. Trigger: 'generate an image', 'create an icon/asset'. |
| version | 1.0.2 |
| tags | ["image-generation","assets","media","codex","vision","frontend","content","documentation"] |
| domain | media |
Generate or edit an image using the Codex CLI based on $ARGUMENTS.
Parse $ARGUMENTS as one of:
"<prompt>" — generate a new image"edit <path> <prompt>" — edit an existing imagesize:<WxH>, format:<png|jpg|webp>, out:<path>, style:<hint>Examples:
"a watercolor moonlit library""edit assets/hero.png replace background with white""a minimalist OCaml logo size:512x512 out:docs/logo.png"Extract from $ARGUMENTS:
MODE: generate or editRAW_PROMPT: the user's original descriptionINPUT_PATH: (edit mode only) path to source image — verify it exists; abort if notSIZE: default 1024x1024; override if size:WxH presentFORMAT: default png; override if format:X presentOUTPUT_PATH: if out:<path> present, use it; otherwise ask the user where to save the resultIf OUTPUT_PATH is missing and $ARGUMENTS provides no hint, ask:
"Where should I save the image? (e.g.,
assets/hero.png)"
Do not proceed until OUTPUT_PATH is resolved.
Before invoking Codex, rewrite RAW_PROMPT into a detailed, visually precise prompt:
SIZE as an aspect ratio hint (e.g., "square 1:1 composition")FORMAT only if it has visual implications (e.g., transparency for PNG)Store the result as REFINED_PROMPT. Show the user both the original and refined version:
Original:
<RAW_PROMPT>Refined:<REFINED_PROMPT>
If the user rejects the refinement, use RAW_PROMPT as-is.
Set ATTEMPT=1, MAX_ATTEMPTS=3.
Generate mode:
codex exec --full-auto "Generate a <SIZE> <FORMAT> image of: <REFINED_PROMPT>. Save the result to <OUTPUT_PATH>."
Edit mode:
codex exec --full-auto "Edit the image at <INPUT_PATH>: <REFINED_PROMPT>. Save the result to <OUTPUT_PATH>."
Capture both stdout and stderr. On completion, proceed to Step 4.
If stderr contains rate limit, 429, or quota:
WAIT = 15 * ATTEMPT seconds (15s, 30s, 45s)ATTEMPT for rate limit retries — at most 3 rate limit waits per attempt.Abort immediately (do not retry) if stderr contains:
command not found / codex: not found → "Codex CLI not installed. Run: npm install -g @openai/codex"authentication / unauthorized / 401 → "Codex authentication failed. Check your credentials."not found on INPUT_PATH (edit mode) → "Source image not found at <INPUT_PATH>."Verify OUTPUT_PATH exists and is non-empty (size > 0 bytes).
If missing or empty:
ATTEMPT.ATTEMPT <= MAX_ATTEMPTS, refine the prompt further (add more explicit detail) and go to Step 3.ATTEMPT > MAX_ATTEMPTS, abort: "Codex did not produce an output file after 3 attempts."Read the file. If the image cannot be decoded (corrupted header, truncated):
Inspect the generated image visually:
RAW_PROMPT requested?SIZE?Score the result: pass / soft-fail / hard-fail
| Result | Condition | Action |
|---|---|---|
| pass | Intent clearly satisfied | Proceed to Step 5 |
| soft-fail | Mostly correct but minor issues | Show user, offer retry or keep |
| hard-fail | Wrong content or unusable | Auto-retry with corrected prompt |
On soft-fail, present the image path and ask:
"The image was generated but may not fully match your intent. Keep it, or retry with adjustments?"
On hard-fail, identify the specific mismatch, adjust REFINED_PROMPT to correct it, increment ATTEMPT, and go to Step 3 if ATTEMPT <= MAX_ATTEMPTS.
If ATTEMPT > MAX_ATTEMPTS on hard-fail:
<OUTPUT_PATH>. Issues: <mismatch description>."Append a JSON entry to .imagelog.json in the project root (create if absent):
{
"timestamp": "<ISO 8601>",
"mode": "<generate|edit>",
"raw_prompt": "<RAW_PROMPT>",
"refined_prompt": "<REFINED_PROMPT>",
"output_path": "<OUTPUT_PATH>",
"size": "<SIZE>",
"format": "<FORMAT>",
"attempts": <ATTEMPT>,
"outcome": "<pass|soft-fail|hard-fail|aborted>"
}
If .imagelog.json exists, parse it as an array and append. If it does not exist, create it as a single-element array.
On success:
"Image saved to
<OUTPUT_PATH>(attempt /<MAX_ATTEMPTS>). Logged to.imagelog.json."
On abort: summarize what failed and what the user should do next.
OUTPUT_PATH.MAX_ATTEMPTS times total (rate limit retries are separate)..imagelog.json must always be updated, even on failure (log the abort).