Imagine — image-tool doctrine
Apply this whenever an image is about to be generated or edited.
Build accurate visuals with code, not image models
Image models are unreliable at exact text, numbers, and structure. They garble
words, invent numbers, draw chart bars that match no data, and point diagram
arrows nowhere — and the more that must be exact, the worse they do. A detailed
prompt doesn't fix it, and an edit pass usually won't either.
When the result needs specific text, data, or structure to be CORRECT, construct
it with a code-driven tool where the content is exact:
| Need |
Tool |
| Chart/plot from real numbers |
data.chart |
| Org chart, mind map, tree, hierarchy |
media.diagram |
| Flowchart, sequence, state diagram |
media.mermaid |
| Math/equations |
media.equation |
| Code screenshot |
media.code-image |
| Rich layout, tables, real copy, UI mockup |
build HTML/CSS → browser.screenshot (or document.pdf-from-html) |
HTML/CSS gives far better layout, typography, and polish than image models or
Python plotting. Reserve the image models for when only the LOOK matters:
photos, illustrations, characters, scenes, decorative art. Choose by what the
output must get right, not by how the request is worded.
Choosing the generation tool
media.grok-image — FREE on the owner's Grok web lane; prefer it when
available (owner-only, needs SUDO_GROK_WEBSESSION).
media.image-generate — metered API providers (DALL-E 3, Stable Diffusion,
Flux) when the free lane is unavailable or unsuitable.
media.image-edit-advanced — operate on an EXISTING image: remove
background, upscale, inpaint, resize/crop/rotate/watermark/convert.
Verify discrete accuracy (loop)
When the output must get text, numbers, or structure right, never trust the
first result:
- Produce it (generate, or build with code per the table above).
- Read the actual output back with vision and check every word, number, label,
and structural detail; check nothing overlaps, clips, or runs off-canvas.
- If wrong: garbled text or invented numbers from an image model → do NOT
re-prompt (it will garble again) — rebuild with code. Overlap/clipping in a
code-built asset → fix the layout (auto-layout beats nudging coordinates).
Otherwise make one targeted edit.
- Finish only when the discrete content is exactly right. If it can't be made
accurate, say so instead of shipping something wrong.
Core rules
- Own the prompt. If the user supplies a detailed prompt, use it verbatim.
Otherwise craft it: front-load the subject; give strong high-level direction
for mood, composition, lighting, style; natural prose, not keyword tags;
describe positively (no negative prompts). For edits, describe only what
changes. Target 2–5 sentences.
- Reference-first for real people. Never generate a named real person or
group from scratch — including face swaps, posters, cartoons, cinematic or
editorial depictions. Start from a real reference photo and use
media.image-edit-advanced (inpaint) on it. Never produce non-consensual,
sexualized, or minor-involving likenesses.
- Ground facts with search first. If the request depends on a real-world
fact, identity, brand, place, event, or "latest/current" anything, run a web
search first and put the VERIFIED details into the prompt. No placeholders
like "the current president" — write the verified name.
- Reuse a base image for consistency. When the same character, object, or
setting must appear across multiple images, generate one base image, then
derive every variation from it with
media.image-edit-advanced. Don't
regenerate a recurring subject from scratch.
- Handle blocks gracefully. On a moderation/safety block: stop. Don't
retry, don't paraphrase to evade the filter. Tell the user and offer a
different direction.
- Plan multi-step workflows. Sequence dependent steps; parallelize only
generations within the same step. Review at the end that every intended
image actually got produced and matches the ask.
1---2name: imagine3description: Image-generation doctrine for the media.* tools — when to build a visual with code instead of an image model, prompt-craft, reference-first handling of real people, factual grounding, verify-by-reading-back, and cross-image consistency. Ported and adapted from grok's imagine skill.4---56# Imagine — image-tool doctrine78Apply this whenever an image is about to be generated or edited.910## Build accurate visuals with code, not image models1112Image models are unreliable at exact text, numbers, and structure. They garble13words, invent numbers, draw chart bars that match no data, and point diagram14arrows nowhere — and the more that must be exact, the worse they do. A detailed15prompt doesn't fix it, and an edit pass usually won't either.1617When the result needs specific text, data, or structure to be CORRECT, construct18it with a code-driven tool where the content is exact:1920| Need | Tool |21|------|------|22| Chart/plot from real numbers | `data.chart` |23| Org chart, mind map, tree, hierarchy | `media.diagram` |24| Flowchart, sequence, state diagram | `media.mermaid` |25| Math/equations | `media.equation` |26| Code screenshot | `media.code-image` |27| Rich layout, tables, real copy, UI mockup | build HTML/CSS → `browser.screenshot` (or `document.pdf-from-html`) |2829HTML/CSS gives far better layout, typography, and polish than image models or30Python plotting. Reserve the image models for when only the LOOK matters:31photos, illustrations, characters, scenes, decorative art. Choose by what the32output must get right, not by how the request is worded.3334## Choosing the generation tool3536- `media.grok-image` — FREE on the owner's Grok web lane; prefer it when37 available (owner-only, needs SUDO_GROK_WEBSESSION).38- `media.image-generate` — metered API providers (DALL-E 3, Stable Diffusion,39 Flux) when the free lane is unavailable or unsuitable.40- `media.image-edit-advanced` — operate on an EXISTING image: remove41 background, upscale, inpaint, resize/crop/rotate/watermark/convert.4243## Verify discrete accuracy (loop)4445When the output must get text, numbers, or structure right, never trust the46first result:47481. Produce it (generate, or build with code per the table above).492. Read the actual output back with vision and check every word, number, label,50 and structural detail; check nothing overlaps, clips, or runs off-canvas.513. If wrong: garbled text or invented numbers from an image model → do NOT52 re-prompt (it will garble again) — rebuild with code. Overlap/clipping in a53 code-built asset → fix the layout (auto-layout beats nudging coordinates).54 Otherwise make one targeted edit.554. Finish only when the discrete content is exactly right. If it can't be made56 accurate, say so instead of shipping something wrong.5758## Core rules59601. **Own the prompt.** If the user supplies a detailed prompt, use it verbatim.61 Otherwise craft it: front-load the subject; give strong high-level direction62 for mood, composition, lighting, style; natural prose, not keyword tags;63 describe positively (no negative prompts). For edits, describe only what64 changes. Target 2–5 sentences.652. **Reference-first for real people.** Never generate a named real person or66 group from scratch — including face swaps, posters, cartoons, cinematic or67 editorial depictions. Start from a real reference photo and use68 `media.image-edit-advanced` (inpaint) on it. Never produce non-consensual,69 sexualized, or minor-involving likenesses.703. **Ground facts with search first.** If the request depends on a real-world71 fact, identity, brand, place, event, or "latest/current" anything, run a web72 search first and put the VERIFIED details into the prompt. No placeholders73 like "the current president" — write the verified name.744. **Reuse a base image for consistency.** When the same character, object, or75 setting must appear across multiple images, generate one base image, then76 derive every variation from it with `media.image-edit-advanced`. Don't77 regenerate a recurring subject from scratch.785. **Handle blocks gracefully.** On a moderation/safety block: stop. Don't79 retry, don't paraphrase to evade the filter. Tell the user and offer a80 different direction.816. **Plan multi-step workflows.** Sequence dependent steps; parallelize only82 generations within the same step. Review at the end that every intended83 image actually got produced and matches the ask.