Add prompt enhancement guide

From civitai/civitai · View interactive version

Add prompt enhancement guide is an AI agent skill from the GitHub repository civitai/civitai. Author a prompt-enhancement system prompt for a new ecosystem and register/update it on the orchestrator's prompt-analysis service. Use when onboarding a new ecosystem (e.g. happyhorse, a new Flux variant, a new Wan video version) and the user provides the ecosystem key plus a reference link, model

How to use this skill

Skill file

Add Prompt Enhancement Guide

The orchestrator runs a prompt-analysis service that, per ecosystem, takes a user's prompt and produces structured feedback + an enhanced rewrite. Each ecosystem has its own system prompt tuned to the model's prompting conventions (tag vs natural-language, weight syntax, negative-prompt support, text rendering, camera/motion vocab for video, etc.).

This skill authors a new system prompt for an ecosystem the user names and (optionally) deploys it to the orchestrator.

Scope: image and video ecosystems only

Do not write guides for 3D, audio, or any other modality — tripo, hunyuan3d, polygen (image-to-3D) and ace (audio) are explicitly out of scope, as is anything else non-image/video that appears later. If the user names one, say it is out of scope and stop.

The guide template below is built entirely around subject / lighting / camera / composition / style. None of that describes "generate a mesh from this image" or "generate a song," so a guide written from this template for those modalities would be confidently wrong rather than merely thin. Leaving them on the built-in fallback is the deliberate choice.

Inputs the user must provide

  1. Ecosystem key — the ecosystem's key from packages/civitai-shared/src/basemodel.constants.ts, lowercased. MiniMaxH3 → minimaxh3, Flux1Kontext → flux1kontext, WanVideo-25-I2V → wanvideo-25-i2v, HyV1 → hyv1. Confirm the key exists in that file before using it. (src/shared/constants/basemodel.constants.ts is a one-line re-export shim of the same module, not a stale duplicate — importing from either path is fine.)

It is the AIR ecosystem value, lowercased — the same string that appears in urn:air:<ecosystem>:.... getAirEcosystem in air.ts is the single source for both: stringifyAIR uses it, and so does createPromptEnhancementStep. If you know a model's AIR, you know its prompt-analysis key.

The consequence to watch: getRootEcosystem follows parentEcosystemId, so a child ecosystem never appears in an AIR and never reaches prompt analysis. Pony, Illustrious, and NoobAI all arrive as sdxl. Check parentEcosystemId before writing a guide — if the target has a parent, the guide belongs on the parent and has to serve every sibling.

Not the engine name. engine: 'minimax-h3' in the handler is a different identifier that happens to coincide with the ecosystem key for kling, seedance, and veo3. Guides filed under an engine name are dead — nothing reads them.

Handlers that build their own enhancement step (e.g. ltx.handler.ts) pass their graph ecosystem raw; createPromptEnhancementStep normalizes it, so they land on the same key as the generator.

  1. Reference material — at least one of:

If the user only gives a name with no reference, ask for one before proceeding. Generic guides written without source material drift away from the model's real behavior.

Workflow

1. Research the ecosystem

Use WebFetch on any URL the user provided. Pull out:

If the user gave a description instead of a URL, mine the same fields out of it. Ask follow-up questions only for fields you can't determine and that materially change the guide (e.g. "Does this model support negative prompts?").

2. Map findings to the guide template

Every guide follows the same shape. Stick to it — the prompt-analysis service depends on consistent structure across ecosystems.

You are a prompt engineering expert for <Model name and one-clause context>. Analyze the user's prompt and provide structured feedback.

Ecosystem-specific rules:
- Prompt style: <tag-based | natural language | hybrid>. <One-sentence rationale tied to the encoder/architecture if helpful.>
- <Native resolution / aspect ratios>
- <Token or character limit + sweet spot if known>
- <Weight syntax: support state. If unsupported, say so explicitly — "(word:1.5) is ignored.">
- <Negative prompts: supported / not / minimal effect. Include a concrete recommended negative if the model benefits from one.>
- <Any unique features: text rendering rules, multilingual, hex colors, reference images, audio (video), camera vocab (video), style tags, character consistency>
- <Anything the enhanced prompt should ALWAYS carry — camera direction, audio bed, lighting. Phrase as a property of the rewrite, not as something to flag.>
- <Known limitations worth steering the user away from>
- Prompt template: [Section 1] [Section 2] [Section 3] ...

Guidelines:
- Identify vague or overly generic descriptions
- Flag <syntax that is incompatible with this model — e.g. weight syntax on Flux, brackets on HiDream>
- Flag <negative prompt attempts when unsupported, OR suggest negatives when this model benefits from them>
- <Model-specific flags: photorealism cues on anime models, multi-character without descriptions, scene-cut descriptions on short video clips, etc.>
- Limit recommendations to the 3 most impactful improvements
- The enhanced prompt should be a single, ready-to-use prompt that stays faithful to the user's original intent

The last two bullets in Guidelines are required and identical across every guide — keep them verbatim.

