SKILL.md
SKILL.mdBrowse 12 files
4,220 tokens
19,201 bytes
Token encoding: o200k_base
Snapshot 18d7ace
1---2name: "imagegen"3description: "Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output should be a bitmap asset rather than repo-native code or vector. Do not use when the task is better handled by editing existing SVG/vector/code-native assets, extending an established icon or logo system, or building the visual directly in HTML/CSS/canvas."4---5 6# Image Generation Skill7 8Generates or edits images for the current project (for example website assets, game assets, UI mockups, product mockups, wireframes, logo design, photorealistic images, or infographics).9 10## Top-level modes and rules11 12This skill has exactly two top-level modes:13 14- **Default built-in tool mode (preferred):** built-in `image_gen` tool for image generation, editing, and transparent-image requests. Does not require `OPENAI_API_KEY`.15- **Fallback CLI mode:** `scripts/image_gen.py` CLI. Use when the user explicitly asks for or confirms the CLI/API/model path. Requires `OPENAI_API_KEY`.16 17Within CLI fallback, the CLI exposes three subcommands:18 19- `generate`20- `edit`21- `generate-batch`22 23Rules:24- Use the built-in `image_gen` tool by default for normal image generation and editing requests.25- Do not switch to CLI fallback for ordinary quality, size, or file-path control.26- For transparent images, ask built-in `image_gen` for a transparent background and preserve the generated alpha.27- Never silently switch from built-in `image_gen` or CLI `gpt-image-2` to CLI `gpt-image-1.5`; ask the user first unless they explicitly requested `gpt-image-1.5`.28- The word `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.29- If the built-in tool fails or is unavailable, tell the user the CLI fallback exists and that it requires `OPENAI_API_KEY`. Proceed only if the user explicitly asks for that fallback.30- If the user explicitly asks for CLI mode, use the bundled `scripts/image_gen.py` workflow. Do not create one-off SDK runners.31- Never modify `scripts/image_gen.py`. If something is missing, ask the user before doing anything else.32 33Built-in save-path policy:34- In built-in tool mode, Codex saves generated images under `$CODEX_HOME/*` by default.35- Do not describe or rely on OS temp as the default built-in destination.36- Do not describe or rely on a destination-path argument (if any) on the built-in `image_gen` tool. If a specific location is needed, generate first and then move or copy the selected output from `$CODEX_HOME/generated_images/...`.37- Save-path precedence in built-in mode:38 1. If the user names a destination, move or copy the selected output there.39 2. If the image is meant for the current project, move or copy the final selected image into the workspace before finishing.40 3. If the image is only for preview or brainstorming, render it inline; the underlying file can remain at the default `$CODEX_HOME/*` path.41- Never leave a project-referenced asset only at the default `$CODEX_HOME/*` path.42- Do not overwrite an existing asset unless the user explicitly asked for replacement; otherwise create a sibling versioned filename such as `hero-v2.png` or `item-icon-edited.png`.43 44Shared prompt guidance for both modes lives in `references/prompting.md` and `references/sample-prompts.md`.45 46Fallback-only docs/resources for CLI mode:47- `references/cli.md`48- `references/image-api.md`49- `references/codex-network.md`50- `scripts/image_gen.py`51 52## When to use53- Generate a new image (concept art, product shot, cover, website hero)54- Generate a new image using one or more reference images for style, composition, or mood55- Edit an existing image (inpainting, lighting or weather transformations, background replacement, object removal, compositing, transparent background)56- Produce many assets or variants for one task57 58## When not to use59- Extending or matching an existing SVG/vector icon set, logo system, or illustration library inside the repo60- Creating simple shapes, diagrams, wireframes, or icons that are better produced directly in SVG, HTML/CSS, or canvas61- Making a small project-local asset edit when the source file already exists in an editable native format62- Any task where the user clearly wants deterministic code-native output instead of a generated bitmap63 64## Decision tree65 66Think about two separate questions:67 681. **Intent:** is this a new image or an edit of an existing image?692. **Execution strategy:** is this one asset or many assets/variants?70 71Intent:72- If the user wants to modify an existing image while preserving parts of it, treat the request as **edit**.73- If the user provides images only as references for style, composition, mood, or subject guidance, treat the request as **generate**.74- If the user provides no images, treat the request as **generate**.75 76Built-in edit semantics:77- Built-in edit mode is for images already visible in the conversation context, such as attached images or images generated earlier in the thread.78- If the user wants to edit a local image file with the built-in tool, first load it with built-in `view_image` tool so the image is visible in the conversation context, then proceed with the built-in edit flow.79- Do not promise arbitrary filesystem-path editing through the built-in tool.80- If a local file still needs direct file-path control, masks, or other explicit CLI-only parameters, use the explicit CLI fallback only when the user asks for it.81- For edits, preserve invariants aggressively and save non-destructively by default.82 83Execution strategy:84- In the built-in default path, produce many assets or variants by issuing one `image_gen` call per requested asset or variant.85- In the CLI fallback path, use the CLI `generate-batch` subcommand only when the user explicitly chose CLI mode and needs many prompts/assets.86- For many distinct assets, do not use `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.87 88Assume the user wants a new image unless they clearly ask to change an existing one.89 90## Workflow911. Decide the top-level mode: built-in by default, including transparent-output requests; fallback CLI only if explicitly requested or confirmed.922. Decide the intent: `generate` or `edit`.933. Decide whether the output is preview-only or meant to be consumed by the current project.944. Decide the execution strategy: single asset vs repeated built-in calls vs CLI `generate-batch`.955. Collect inputs up front: prompt(s), exact text (verbatim), constraints/avoid list, and any input images.966. For every input image, label its role explicitly:97 - reference image98 - edit target99 - supporting insert/style/compositing input1007. If the edit target is only on the local filesystem and you are staying on the built-in path, inspect it with `view_image` first so the image is available in conversation context.1018. If the user asked for a photo, illustration, sprite, product image, banner, or other explicitly raster-style asset, use `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.1029. Augment the prompt based on specificity:103 - If the user's prompt is already specific and detailed, normalize it into a clear spec without adding creative requirements.104 - If the user's prompt is generic, add tasteful augmentation only when it materially improves output quality.10510. Use the built-in `image_gen` tool by default.10611. For transparent-output requests, ask built-in `image_gen` for a transparent background and preserve the generated alpha channel.10712. Inspect outputs and validate: subject, style, composition, text accuracy, and invariants/avoid items.10813. Iterate with a single targeted change, then re-check.10914. For preview-only work, render the image inline; the underlying file may remain at the default `$CODEX_HOME/generated_images/...` path.11015. For project-bound work, move or copy the selected artifact into the workspace and update any consuming code or references. Never leave a project-referenced asset only at the default `$CODEX_HOME/generated_images/...` path.11116. For batches or multi-asset requests, persist every requested deliverable final in the workspace unless the user explicitly asked to keep outputs preview-only. Discarded variants do not need to be kept unless requested.11217. If the user explicitly chooses or confirms the CLI fallback, then use the fallback-only docs for model, quality, size, `input_fidelity`, masks, output format, output paths, and network setup.11318. Always report the final saved path(s) for any workspace-bound asset(s), plus the final prompt or prompt set and whether the built-in tool or fallback CLI mode was used.114 115## Transparent image requests116 117Ask built-in `image_gen` for a genuinely transparent background and preserve its alpha.118 119## Prompt augmentation120 121Reformat user prompts into a structured, production-oriented spec. Make the user's goal clearer and more actionable, but do not blindly add detail.122 123Treat 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.124 125### Specificity policy126 127Use the user's prompt specificity to decide how much augmentation is appropriate:128 129- If the prompt is already specific and detailed, preserve that specificity and only normalize/structure it.130- If the prompt is generic, you may add tasteful augmentation when it will materially improve the result.131 132Allowed augmentations:133- composition or framing hints134- polish level or intended-use hints135- practical layout guidance136- reasonable scene concreteness that supports the stated request137 138Not allowed augmentations:139- extra characters or objects that are not implied by the request140- brand names, slogans, palettes, or narrative beats that are not implied141- arbitrary side-specific placement unless the surrounding layout supports it142 143## Use-case taxonomy (exact slugs)144 145Classify each request into one of these buckets and keep the slug consistent across prompts and references.146 147Generate:148- photorealistic-natural — candid/editorial lifestyle scenes with real texture and natural lighting.149- product-mockup — product/packaging shots, catalog imagery, merch concepts.150- ui-mockup — app/web interface mockups and wireframes; specify the desired fidelity.151- infographic-diagram — diagrams/infographics with structured layout and text.152- scientific-educational — classroom explainers, scientific diagrams, and learning visuals with required labels and accuracy constraints.153- ads-marketing — campaign concepts and ad creatives with audience, brand position, scene, and exact tagline/copy.154- productivity-visual — slide, chart, workflow, and data-heavy business visuals.155- logo-brand — logo/mark exploration, vector-friendly.156- illustration-story — comics, children’s book art, narrative scenes.157- stylized-concept — style-driven concept art, 3D/stylized renders.158- historical-scene — period-accurate/world-knowledge scenes.159 160Edit:161- text-localization — translate/replace in-image text, preserve layout.162- identity-preserve — try-on, person-in-scene; lock face/body/pose.163- precise-object-edit — remove/replace a specific element (including interior swaps).164- lighting-weather — time-of-day/season/atmosphere changes only.165- background-extraction — transparent background / clean cutout. Ask built-in `image_gen` for actual transparency.166- style-transfer — apply reference style while changing subject/scene.167- compositing — multi-image insert/merge with matched lighting/perspective.168- sketch-to-render — drawing/line art to photoreal render.169 170## Shared prompt schema171 172Use the following labeled spec as shared prompt scaffolding for both top-level modes:173 174```text175Use case: <taxonomy slug>176Asset type: <where the asset will be used>177Primary request: <user's main prompt>178Input images: <Image 1: role; Image 2: role> (optional)179Scene/backdrop: <environment>180Subject: <main subject>181Style/medium: <photo/illustration/3D/etc>182Composition/framing: <wide/close/top-down; placement>183Lighting/mood: <lighting + mood>184Color palette: <palette notes>185Materials/textures: <surface details>186Text (verbatim): "<exact text>"187Constraints: <must keep/must avoid>188Avoid: <negative constraints>189```190 191Notes:192- `Asset type` and `Input images` are prompt scaffolding, not dedicated CLI flags.193- `Scene/backdrop` refers to the visual setting. It is not the same as the fallback CLI `background` parameter, which controls output transparency behavior.194- Fallback-only execution notes such as `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.195 196Augmentation rules:197- Keep it short.198- Add only the details needed to improve the prompt materially.199- For edits, explicitly list invariants (`change only X; keep Y unchanged`).200- If any critical detail is missing and blocks success, ask a question; otherwise proceed.201 202## Examples203 204### Generation example (hero image)205```text206Use case: product-mockup207Asset type: landing page hero208Primary request: a minimal hero image of a ceramic coffee mug209Style/medium: clean product photography210Composition/framing: wide composition with usable negative space for page copy if needed211Lighting/mood: soft studio lighting212Constraints: no logos, no text, no watermark213```214 215### Edit example (invariants)216```text217Use case: precise-object-edit218Asset type: product photo background replacement219Primary request: replace only the background with a warm sunset gradient220Constraints: change only the background; keep the product and its edges unchanged; no text; no watermark221```222 223## Prompting best practices224- Structure prompt as scene/backdrop -> subject -> details -> constraints.225- Include intended use (ad, UI mock, infographic) to set the mode and polish level.226- Use camera/composition language for photorealism.227- Only use SVG/vector stand-ins when the user explicitly asked for vector output or a non-image placeholder.228- Quote exact text and specify typography + placement.229- For tricky words, spell them letter-by-letter and require verbatim rendering.230- For multi-image inputs, reference images by index and describe how they should be used.231- For edits, repeat invariants every iteration to reduce drift.232- Iterate with single-change follow-ups.233- If the prompt is generic, add only the extra detail that will materially help.234- If the prompt is already detailed, normalize it instead of expanding it.235- For CLI fallback only, see `references/cli.md` and `references/image-api.md` for model, `quality`, `input_fidelity`, masks, output format, and output-path guidance.236- For transparent images, ask built-in `image_gen` for actual transparency and preserve its alpha.237 238More principles shared by both modes: `references/prompting.md`.239Copy/paste specs shared by both modes: `references/sample-prompts.md`.240 241## Guidance by asset type242Asset-type templates (website assets, game assets, wireframes, logo) are consolidated in `references/sample-prompts.md`.243 244## gpt-image-2 guidance for CLI fallback245 246The fallback CLI defaults to `gpt-image-2`.247 248- Use `gpt-image-2` for new CLI/API workflows unless the user confirms a different model.249- CLI `gpt-image-2` does not support `background=transparent`; ask before using `gpt-image-1.5` unless the user explicitly requested that model.250- `gpt-image-2` always uses high fidelity for image inputs; do not set `input_fidelity` with this model.251- `gpt-image-2` supports `quality` values `low`, `medium`, `high`, and `auto`.252- Use `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.253- Square images are typically fastest to generate. Use `1024x1024` for fast square drafts.254- If the user asks for 4K-style output, use `3840x2160` for landscape or `2160x3840` for portrait.255- `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`.256 257Popular `gpt-image-2` sizes:258- `1024x1024` square259- `1536x1024` landscape260- `1024x1536` portrait261- `2048x2048` 2K square262- `2048x1152` 2K landscape263- `3840x2160` 4K landscape264- `2160x3840` 4K portrait265- `auto`266 267## Fallback CLI mode only268 269### Temp and output conventions270These conventions apply only to the CLI fallback. They do not describe built-in `image_gen` output behavior.271- Use `tmp/imagegen/` for intermediate files (for example JSONL batches); delete them when done.272- Write final artifacts under `output/imagegen/`.273- Use `--out` or `--out-dir` to control output paths; keep filenames stable and descriptive.274 275### Dependencies276Prefer `uv` for dependency management in this repo.277 278Required Python package:279```bash280uv pip install openai281```282 283Optional for image inspection and downscaling:284```bash285uv pip install pillow286```287 288Portability note:289- If you are using the installed skill outside this repo, install dependencies into that environment with its package manager.290- In uv-managed environments, `uv pip install ...` remains the preferred path.291 292### Environment293- `OPENAI_API_KEY` must be set for live API calls.294- Do not ask the user for `OPENAI_API_KEY` when using the built-in `image_gen` tool.295- Never ask the user to paste the full key in chat. Ask them to set it locally and confirm when ready.296 297If the key is missing, give the user these steps:2981. Create an API key in the OpenAI platform UI: https://platform.openai.com/api-keys2992. Set `OPENAI_API_KEY` as an environment variable in their system.3003. Offer to guide them through setting the environment variable for their OS/shell if needed.301 302If installation is not possible in this environment, tell the user which dependency is missing and how to install it into their active environment.303 304### Script-mode notes305- CLI commands + examples: `references/cli.md`306- API parameter quick reference: `references/image-api.md`307- Network approvals / sandbox settings for CLI mode: `references/codex-network.md`308 309## Reference map310- `references/prompting.md`: shared prompting principles for both modes.311- `references/sample-prompts.md`: shared copy/paste prompt recipes for both modes.312- `references/cli.md`: fallback-only CLI usage via `scripts/image_gen.py`.313- `references/image-api.md`: fallback-only API/CLI parameter reference.314- `references/codex-network.md`: fallback-only network/sandbox troubleshooting for CLI mode.315- `scripts/image_gen.py`: fallback-only CLI implementation. Use only when the user explicitly chooses or confirms CLI mode.316 Discovery context
Discovered by repository scan. No exact path reference found in the snapshot’s root AGENTS.md.
