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.
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:
The actual result produced by that casual prompt
gemini-3-pro-image), unchanged:

Regenerated from the rewritten prompt: a clean, usable e-commerce hero shot
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):pip install needed.
2. Add your key next to it
Put your APIYI API key (created in theapi.apiyi.com console) in image-prompt-doctor/.env:
.env automatically — no other configuration or environment variable required.
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.”
SKILL.md
Createimage-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
Createimage-prompt-doctor/scripts/prompt_doctor.py with the full content below (Python standard library only, nothing to install):
Switching the diagnosis model
The default isgpt-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:
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 thedescription 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. Atgpt-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.
Related documentation
- Advanced Image Generation: Workflow and Realism (where this skill sits in the full pipeline)
- How to Get the Image You Want (rescuing a single failed call)
- Nano Banana Pro Agent Skill (the companion generation skill to chain onto the diagnosis)
- GPT-Image-2 Series Agent Skill (same, for the GPT line)
- GPT-5.6 Luna (the default diagnosis model: specs, pricing and endpoint support)