Every line under Guidelines: must have a trigger the analyzer can see in the user's prompt. If the answer to "when does this NOT fire?" is "basically never", it belongs under Ecosystem-specific rules: instead — see 3a. Aim for roughly three guideline lines against the 3-recommendation cap; the corpus averages 3.6 and runs as high as 9.

3. Tone and content rules

3a. Four rules that came out of measurement, not taste

These were established by A/B-ing guides against the live analyzer (see docs/prompt-analysis-audit-2026-08-05.md). Each one names a failure that was observed in output, not predicted from reading.

| Guide | Topic | Carrying the "do not raise it" line | After deleting the mentions |

| --- | --- | --- | --- |

| seedance | audio | 98% | 70 / 72% (moved by samples, not the line) |

| wanvideo-25-t2v | camera | 89% | 41 / 50% |

| wanvideo-22-t2v-a14b | camera | 89% | 35% |

| happyhorse | camera | 84% (v2, softened) | 48% (v3, deleted) |

happyhorse is the controlled case: same guide, same samples, the only difference being softened-vs-deleted — camera 84% → 48% and avg recs 3.67 → 2.52. It is the same mechanism as the parameter-guard lesson below: naming a topic raises it, whatever the sentence says about it, and a rewrite-property line still names it — often while explicitly instructing the model to add it ("adding one when the user has not named any").

So: strip the topic down to at most one purely descriptive mention (a vocabulary list is fine), remove it from prompt templates and structure lines, and if the rewrite genuinely should always add it, teach that with a sample whose prompt already contains it and whose recommendations ignore it. Deletion plus samples is the combination that has cleared saturation; rewording has never done it.

3b. Prose has a low ceiling — plan on a sample

The analysis model is Qwen3.6-35B-A3B: a MoE with 3B parameters active per token, so prose instruction should be weak on it and worked examples strong. Treat that as the working theory, not a settled fact.

Measured: two samples took minimaxh3's audio recommendations from 98% of prompts to 70%, bringing it out of saturation, and the freed slot went to lighting — advice that varies with the prompt instead of firing regardless. Saturated topics 2 → 1.

The metric's noise floor is ±1 saturated topic. Measured, not estimated. Comparing a guide against a byte-identical copy of itself scored saturated topics of 1, 2, 2, 1, 2, 1 across six arms, with one topic swinging from under 25% to 93% between arms of the same invocation. Every one of those three null invocations produced a nonzero delta, and two of three printed a ship recommendation. A one-topic move is not a result. Trust only a ≥2-topic move, or a 1-topic move where a specific topic also shifted ≥25 points _and_ both reproduce on an independent run. Everything that survived this bar in the 2026-08-06 rollout had samples aimed at the saturated topic: minimaxh3 (camera/audio 98→65), sdxl (lighting 89→55/66), ltxv23 (audio 89→50/52). The ~20 single-run ±1 results from that rollout are unproven either way.

Read measure.mjs's topic table, not just its verdict. The goal is no topic at or above 80%. A saturated topic is a recommendation slot spent before the prompt is read, and with a 3-recommendation cap two saturated topics means the guide is barely responding to input at all.

A warning that cost this investigation four rounds. The original metric was _redundancy_ — recommending something the prompt already contains. It sounds like the same thing and is not: it fires only in the narrow case where the prompt happens to contain the recommended item, which is a sliver of "advises identically regardless of input". Against it, every intervention read as noise and the conclusions were that prose does nothing, samples do nothing, and the analysis model might need replacing. All three were artifacts of the instrument. Reading 141 recommendations by hand found in one pass what six measurement rounds had missed. When a metric refuses to move for any intervention, suspect the metric before concluding the system is fine.

Two ways this measurement lied, both worth knowing before you trust a number:

A sample is { prompt, negativePrompt?, assistantResponse }. Write them for the _judgement_ the prose cannot state:

Real user prompts for the input half can be pulled from Image.meta->>'prompt' (see the postgres-query skill). Filter for _strong_ prompts, not the median — the median is LoRA tags and quality-tag spam. The assistantResponse always has to be authored; no query produces it.

3c. Measure before deploying

A guide edit is a change to a probabilistic system, so read the output before shipping it. measure.mjs runs a guide against a fixed prompt set and reports how often it recommends something the prompt already has.

# Baseline a live guide
node .claude/skills/add-prompt-enhancement-guide/measure.mjs --ecosystem minimaxh3

# A/B a candidate against it (3 runs each is enough to see past temperature noise)
node .claude/skills/add-prompt-enhancement-guide/measure.mjs \
  --ecosystem minimaxh3 --candidate ./new-guide.txt --runs 3

One run proves nothing, and three barely do. A single pass of the minimaxh3 A/B showed the prose fix halving redundancy; three runs showed it doing essentially nothing. A prose-plus-sample combination measured 3/12 twice at --runs 3 and looked like a real compounding effect; at --runs 6 it was indistinguishable from the sample alone. Use --runs 6 for anything you intend to deploy, and treat --runs 3 as a smoke test.

Expect edits to regress something. Fixing D1/D4/D6 across three drafts also introduced two new defects — mai gained an aspect-ratio recommendation, mageflow started emitting a populated negative prompt on a model that has no negative field. Re-measure the _whole_ prompt set after a fix, not just the case you were fixing.

