OR Key
drop another .md file to compare - side-by-side diff against image-gen

image-gen

Generates an image from a description you type.
personal 2 files

What it does for you

Generates an image from a description you type.

What it produces

A recent result, so you can see the kind of work it returns.

loading…

How to get it

These run inside the Snappy workspace. Want this working in your business? I set skills like this up with you, in one focused week.

Work with me
For developers how this skill is built, graded, and how it runs

at a glance- the short version

actorGeneration model (DALL-E 3 or SDXL).
auditorGemini vision model
eval modeauto
categoryContent
stages6

what's inside - the parts that make up a skill 2/4 present

A skill is just a few plain-text files. Only the main one is required. The rest are optional, added as the work needs them. This is what the skill is made of; how it runs is just below.

The skill
state/skills/image-gen/SKILL.md present
the skill itself, in plain text
The main file. It says what the skill is and lays out the steps in plain English.
Code
state/lib/image-gen.ts not present
code the skill can run
Optional. Many skills are just words and need no code at all.
Scripts
state/bin/image-gen/ not present
helper scripts
Optional. Added when a skill has a few commands to run.
Loader
state/skills/image-gen/AGENTS.md present
what the AI loads on the fly
Loaded automatically the moment this skill is needed. Kept short on purpose.

how it runs - the shared frame every skill uses 5/5 present

Every skill runs the same way. One part does the work, a separate part checks it, and a short loader hands the AI exactly what it needs for the job. Anything this skill doesn't use shows a one-line note saying why, on purpose, not by accident.

makes the work The worker
present
Generation model (DALL-E 3 or SDXL). an AI model
Does the actual work. Whatever it produces is what gets checked next.
checks the work The reviewer
present
Gemini vision model the checker
A separate checker grades the work, so the part that made it can't approve its own work.
frame
learns Self-correction
present
fixes itself learns from gaps
When a run hits a gap, the skill gets edited on the spot [FIXED] or queued for a bigger rewrite [LOGGED], so it keeps getting better.
tidies up Background fixes
present
queued for rewrite runs in the background
Bigger fixes that can't be made on the spot get queued and rewritten in the background later.
remembers Run history
present
state/log/evals.ndjson auto runs
Every run is written down here, so the next time this skill is used it already knows how the last runs went.
Critical rules the things this skill must not get wrong
No must-not-break rules called out for this skill. Anything important lives in the writeup below.

what it has learned - fixes written back in over time sample

When a run hits something this skill didn't handle, the fix gets written back into the skill so it doesn't happen again. FIXED means it was corrected on the spot. LOGGED means it's queued for a bigger rewrite. Either way, the skill gets a little better and never makes the same mistake twice.

  1. Loading feedback rows…

how the work flows- who makes it, who checks it

actor Generation model (DALL-E 3 or SDXL).
1 generator
Expand the prompt
Rewrite the raw intent into a rich generation prompt.
# Expand subject into vivid detail: lighting, camera angle, color palette.
2 generator
Generate the image
Call the selected model API with the expanded prompt.
# DALL-E 3 path:
auditor Gemini vision model
3 auditor
Verify the output
Confirm the URL is reachable and the image is non-empty.
# HEAD <url>: expect 200 and content-type image/*
4 auditor
Return the result
Emit an ImagePreview card with the URL, prompt used, and model name.
# Return: { url, prompt_used, model, width, height, ts }

SKILL.md- the skill, written out in plain English

image-gen

Generate an image from a prompt, with a visible pipeline the user can inspect and edit.

The pipeline is the skill - editing a step mutates this file.

Steps

1. Parse intent

Extract the image subject, style, and mood from the user's prompt.

# No side effects. Extract: subject, style, mood, aspect ratio.
# Default aspect: 1024x1024 square. Default style: natural photorealistic.

2. Expand the prompt

Rewrite the raw intent into a rich generation prompt.

# Expand subject into vivid detail: lighting, camera angle, color palette.
# Keep under 400 chars for DALL-E 3 compatibility.
# Append negative: "blurry, watermark, low quality" to end.

