agentleFS
GGGODLINGGGODLIN/claude-skills/skills/ai-image-gen/SKILL.md

ai-image-gen

Skill0 starsChanged 6 months ago0BSDView on GitHub

Single entry point for ANY request to create, generate, design, draw, make, render, produce, or edit a visual asset. This explicitly includes logos, icons, brand marks, and design briefs — they count as image-generation tasks under this skill, not as generic "design work". Also covers photos, illustrations, comic/anime art, diagrams, flowcharts, wireframes, mockups, posters, banners, textures, sprites, concept art, and edits of existing images. Triggers on vague image requests ("做一張圖", "need an image") AND on traditional-sounding design briefs ("設計一個 logo", "做個 icon"). Trigger phrases (any language): "產圖", "生成圖片", "畫一張", "做一張圖", "做張圖", "做個圖", "畫個", "設計 logo", "設計一個 logo", "做個 logo", "設計圖標", "做個 icon", "generate image", "make an image", "create picture", "render image", "design a logo", "make me a logo", "I need an icon", "AI art", "illustration", "brand mark". ALWAYS invoke this skill when the user request could plausibly resolve to a visual output, even if it looks like a traditional design brief.

  • Reads credentials

3 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions3 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 3

    1. ZJU-REAL/Easel★ 4.5ksame name
    2. kudeerliu48-web/CloseCode★ 14same name
    3. xuejianrpa/ai-image-gen★ 3same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

