Skip to main content
This page gives you a drop-in Agent Skill: run a check over the prompt before you generate, fill in the missing elements, strip the vague words that drag quality down, and generate with the rewritten version. The whole thing is two files with zero third-party dependencies.
When an image disappoints, the prompt is usually the problem — not the model and not the channel. This skill turns the “rewrite layer” from Advanced Image Generation into something you can drop into any coding agent.

What the skill does

Pre-generation diagnosis

Scores subject, environment, light, lens, grading and composition one by one, gives a 0-100 rating, lists the risks, and returns a rewritten prompt ready to copy.

Post-generation review

Pass the actual image along with the original prompt and the model reads it back, pointing out which sentence of the prompt was not executed and what the model added on its own, then rewrites accordingly.

Target-model advice

With -t it appends notes specific to that family: reference-image limits, mask support, and what the resolution parameter is called.

Subject-aware checks

Portraits get skin and lighting checks, product shots get background and text-ban checks, and illustration automatically down-weights the photorealism checklist.

A full diagnosis, start to finish

The input is what a user would actually type, plus the image it produced:
Coffee image from the casual prompt: wooden table, grinder, burlap sack and other props, with an invented brand name printed on the cup

The actual result produced by that casual prompt

Diagnosis output (excerpt from a real run):
Feeding that rewritten prompt back to the same model (gemini-3-pro-image), unchanged:
Coffee image from the rewritten prompt: a warm-white ceramic latte cup on a neutral light grey background, clear light direction, shadow falling to the rear right, no text anywhere, generous negative space

Regenerated from the rewritten prompt: a clean, usable e-commerce hero shot

Every prop is gone, the background is a controllable neutral grey, the shadow has a direction, no brand name was invented, and there is room for copy. The model did not change. Only the prompt did.

When to run the diagnosis

Not every generation needs a review. Decide by how specific the request already is:
This skill only rewrites prompts; it does not generate images. Pair it with the Nano Banana Pro Skill or the GPT-Image-2 Series Skill for a complete review-then-generate flow.

Which agents it works in

A Skill is really just a folder: one file telling the agent what it is (SKILL.md) plus a script that does the work. So any coding agent that can read local files and run commands can use it — Codex, OpenClaw, hermes-agent, Claude Code and others.The only requirement: the machine running the agent has Python 3 and network access (the script talks to api.apiyi.com directly). This skill uses only the Python standard library — nothing to pip install.

Install in three steps

1. Create the folder and paste the files

Create a skill folder with these two files (full contents in the two sections below):
No pip install needed.

2. Add your key next to it

Put your APIYI API key (created in the api.apiyi.com console) in image-prompt-doctor/.env:
The script reads the key from this .env automatically — no other configuration or environment variable required.
.env holds your secret. If this skill is shared through a project repository, add .env to .gitignore and never commit it.

3. Hand it to the agent

  • Agents with skill auto-discovery (such as Claude Code): drop the whole image-prompt-doctor/ folder into their skills directory — user level at ~/.claude/skills/, or project level at .claude/skills/ (shared through the repo).
  • Any other agent: place it according to that agent’s own skill/plugin convention; or simplest of all — just tell the agent to “read SKILL.md in this folder and follow it.”
That is the whole install. Jump to how to use it for examples.

SKILL.md

Create image-prompt-doctor/SKILL.md with the full content below (the description states “what it does + when to use it”, which is what the agent uses to auto-trigger it):

scripts/prompt_doctor.py

Create image-prompt-doctor/scripts/prompt_doctor.py with the full content below (Python standard library only, nothing to install):

Switching the diagnosis model

The default is gpt-5.6-luna — cheap ($0.2 input / $1.2 output per million tokens) and it accepts image input, which review mode needs. Two ways to change it:
Two things to watch when switching: review mode requires a model that accepts image input (a text-only model errors out on an attached image) — see Vision Understanding for the list. And the script sends response_format: {"type": "json_object"}, so a model without JSON mode may return fenced text instead (the script strips fences defensively, but prefer a model that supports JSON mode).

Why one sentence triggers the diagnosis

A common question: I never typed a command, so why did saying “draw me an image” make it review the prompt first? Here is the mechanism: at startup the agent reads the description in each skill’s SKILL.md — a short piece of metadata saying what the skill does and when it applies. When what you say matches that description (“draw me a …”, “why did this image come out wrong”, “improve this prompt”), the agent decides on its own to invoke the skill, reads the full SKILL.md, and runs the script. You never memorize a command. SKILL.md also states that a request which is already specific does not need the treatment, so it will not intervene on every prompt. When you want complete control, use explicit invocation below.

How to use it

Natural language (implicit trigger)

Once installed, just talk to the agent:

Explicit invocation (more control)

  • Agents with slash commands (such as Claude Code):
  • Any agent / just tell it to run the script (most universal):

Where the diagnosis goes

  • This skill writes no files. The result prints to the terminal and the agent relays it to you — score, six-element marks, risks, the rewritten prompt, what changed, and parameter suggestions.
  • To feed the result into your own program, add --json; the output is a structured object (score / elements / risks / optimized_prompt / changes / suggested_params) that you can redirect to a file:
  • Confirm the rewritten prompt before using it: a rewrite can shift the intent (turning “coffee” into “a latte”), and SKILL.md already tells the agent to ask first.
  • Images passed to review mode are never modified or overwritten — they are read-only input.

Cost

One diagnosis costs a few thousand tokens. At gpt-5.6-luna list price that is a fraction of a cent, while a single high quality generation costs tens of times more. Diagnosing before generating saves more in avoided retries than it costs. Review mode uploads an image, which is billed as input tokens — slightly more, still far below one generation.