--- name: story-illustrator description: Generates a consistent illustrated image for every scene of a story — keeping characters, locations, and visual style coherent across the whole sequence using cascading reference images. Reads a {slug}_scenes.json (from scene-splitter), proposes a visual style, ASKS the user for the aspect ratio and image model, extracts a visual bible, drafts a continuity-classified shot list, generates one reference image per character + location, then one image per scene (with a strict no-text/no-border constraint), and records every image in {slug}_images.json. Images are generated through the Fal API via the bundled fal_image.py script, with a pluggable model registry (nano-banana-2, nano-banana-pro, seedream-4, or any Fal model you add). Use this skill whenever the user wants to illustrate a story, generate scene images, draw the pictures for a storybook, build the illustrations, or produce a consistent visual sequence. Trigger on phrases like "illustrate this story", "generate the images", "draw the scenes", "make the pictures", "visualize this story", or whenever scenes.json exists and the user wants images. Requires a Fal API key (FAL_KEY in the environment or a .env file). --- # Story Illustrator Turns a story (already split into scenes) into a sequence of illustrations with **consistent characters, locations, and style** — using cascading reference images to preserve continuity from scene to scene. This is where the storybook earns its polish. Naively prompting "scene 1", "scene 2", "scene 3" gives three different-looking children in three different rooms. This skill prevents that with a **bible → references → cascading scene images** workflow. ## When this skill applies `{slug}_scenes.json` exists (from `scene-splitter`) and the user wants images. Also applies if the user pastes a story and asks to illustrate it — in that case, run `scene-splitter` first (or fall back to building a quick internal shot list). The skill does NOT apply to: - Single one-off image requests with no narrative (run `fal_image.py` directly, or call an image tool). - Video/animation tasks. - Cases where the user only wants the bible or shot list as text, not actual images. ## Required tools — the image backend Images are generated through the **Fal API** using the bundled script [assets/fal_image.py](assets/fal_image.py). One call generates one image: ```bash python .claude/skills/story-illustrator/assets/fal_image.py \ --model nano-banana-2 --aspect 4:5 \ --prompt "" \ --ref --ref \ --out stories//_images/part_03.png ``` It submits to Fal, polls until done, **downloads the image locally**, and prints one JSON line: `{"url": "", "path": "", "model": "...", "cost_usd": 0.08}`. Capture **both** the `url` and the `path` (explained in Stage 5/6). **Why a script, not an MCP:** the only thing this skill needs from an image generator is the primitive *(prompt, reference image URLs, aspect ratio) → an image*. A small stdlib script over the Fal HTTP API does exactly that with one dependency — a `FAL_KEY` — and keeps the model choice fully in your hands. (Narration, by contrast, uses the ElevenLabs **MCP** — the repo deliberately demonstrates both integration styles.) **Before anything else**, confirm Fal is reachable: ```bash python .claude/skills/story-illustrator/assets/fal_image.py --check ``` If it prints `{"fal_key": false}` (exit 1), stop and tell the user to set `FAL_KEY` (env var, or a `.env` at the repo root — see the README). Don't proceed without it. ## Model registry — and choosing a model (ASK each run) Available models live in [assets/image-models.json](assets/image-models.json) — each entry maps a friendly key to its Fal endpoint, whether it accepts reference images (**required** for the cascade), how it encodes aspect ratio, and its cost per image. To add or swap a model, edit that file — no code change. The bundled defaults: | Key | Model | Cost/img | Best for | |---|---|---|---| | `nano-banana-2` | Nano Banana 2 (Google) | $0.08 | references + single-character scenes | | `nano-banana-pro` | Nano Banana Pro (Gemini 3 Pro Image) | $0.15 | multi-character beats, fine detail | | `seedream-4` | Seedream v4 (ByteDance) | $0.03 | cheapest; a different look / testing | **Picking the model is a HARD GATE — ask the user each run** (Stage 1). Read the live prices from `image-models.json` and offer: 1. **`nano-banana-2`** — fast & cheap, everywhere. 2. **`nano-banana-pro`** — best quality, everywhere. 3. **Smart mix** *(suggested)* — `nano-banana-pro` for scenes with **2+ characters in frame**, `nano-banana-2` for everything else **and** all reference plates. Best value: pay for the pro model only where multiple characters must stay coherent. 4. **`seedream-4`** (or any other registry key) — cheapest / alternative style. Whatever they pick, **references always use the cheapest reference-capable model** (`references_model` in the registry, default `nano-banana-2`) unless the user chose "pro everywhere." If the orchestrator pre-supplied a model choice, honor it and skip the prompt. ## Workflow — six stages (plus optional Stage 4.5 QA) A **Stage 4.5 vision-QA pass** is available between scene generation and finishing. It is **opt-in** (default OFF) — invoke with `qa`, `--qa`, or "with QA". It reviews the generated images and produces a suggestion table; it never auto-regenerates. ### Stage 0: Load scenes.json Read `{slug}_scenes.json` from `stories/{slug}/`. Each scene becomes exactly one image: - one image per scene, in order, indexed to match `scenes[i].index` - `panel_type` drives framing (`establishing` → wide; `action` → dynamic; `reaction` → close on face; `detail` → tight on object) — don't override it; that variety is what makes the gallery feel like a real book - `dominant_action` becomes the prompt body - `characters` selects which character references to attach - `scene` selects the location reference - `mood` informs lighting/color tone - output image is recorded as scene index `NN` so the publisher can pair it with `{slug}_part_NN.mp3` If no `scenes.json` exists, ask the user to run `scene-splitter` first. ### Stage 1: Connect and orient 1. Confirm Fal is reachable: run `python .claude/skills/story-illustrator/assets/fal_image.py --check`. If `fal_key` is false, stop and tell the user to set `FAL_KEY` (env var or `.env` at the repo root). Don't continue without it. 2. Propose ONE visual style based on the story's tone and audience — don't list five options. For beginner children's stories, a strong default is **"warm, soft watercolor children's-book illustration, gentle rounded shapes, cozy lighting."** The user can override. 3. **Determine the aspect ratio — HARD GATE, ask; do not pick silently.** If the orchestrator pre-supplied one (look for "Aspect ratio: `4:5`"), use that and skip the prompt. Otherwise ask: > "What aspect ratio? Common options: `4:5` portrait (storybook / phone, the default for picture books), `1:1` square, `3:4` portrait (book page), `16:9` widescreen. Pick one." Lock the answer for the whole run — it MUST be passed to every image call so the storybook is visually consistent. 4. **Determine the image model — HARD GATE, ask; do not pick silently** (it spends money). Read the model keys + live prices from [assets/image-models.json](assets/image-models.json) and present the four options from the *Model registry* section above (nano-banana-2 / nano-banana-pro / **Smart mix** *(suggested)* / seedream-4 or other). If the orchestrator pre-supplied a model, honor it and skip. Record the chosen **policy** (single model, or smart-mix) — Stage 5 applies it per scene. 5. State the scope with a real dollar estimate from the chosen model(s): "Style: [proposed]. Aspect: [answer]. Model: [choice]. N scenes + ~M references ≈ **$X.XX** (refs at $a, scenes at $b). Reply `go` to proceed." ### Stage 2: Build the visual bible Read [references/bible-extraction.md](references/bible-extraction.md) for the full process. Briefly: extract a Markdown bible covering **cast** (each recurring character's physical traits, clothing, distinguishing details, default expression), **locations** (each recurring place's key features + mood), **recurring props**, and the locked **style sheet**. Run the two-pass extraction (extract, then re-read the story to catch missed characters/locations) — don't skip the second pass. For anything the story doesn't physically describe, **invent specific, distinctive details** and record them. Specifics (exact clothing colors, hair style, a named accessory) are what make consistency *visible* across scenes; vague descriptions drift. Two special tables when relevant: - **Prop-state tracker** — if a key object visibly changes across scenes (a balloon inflating, a cup filling, a flower wilting then reviving), enumerate its state per scene. Otherwise the model defaults to the "neutral" version of the prop in every scene. Skip only if nothing changes state. - **Characters-in-frame map** — for stories with ≥3 named characters, list who must be VISIBLE in each scene (separate from who merely *exists*). Without it, close shots silently drop characters who should be in the background. **Editorial check (child-safe):** verify each character's design is modest and child-appropriate (shoulders/torso covered, sensible everyday clothing, no suggestive posing) *before* approving — fixing it after references are generated costs a regeneration per affected image. See CLAUDE.md → Editorial standards. Write the bible to `{slug}_bible.md` and pause: "Bible drafted — anything to change before I generate references?" (The user can edit the file directly or say `go`.) ### Stage 3: Generate reference images Generate one reference image per **consistent character** and per **recurring location**, using the references model (`references_model` in the registry — default `nano-banana-2`). Each is a single `fal_image.py` call with **no `--ref`** (references are generated from the prompt alone), saved under `stories//_images/`: ```bash python .claude/skills/story-illustrator/assets/fal_image.py \ --model nano-banana-2 --aspect \ --prompt "