18 rules. About 0 are common, 9 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the user's request and classify into one of five categories:

    line 19
  2. Distinctive:

    Only A and D run without asking.

    line 29
  3. Distinctive:

    If the user's original request contains heavy file-management instructions, strip them from the codex prompt and handle them yourself.

    line 37
  4. Distinctive:

    Keep the visual prompt reasonable length.

    line 38
  5. Distinctive:

    If 60 seconds pass with codex still running, emit a brief "仍在產圖中…" progress note to the user so they know it's not hung.

    line 47
  6. Very specific:

    If parse fails, fall back to: most recently modified subdirectory under ~/.codex/generated_images/.

    line 56
  7. Very specific:

    If still no ig_*.png exists → treat as failure, go to the failure-fallback section.

    line 57
  8. Distinctive:

    If user specified a destination filename/path → use it.

    line 61
  9. Very specific:

    If not specified → default to the current working directory with name <semantic-slug>-<YYYYMMDD>.png (extract a short slug from the prompt, …

    line 62
  10. Very specific:

    If the target filename already exists → append -v2, -v3, … until unique.

    line 63
  11. Very specific:

    Use cp, not mv — leave the original in ~/.codex/generated_images/ alone.

    line 64
  12. Very specific:

    Ask explicitly, in one turn: "Codex 失敗(原因 X)。要改用 Gemini MCP 嗎?會扣 GEMINI_API_KEY(約 $0.03–0.06/張)。要繼續就回 yes。"

    line 87
  13. Distinctive:

    Wait for explicit "yes" (or equivalent clear consent): Do not infer consent from silence, context, or prior preferences.

    line 88
  14. Distinctive:

    If the user declines or stays silent → stop, leave the task incomplete, do not try other paid paths.

    line 90
  15. Very specific:

    stdout pipe buffering: do not pipe codex output through | tail -N.

    line 97
  16. Very specific:

    stale superhero.png etc: if a previous codex run partially failed, old files may be missing or in unexpected state.

    line 98
  17. Very specific:

    Ask: "logo 建議走 SVG/HTML 直接寫,可編輯、體積小、無成本;也可以用 codex $imagegen 出 raster。要哪條?"

    line 116
  18. Distinctive:

    If user picks codex → follow default path.

    line 118

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

AI Image Generation Skill

Single entry point for all image-generation tasks. Classifies the request, routes to the right path, and protects the user from paid API calls they didn't approve.

Hard rules

  1. codex $imagegen is the default path. It costs nothing extra (uses the user's ChatGPT subscription login).
  2. Never call a paid image generation path (Gemini MCP, OpenAI Images API, AI Studio MCP, etc.) without explicit user consent for that specific call. Previous consent does not carry over.
  3. Never put file-management instructions inside the codex prompt (no "save as", "copy to", "confirm file exists"). This causes agent-loop stalls. The skill handles file movement after codex returns.
  4. Never overwrite an existing asset unless the user explicitly asked for replacement. Use versioned filenames (-v2, -v3) instead.

Classification (do this first)

Read the user's request and classify into one of five categories:

CategorySignalsRoute
A. Photo / illustration / comic / anime / AI artScene, lighting, character, style keywords, photorealistic, painting, concept artRun codex $imagegen directly
B. Logo / icon / flat graphic / vector-friendly"logo", "icon", "flat design", "vector", geometric, brand markAsk user first: codex raster, or SVG/HTML directly?
C. Diagram / flowchart / wireframe / schematic"flowchart", "architecture diagram", "wireframe", "sequence diagram"Ask user first: codex raster, or Mermaid/SVG structured?
D. Edit existing imageUser provides an image path + change instruction (inpainting, background swap, object removal, style change)Run codex $imagegen in edit mode
E. UnclearCannot classify confidentlyAsk user which of A–D it is

Only A and D run without asking. B, C, E always confirm first.

Path: codex $imagegen (default for A and D)

Prompt rules

  • Prefix the prompt with $imagegen (shell-escape as \$imagegen when calling from bash to avoid variable expansion).
  • Include only the visual description. Do not include save paths, filenames, or confirmation steps.
  • If the user's original request contains heavy file-management instructions, strip them from the codex prompt and handle them yourself.
  • Keep the visual prompt reasonable length. If the user's prompt is very long and packed with negative conditions, it can stall the codex agent loop — consider light trimming or warn the user.

Invocation

codex exec --full-auto --skip-git-repo-check "\$imagegen <pure visual prompt>"
  • Wall-clock timeout: 600 seconds (10 minutes).
  • If 60 seconds pass with codex still running, emit a brief "仍在產圖中…" progress note to the user so they know it's not hung.
  • For edit mode (category D), pass the source image via -i <path> to codex exec, and phrase the prompt as an edit instruction.

Locating the output

After codex finishes:

  1. Parse session id: <UUID> from codex stdout.
  2. Check ~/.codex/generated_images/<session-id>/ig_*.png.
  3. If parse fails, fall back to: most recently modified subdirectory under ~/.codex/generated_images/.
  4. If still no ig_*.png exists → treat as failure, go to the failure-fallback section.

Copy to target

  • If user specified a destination filename/path → use it.
  • If not specified → default to the current working directory with name <semantic-slug>-<YYYYMMDD>.png (extract a short slug from the prompt, e.g. superhero-20260417.png).
  • If the target filename already exists → append -v2, -v3, … until unique.
  • Use cp, not mv — leave the original in ~/.codex/generated_images/ alone.

Path: ask user first (for B, C, E)

Present the choice concisely, then wait:

  • B (logo/icon): "這看起來是 logo/icon,建議走 SVG/HTML 直接寫(可編輯、體積小、無成本);也可以用 codex $imagegen 產 raster。要走哪一條?"
  • C (diagram): "這像是流程圖/架構圖,建議用 Mermaid 或 SVG 結構化(可編輯、可版控);也可以用 codex $imagegen 產 raster。要走哪一條?"
  • E (unclear): Describe your best guess of the categories and ask the user to pick.

Proceed only after user picks. If they pick codex raster, follow the codex path above.

Failure fallback (paid path — requires explicit consent)

Codex path is considered failed when:

  • Wall-clock exceeds 600 seconds → kill codex, proceed to fallback.
  • Codex finishes but no ig_*.png was produced in the session directory.
  • Codex returns a non-zero exit with an obvious error (auth, quota, sandbox).

On failure:

  1. Report the failure mode to the user (what happened, briefly — timeout vs no output vs error).
  2. Ask explicitly, in one turn: "Codex 失敗(原因 X)。要改用 Gemini MCP 嗎?會扣 GEMINI_API_KEY(約 $0.03–0.06/張)。要繼續就回 yes。"
  3. Wait for explicit "yes" (or equivalent clear consent). Do not infer consent from silence, context, or prior preferences.
  4. On consent: call mcp__gemini__gemini-generate-image. Copy MCP output to target destination using the same naming rules as the codex path.
  5. If the user declines or stays silent → stop, leave the task incomplete, do not try other paid paths.

Other paid paths (mcp__aistudio__generate_content, OpenAI Images API direct) follow the same consent rule — never call without a per-call explicit yes.

Error modes to watch for

  • codex agent loop stall: seen with long complex prompts that also include file-management instructions. Mitigation is in the "Prompt rules" section above — keep the codex prompt pure-visual.
  • stdout pipe buffering: do not pipe codex output through | tail -N. It can buffer and hide progress. Let stdout stream directly.
  • stale superhero.png etc.: if a previous codex run partially failed, old files may be missing or in unexpected state. Never assume target dir is clean — check before writing.
  • $ expansion: in bash, $imagegen will expand to empty string. Always escape as \$imagegen in the shell command.

Example (category A, default path)

User: "幫我產一張賽博朋克風的街道夜景"

  1. Classify → A (scene/style keywords).
  2. Build codex prompt: $imagegen A cyberpunk street scene at night, neon lights, rainy asphalt, reflections, dense urban atmosphere, cinematic wide angle
  3. Run codex exec --full-auto --skip-git-repo-check "\$imagegen …".
  4. Parse session id, locate ig_*.png, cp to ./cyberpunk-street-20260417.png.
  5. Report path + size to user.

Example (category B, ask first)

User: "幫我做一個公司 logo,藍色簡潔風"

  1. Classify → B.
  2. Ask: "logo 建議走 SVG/HTML 直接寫,可編輯、體積小、無成本;也可以用 codex $imagegen 出 raster。要哪條?"
  3. Wait.
  4. If user picks codex → follow default path. If SVG → write SVG directly, don't use 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.