3. Pick the model

Select the backend based on available credentials.

OPENAI_API_KEY_EXISTS=$([ -n "$OPENAI_API_KEY" ] && echo "yes" || echo "no")
REPLICATE_API_KEY_EXISTS=$([ -n "$REPLICATE_API_KEY" ] && echo "yes" || echo "no")
# if OPENAI_API_KEY: use dall-e-3
# elif REPLICATE_API_KEY: use stability-ai/sdxl
# else: emit graceful Callout (no key — skip generation)

4. Generate the image

Call the selected model API with the expanded prompt.

# DALL-E 3 path:
#   POST https://api.openai.com/v1/images/generations
#   body: { model: "dall-e-3", prompt: "<expanded>", n: 1, size: "1024x1024" }
#   response: data[0].url
#
# Replicate path:
#   POST https://api.replicate.com/v1/models/stability-ai/sdxl/predictions
#   body: { input: { prompt: "<expanded>", negative_prompt: "...", width: 1024, height: 1024 } }
#   poll until status="succeeded", response: output[0]

5. Verify the output

Confirm the URL is reachable and the image is non-empty.

# HEAD <url>: expect 200 and content-type image/*
# If fail: retry once, then emit Callout with "generation failed".

6. Return the result

Emit an ImagePreview card with the URL, prompt used, and model name.

# Return: { url, prompt_used, model, width, height, ts }
# Log to state/log/chain.ndjson: { ts, skill: "image-gen", url, model }

Eval

Actor: the generation model (DALL-E 3 or SDXL). Auditor: Gemini vision model inspects for subject match + quality.

OutcomeScore
URL reachable + subject present1.0
URL reachable, subject partially present0.5
Generation failed or no key0.0

Gotchas

  • Step 3 is the API key gate - if neither key exists, the pipeline short-circuits to a Callout. The user should see a helpful message with setup instructions, not an error.
  • DALL-E 3 does NOT support n > 1 with hd quality. Keep n=1.
  • Replicate predictions can take 15-45s. Poll every 2s with a 60s timeout.
  • Prompt expansion (Step 2) is the highest-leverage step - editing it is the most common user action.
  • Empty negative prompt causes poorer results. Always include the default negative.

AGENTS.md- what the AI loads when this skill comes up

image-gen - loader

Per-turn rules for the image-gen skill. Full skill: state/skills/image-gen/SKILL.md (6-step pipeline: parse intent → expand prompt → pick model → generate → verify → return).

Critical Rules

  1. Pipeline = SKILL.md Steps. Each ### N. Title is a step. Edit via POST /skills/image-gen/edit-step { step_index: N, new_body: "..." }.
  2. No-key fallback: emit Callout + PipelineDiagram. Show setup instructions if both OPENAI_API_KEY and REPLICATE_API_KEY absent. Never attempt generation without a key.
  3. Key gate: OPENAI → DALL-E 3 | REPLICATE → SDXL | neither → Callout only.
  4. DALL-E 3: n=1 only. Does NOT support n > 1 with hd quality.
  5. Replicate: poll every 2s, timeout 60s. Predictions 15-45s. Poll status="succeeded", return output[0].
  6. Step 2 (prompt expansion) is highest-leverage. Vivid detail (lighting, camera, palette), <400 chars, default negative "blurry, watermark, low quality".
  7. Feedback via POST /skills/:slug/feedback. Appends to state/skills/:slug/feedback.ndjson (rating 1-5).
  8. Pipeline history: git log --oneline -10 -- state/skills/image-gen/SKILL.md. Emit DiffView if ≥2 commits.
  9. Rollback via git is destructive. Warn user before git checkout HEAD~1 -- state/skills/image-gen/SKILL.md.

Commands