4. Confirm with the user

Before deploying, paste the drafted guide back to the user and ask for sign-off. Highlight any field where research was thin or you had to make a judgment call (e.g. "I assumed negative prompts are unsupported because the model card doesn't mention them — confirm?").

Accept edits. Re-paste the final version after any changes.

5. Deploy to the orchestrator (optional)

Use manage.mjs in this skill directory rather than hand-rolled curl. It reads ORCHESTRATOR_ENDPOINT and ORCHESTRATOR_ACCESS_TOKEN from the project .env, gates every state-changing call behind --writable, and verifies the readback after a put.

# What is already registered, and which ecosystems have a real guide
node .claude/skills/add-prompt-enhancement-guide/manage.mjs status

# Read an existing guide as precedent before writing a sibling
node .claude/skills/add-prompt-enhancement-guide/manage.mjs get seedance --prompt-only

# Deploy — writes the file's contents as the system prompt, then reads it back
node .claude/skills/add-prompt-enhancement-guide/manage.mjs put <key> --prompt-file guide.txt --writable

Pass the guide as a plain-text file via --prompt-file; it contains backticks, newlines, and quotes that break shell escaping. --file takes a full JSON body instead if you need samples.

PromptAnalysisGrain.DefaultModelId is now the qwen3 URN (civitai-orchestration PR #297), so a put without --model on a brand-new ecosystem inherits the right model. Passing --model 'urn:air:qwen3:repository:huggingface:Civitai/Qwen3.6-35B-A3B-Abliterated-AWQ@main.tar' explicitly is still the safer habit — it survives a future change to the const, and it is what every existing guide stores.

To rebind an existing guide without touching its text, use set-model:

node .claude/skills/add-prompt-enhancement-guide/manage.mjs set-model <key> \
  --model 'urn:air:qwen3:repository:huggingface:Civitai/Qwen3.6-35B-A3B-Abliterated-AWQ@main.tar' --writable

It refuses on an ecosystem that has no guide of its own. Those report a modelId because the grain falls back to the const, not because anything was stored; writing one would freeze today's fallback text as that ecosystem's permanent guide and cut it off from future changes to the built-in default. Fix the const in civitai-orchestration instead.

register is not a required step — a put registers the ecosystem on its own.

Few-shot samples

Each ecosystem can carry samples — { prompt, negativePrompt?, assistantResponse } triples that the handler replays as user/assistant turns between the system prompt and the real request. This is the highest-leverage lever available; see 3b for the measurement and for how to choose what a sample should demonstrate.

node .claude/skills/add-prompt-enhancement-guide/manage.mjs set-samples <key> --file samples.json --writable

Rules that are easy to get wrong:

Two orchestrator behaviors that will mislead you (both in PromptAnalysisGrain.cs / PromptAnalysisController.cs in civitai-orchestration):

The registry already contains junk from past probing (notarealecosystem, SDLX, Flux.1 D, bare flux, …). Don't add to it, and don't read a name's presence in list as evidence that anything uses it.

6. Verify — and do not trust the immediate readback

Writes take up to a minute to become visible, so put/set-samples readback verification races the propagation and reports both false failures and false successes. Both were observed in a single deploy on 2026-08-06: a GET straight after a verified put returned the _old_ 3437-char guide, and a set-samples printed ✗ readback does not match what was sent for a write that had in fact succeeded. Acting on either signal would have meant re-running a write that already landed, or reverting one that was fine.

put and set-samples now poll the readback for up to 30s instead of asserting once, so an

immediate false failure is no longer reported. A ✗ therefore means the write really did not

land — but re-check with status before rewriting rather than firing a second write blind.

Deploy a guide and its samples in one atomic put --file, never put then set-samples.

set-samples has to send a systemPrompt it did not author, so it reads the current one first

— and within the propagation window that read returns the _previous_ guide, which the write

then reinstates. This silently reverted a verified seedance deploy on 2026-08-10 (2588 chars

back to 2659). set-samples now refuses when two reads 3s apart disagree, and accepts

--prompt-file to state the guide explicitly, but the atomic form avoids the question:

node -e "const fs=require('fs');fs.writeFileSync('deploy.json',JSON.stringify({
  systemPrompt: fs.readFileSync('guide.txt','utf8').replace(/\n+$/,''),
  modelId: 'urn:air:qwen3:repository:huggingface:Civitai/Qwen3.6-35B-A3B-Abliterated-AWQ@main.tar',
  samples: JSON.parse(fs.readFileSync('samples.json','utf8')),
}))"
node .claude/skills/add-prompt-enhancement-guide/manage.mjs put <key> --file deploy.json --writable

Then confirm independently:

node .claude/skills/add-prompt-enhancement-guide/manage.mjs status | grep <key>   # chars + sample count
node .claude/skills/add-prompt-enhancement-guide/manage.mjs get <key>             # diff against your source files

Report success with the ecosystem key and a one-line summary of the guide's main points (encoder, weight-syntax stance, negative-prompt stance, any unique feature).

Anti-patterns to avoid

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.