The Complete Production SOP: How to Deploy and Run Image Generation Pro in Autonomous AI Agents
Production SOP to install and run Image Generation Pro in Codex, Claude Code, and Cursor. Master raster generation, asset pipelines, and transparent PNGs.
Technical Overview & Architectural Context
Autonomous coding agents frequently fail when handling media pipelines. When asked to create visual UI mockups, icons, or landing page graphics, default agents often generate invalid SVG representations, hallucinate external CDN URLs, write broken HTML canvas code, or silently overwrite critical production art assets without preserving alpha channels. Without strict procedural guardrails, agents lack awareness of transparent PNG compositing, aspect ratio constraints, and local directory standards. Image Generation Pro (`imagegen`) resolves these failure modes by enforcing deterministic procedural SOPs across autonomous runtimes like Codex, Claude Code, Cursor, and Windsurf. It establishes a hard hierarchy between runtime-native tool calling (`image_gen`) and programmatic fallback execution via localized Python scripts using Pillow and the OpenAI DALL-E API. The skill standardizes asset output locations into `/public` or `/assets`, strictly bans unconfirmed file overwrites, and enforces automated post-generation validation checks to ensure alpha channel integrity and correct bounding box geometry.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Create the local skill manifest directory and inject verified procedural rules into the agent runtime path.
Autonomous runtimes discover capabilities by indexing `.agents/skills` or `.claude/skills` directories on boot. By placing the audited SKILL.md in the project-level or global agents registry, the LLM reads frontmatter triggers ('generate image', 'create mockup', 'transparent cutout', 'app icon') and binds deterministic workflows prior to executing sub-tasks.
mkdir -p .agents/skills/imagegen && curl -fsSL https://askills.dev/api/skills/imagegen/raw -o .agents/skills/imagegen/SKILL.md---
name: "imagegen"
description: "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."
triggers:
- "generate image"
- "create mockup"
- "transparent cutout"
- "app icon"
---
# Image Generation SOP
1. Default built-in `image_gen` tool mode is preferred.
2. Fallback CLI mode (`scripts/image_gen.py`) requires OPENAI_API_KEY.
3. Destination must reside strictly in `public/` or `assets/`.
4. Preserve transparent alpha channels for cutouts and app icons.
5. Never overwrite existing files without explicit user confirmation.Keep the SKILL.md concise. Restricting rules to procedural boundaries rather than verbose background descriptions saves over 1,200 context tokens per agent reasoning cycle.
In Cursor and Windsurf, ensure the skill path is not excluded in `.cursorignore` or `.codeiumignore`, otherwise the agent cannot index triggers during prompt processing.
Environment Secrets & Dependency Validation
Inject required environment variables safely and install runtime image processing dependencies.
When the built-in tool is unavailable, the fallback mode executes localized Python scripts using Pillow and Requests. The agent requires `OPENAI_API_KEY` exported in its subshell context while keeping keys isolated from the LLM conversation context.
pip install --quiet pillow requests && echo "OPENAI_API_KEY=sk-proj-YOUR_API_KEY_HERE" >> .env.local && git update-index --skip-worktree .env.local 2>/dev/null || trueUse `git update-index --skip-worktree .env.local` to prevent accidental staging and commit of active OpenAI credentials during autonomous agent commits.
Never echo API keys in conversation prompts. Agents with bash tools can read environment variables natively without exposing secret tokens in raw LLM chat history.
Intent Matching & Trigger Invocation
Verify deterministic activation using tested natural language triggers.
Agents evaluate user intent against frontmatter triggers. Invoking canonical keywords such as 'generate image', 'create mockup', or 'transparent cutout' immediately switches the agent into deterministic design mode, forcing adherence to asset paths and format validation.
Specify dimensions, file format, and destination directory within the prompt (e.g., '1024x1024 PNG into public/assets') to bypass interactive ambiguity disambiguation cycles.
Omitting the word 'transparent' when requesting cutout assets will cause the DALL-E pipeline to default to solid white backgrounds, failing alpha-channel checks.
Verification, Linting & Output Quality Gate
Execute automated self-healing checks to confirm file existence, dimensions, and RGBA channel validity.
The imagegen SOP mandates that the agent verify generated assets before reporting task completion. A dedicated verification script checks format headers, image bounds, and alpha transparency.
python3 -c "from PIL import Image; img = Image.open('public/assets/hero-icon.png'); assert img.format == 'PNG'; assert img.mode in ('RGBA', 'LA'); print('Asset verification passed:', img.size)"Instruct the agent to review `git status --porcelain` to guarantee no unexpected root-level temporary image files (`output.png`, `temp.jpg`) linger after generation.
Pillow throws `UnidentifiedImageError` if the agent writes an empty 0-byte file or captures an HTTP error response body directly into an image filename.
Real-World Scenario: Autonomous Generation of Transparent SaaS Feature Icons for a Next.js Marketing Page
“We need a transparent cutout icon for our new real-time analytics feature. Generate image using imagegen, format as a 512x512 PNG, save to public/features/analytics-icon.png, and update the FeatureCard component to display it.”
Runtime Troubleshooting & Failure Modes
Root Cause: The fallback CLI script attempted to pass unsupported dimensions (e.g., 512x512) directly to the DALL-E 3 endpoint, which requires 1024x1024, 1024x1792, or 1792x1024.
python3 -c "from PIL import Image; img = Image.open('public/temp.png'); img.resize((512, 512), Image.Resampling.LANCZOS).save('public/features/analytics-icon.png', 'PNG')"Root Cause: The agent received a rate limit (HTTP 429) or authentication error (HTTP 401) from OpenAI and streamed the raw JSON error string directly into the file destination instead of binary image bytes.
rm public/assets/mockup.png && echo $OPENAI_API_KEY && python3 scripts/image_gen.py --prompt "Modern dashboard UI mockup" --output public/assets/mockup.png --debugFrequently Asked Questions (Image Generation Pro SOP)
Q:Can I use Image Generation Pro across Codex, Claude Code, and Cursor simultaneously?
Yes. Image Generation Pro adheres strictly to the universal SKILL.md specification. Whether mounted in `.agents/skills/imagegen`, `.claude/skills/imagegen`, or referenced in Cursor `.cursorrules`, the declarative frontmatter and operational rules are parsed identically across all modern LLM coding runtimes.
Q:How does Image Generation Pro prevent context window overflow during long agent sessions?
The skill avoids polluting system contexts with massive API reference payloads. It exposes terse conditional gates and delegates actual bitmap synthesis to sandboxed CLI execution or native agent tool calls, outputting only file paths and verification metadata back into the context window.
Q:Does this skill require escalated root or container permissions?
No. Audited at a 99/100 security score, Image Generation Pro operates strictly within the unprivileged user workspace. It requires only standard disk writes to `public/` or `assets/` and outbound HTTPS access to image generation endpoints.
Ready to equip your autonomous agent with Image Generation Pro?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.