whatcommand
view pipelineGET http://127.0.0.1:3147/skills/image-gen/pipeline
edit step NPOST http://127.0.0.1:3147/skills/image-gen/edit-step body { step_index: N, new_body: "..." }
submit feedbackPOST http://127.0.0.1:3147/skills/image-gen/feedback body { rating: N, comment: "..." }
view skillcat ~/projects/snappy-os/state/skills/image-gen/SKILL.md
pipeline historygit -C ~/projects/snappy-os log --oneline -10 -- state/skills/image-gen/SKILL.md
rollback last editgit -C ~/projects/snappy-os checkout HEAD~1 -- state/skills/image-gen/SKILL.md
referencestate/skills/image-gen/SKILL.md

Self-Test

  • [ ] Pipeline = SKILL.md Steps, edit via POST /skills/image-gen/edit-step?
  • [ ] Emit Callout + PipelineDiagram when no API keys?
  • [ ] Route correctly: OpenAI → DALL-E 3, Replicate → SDXL?
  • [ ] DALL-E 3 n=1 only?
  • [ ] Replicate: poll 2s, timeout 60s?
  • [ ] Step 2 (prompt expansion) is highest-leverage?
  • [ ] Feedback appends to feedback.ndjson?
  • [ ] Pipeline history via git log?
  • [ ] Warn before destructive rollback?

<!-- kernel-ok: historical attribution for the PID-loader pattern. -->

Self-correcting loader (PID feedback)

This is the rule that makes loaders learn. Ported from snappy-kernel, where it demonstrably worked: the snappy-dom-cartographer skill mapped Skool admin UI once, every later ship-agent inherited the full map for free.

Before you finish, do two things:

1. Fix gaps (P - proportional). MANDATORY. If this loader didn't cover your case - if you had to read another file, run an undocumented command, work around a wrong selector, or discover a quirk - you MUST attempt an Edit to this AGENTS.md before you log.

  • Default action: edit this file. Surgical. Add the missing line, table

row, or code example where it belongs. No restructuring.

  • Only LOGGED is allowed when: the fix needs >10 lines, spans multiple

files, or requires a structural rewrite. In that case the state/regen/drain.sh queue picks it up asynchronously.

  • "I didn't have time" / "it's minor" / "the next agent will figure it out"

are NOT valid reasons. Minor gaps compound - that's the whole point of this loop.

  • Concrete example of a valid P-fix: discover agent-browser screenshot

takes path positionally not as --output <path>. One line in a table. Edit it in. Do not just log it.

  • The goal: the next agent never has to leave the loader.

2. Log the result.

echo "[$(date -u +%FT%TZ)] image-gen: <what was missing or fixed> [FIXED|LOGGED] action_kind=<kind>" >> state/log/loader-feedback.log
  • <slug> MUST be the literal folder name of this loader

(state/skills/<slug>/AGENTS.md). The class token between [ts] and : is the producer slug, the writeback class, AND the grade class - they must be equal so state/lib/controller-tune.ts can pair the brief.

  • FIXED = you patched this loader inline (P-fix).
  • LOGGED = too large for inline; the PostToolUse enqueue + Stop-hook drain

will rewrite the loader from scratch on next session-end.

  • action_kind is the SECOND pairing predicate. Pick the value that describes what you actually did:
  • shape-ok - frontmatter-shape verification only
  • skill-ran - the skill ran end-to-end with eval row in state/log/evals.ndjson
  • loader-rewritten - you EDITED this AGENTS.md inline (the FIXED case), OR regen rewrote it
  • pattern-elevated - you promoted a recurring failure to a Critical Rule

Do not skip this. Every agent run must leave the system better than it found it. The loader is the setpoint; you are the sensor; the gap is the error signal; closing the gap is the correction.

api.ts- the code it can call

⚠ no api.ts - this skill has no typed action surface

scripts- helper scripts it can run

prose-only skill - 6 inline code blocks live in SKILL.md above (no state/bin/ sidecar yet).

how we check it- the checks, plus the last 10 runs

rubric auto no rubric declared
recent no runs actor/auditor: unverifiable
deps none declared

no recent runs logged - the eval contract is declared but nothing has been graded yet