imagegen — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited imagegen (Agent Skill) and scored it 92/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 2 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 2 flagged
The text {match} tells the agent to skip the normal "ask the user first" gate. Used adversarially it removes the human-in-the-loop check before destructive or sensitive actions, turning a normally-gated agent into a fire-and-forget executor.
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Generates or edits images for the current project (for example website assets, game assets, UI mockups, product mockups, wireframes, logo design, photorealistic images, or infographics).
This skill has exactly two top-level modes:
image_gen tool for normal image generation, editing, and simple transparent-image requests. Does not require OPENAI_API_KEY.scripts/image_gen.py CLI. Use when the user explicitly asks for the CLI/API/model path, or after the user explicitly confirms a true model-native transparency fallback with gpt-image-1.5. Requires OPENAI_API_KEY.Within CLI fallback, the CLI exposes three subcommands:
generateeditgenerate-batchRules:
image_gen tool by default for normal image generation and editing requests.image_gen first: prompt for a flat removable chroma-key background, then remove it locally with the installed helper at $CODEX_HOME/skills/.system/imagegen/scripts/remove_chroma_key.py.image_gen or CLI gpt-image-2 to CLI gpt-image-1.5. Treat this as a model/path downgrade and ask the user before doing it, unless the user has already explicitly requested gpt-image-1.5, scripts/image_gen.py, or CLI fallback.gpt-image-1.5 --background transparent --output-format png because gpt-image-2 does not support background=transparent, then ask whether to proceed. Run the CLI fallback only after the user confirms.batch by itself does not mean CLI fallback. If the user asks for many assets or says to batch-generate assets without explicitly asking for CLI/API/model controls, stay on the built-in path and issue one built-in call per requested asset or variant.OPENAI_API_KEY. Proceed only if the user explicitly asks for that fallback.scripts/image_gen.py workflow. Do not create one-off SDK runners.scripts/image_gen.py. If something is missing, ask the user before doing anything else.Built-in save-path policy:
$CODEX_HOME/* by default.image_gen tool. If a specific location is needed, generate first and then move or copy the selected output from $CODEX_HOME/generated_images/....$CODEX_HOME/* path.$CODEX_HOME/* path.hero-v2.png or item-icon-edited.png.Shared prompt guidance for both modes lives in references/prompting.md and references/sample-prompts.md.
Fallback-only docs/resources for CLI mode:
references/cli.mdreferences/image-api.mdreferences/codex-network.mdscripts/image_gen.pyLocal post-processing helper:
$CODEX_HOME/skills/.system/imagegen/scripts/remove_chroma_key.py: removes a flat chroma-key background from a generated image and writes a PNG/WebP with alpha. Prefer auto-key sampling, soft matte, and despill for antialiased edges.Think about two separate questions:
Intent:
Built-in edit semantics:
view_image tool so the image is visible in the conversation context, then proceed with the built-in edit flow.Execution strategy:
image_gen call per requested asset or variant.generate-batch subcommand only when the user explicitly chose CLI mode and needs many prompts/assets.n as a substitute for separate prompts. n is for variants of one prompt; distinct assets need distinct built-in calls or distinct CLI generate-batch jobs.Assume the user wants a new image unless they clearly ask to change an existing one.
generate or edit.generate-batch.view_image first so the image is available in conversation context.image_gen rather than substituting SVG/HTML/CSS placeholders. If the request is for an icon, logo, or UI graphic that should match existing repo-native SVG/vector/code assets, prefer editing those directly instead.image_gen tool by default.image_gen on a flat chroma-key background, copy the selected output into the workspace or tmp/imagegen/, run the installed $CODEX_HOME/skills/.system/imagegen/scripts/remove_chroma_key.py helper, and validate the alpha result before using it. If this path looks unsuitable or fails, ask before switching to CLI gpt-image-1.5.$CODEX_HOME/generated_images/... path.$CODEX_HOME/generated_images/... path.input_fidelity, masks, output format, output paths, and network setup.Transparent-image requests still use built-in image_gen first. Because the built-in tool does not expose a true transparent-background control, create a removable chroma-key source image and then convert the key color to alpha locally.
Default sequence:
image_gen to generate the requested subject on a perfectly flat solid chroma-key background.#00ff00, use #ff00ff for green subjects, and avoid #0000ff for blue subjects.$CODEX_HOME/generated_images/... into the workspace or tmp/imagegen/. python "${CODEX_HOME:-$HOME/.codex}/skills/.system/imagegen/scripts/remove_chroma_key.py" \
--input <source> \
--out <final.png> \
--auto-key border \
--soft-matte \
--transparent-threshold 12 \
--opaque-threshold 220 \
--despill--edge-contract 1; use --edge-feather 0.25 only when the edge is visibly stair-stepped and the subject is not shiny or reflective.$CODEX_HOME/*.Prompt transparent requests like this:
Create the requested subject on a perfectly flat solid #00ff00 chroma-key background for background removal.
The background must be one uniform color with no shadows, gradients, texture, reflections, floor plane, or lighting variation.
Keep the subject fully separated from the background with crisp edges and generous padding.
Do not use #00ff00 anywhere in the subject.
No cast shadow, no contact shadow, no reflection, no watermark, and no text unless explicitly requested.Do not automatically use CLI gpt-image-1.5 --background transparent --output-format png instead of chroma keying. Ask the user first when the user asks for true/native transparency, when local removal fails validation, or when the requested image is complex: hair, fur, feathers, smoke, glass, liquids, translucent materials, reflective objects, soft shadows, realistic product grounding, or subject colors that conflict with all practical key colors.
Use a concise confirmation like:
This likely needs true native transparency. The default built-in path uses a chroma-key background plus local removal, but true transparency requires the CLI fallback with gpt-image-1.5 because gpt-image-2 does not support background=transparent. It also requires OPENAI_API_KEY. Should I proceed with that CLI fallback?Reformat user prompts into a structured, production-oriented spec. Make the user's goal clearer and more actionable, but do not blindly add detail.
Treat this as prompt-shaping guidance, not a closed schema. Use only the lines that help, and add a short extra labeled line when it materially improves clarity.
Use the user's prompt specificity to decide how much augmentation is appropriate:
Allowed augmentations:
Not allowed augmentations:
Classify each request into one of these buckets and keep the slug consistent across prompts and references.
Generate:
Edit:
image_gen with chroma-key removal first for simple opaque subjects; ask before using CLI true transparency for complex subjects.Use the following labeled spec as shared prompt scaffolding for both top-level modes:
Use case: <taxonomy slug>
Asset type: <where the asset will be used>
Primary request: <user's main prompt>
Input images: <Image 1: role; Image 2: role> (optional)
Scene/backdrop: <environment>
Subject: <main subject>
Style/medium: <photo/illustration/3D/etc>
Composition/framing: <wide/close/top-down; placement>
Lighting/mood: <lighting + mood>
Color palette: <palette notes>
Materials/textures: <surface details>
Text (verbatim): "<exact text>"
Constraints: <must keep/must avoid>
Avoid: <negative constraints>Notes:
Asset type and Input images are prompt scaffolding, not dedicated CLI flags.Scene/backdrop refers to the visual setting. It is not the same as the fallback CLI background parameter, which controls output transparency behavior.Quality:, Input fidelity:, masks, output format, and output paths belong in the CLI path only. Do not treat them as built-in image_gen tool arguments.Augmentation rules:
change only X; keep Y unchanged).Use case: product-mockup
Asset type: landing page hero
Primary request: a minimal hero image of a ceramic coffee mug
Style/medium: clean product photography
Composition/framing: wide composition with usable negative space for page copy if needed
Lighting/mood: soft studio lighting
Constraints: no logos, no text, no watermarkUse case: precise-object-edit
Asset type: product photo background replacement
Primary request: replace only the background with a warm sunset gradient
Constraints: change only the background; keep the product and its edges unchanged; no text; no watermarkreferences/cli.md and references/image-api.md for model, quality, input_fidelity, masks, output format, and output-path guidance.gpt-image-1.5.More principles shared by both modes: references/prompting.md. Copy/paste specs shared by both modes: references/sample-prompts.md.
Asset-type templates (website assets, game assets, wireframes, logo) are consolidated in references/sample-prompts.md.
The fallback CLI defaults to gpt-image-2.
gpt-image-2 for new CLI/API workflows unless the request needs true model-native transparent output.gpt-image-1.5 unless the user already explicitly requested gpt-image-1.5, scripts/image_gen.py, or CLI fallback. Explain that the built-in chroma-key path is the default, but true transparency requires gpt-image-1.5 because gpt-image-2 does not support background=transparent.gpt-image-2 always uses high fidelity for image inputs; do not set input_fidelity with this model.gpt-image-2 supports quality values low, medium, high, and auto.quality low for fast drafts, thumbnails, and quick iterations. Use medium, high, or auto for final assets, dense text, diagrams, identity-sensitive edits, or high-resolution outputs.1024x1024 for fast square drafts.3840x2160 for landscape or 2160x3840 for portrait.gpt-image-2 size may be auto or WIDTHxHEIGHT if all constraints hold: max edge <= 3840px, both edges multiples of 16px, long-to-short ratio <= 3:1, total pixels between 655,360 and 8,294,400.Popular gpt-image-2 sizes:
1024x1024 square1536x1024 landscape1024x1536 portrait2048x2048 2K square2048x1152 2K landscape3840x2160 4K landscape2160x3840 4K portraitautoThese conventions apply only to the CLI fallback. They do not describe built-in image_gen output behavior.
tmp/imagegen/ for intermediate files (for example JSONL batches); delete them when done.output/imagegen/.--out or --out-dir to control output paths; keep filenames stable and descriptive.Prefer uv for dependency management in this repo.
Required Python package:
uv pip install openaiRequired for local chroma-key removal and optional downscaling:
uv pip install pillowPortability note:
uv pip install ... remains the preferred path.OPENAI_API_KEY must be set for live API calls.OPENAI_API_KEY when using the built-in image_gen tool.If the key is missing, give the user these steps:
OPENAI_API_KEY as an environment variable in their system.If installation is not possible in this environment, tell the user which dependency is missing and how to install it into their active environment.
references/cli.mdreferences/image-api.mdreferences/codex-network.mdreferences/prompting.md: shared prompting principles for both modes.references/sample-prompts.md: shared copy/paste prompt recipes for both modes.references/cli.md: fallback-only CLI usage via scripts/image_gen.py.references/image-api.md: fallback-only API/CLI parameter reference.references/codex-network.md: fallback-only network/sandbox troubleshooting for CLI mode.scripts/image_gen.py: fallback-only CLI implementation. Do not load or use it unless the user explicitly chooses CLI mode or explicitly confirms a transparent request's true CLI transparency fallback.$CODEX_HOME/skills/.system/imagegen/scripts/remove_chroma_key.py: local post-processing helper for built-in transparent-image requests.~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.