---
name: prompt-gen
description: Sub-agent skill for prompt compilation. Reads shot plan for an episode and generates model-specific prompts per shot using prompt_engine.py builders. Validates prompt length/format against model profiles.
allowed-tools: Read, Bash, Glob, Grep
argument-hint: "--episode 1 [--model gemini-3-pro-image-preview] [--dry-run]"
---

# /prompt-gen — Prompt Generation Sub-Agent

Reads a shot plan for an episode and compiles model-specific prompts for each shot using the prompt builders in `lib/prompt_engine.py`. Validates prompt length and format against the target model's profile.

## What This Agent Does

1. Loads episode plan from `state/visual/plans/ep_{NNN}_plan.json`
2. Loads Global Bible for character/location reference data
3. For each shot record:
   a. Determines target model from routing data (still vs video, complexity tier)
   b. Calls appropriate prompt builder:
      - `build_prompt_from_plan()` for production prompts
      - `build_previs_prompt()` for previs gate prompts
      - `build_grid_prompt()` for grid planning prompts
      - `build_cinematic_prompt()` for legacy format
   c. Applies kinetic descriptor enrichment
   d. Applies wide-shot branching (strip facial demands for WS/LS)
   e. Applies ENV sanitization for environment-only shots
4. Validates compiled prompts against model profile constraints
5. Outputs enriched plan with compiled prompts

## Prompt Validation

- Prompt length must not exceed model's max token limit
- Prompt must contain lighting vector lock (directional coordinates)
- Prompt must use positive constraints (not negative language)
- ENV shots must be sanitized (no human-presence language)
- Wide shots must not contain facial detail demands
- Two-character shots must use spatial syntax ("LEFT SIDE: ... RIGHT SIDE: ...")

## Model-Specific Format

Each model has different prompt requirements (from `config/model_profiles.json`):
- **NBP/Flash** (genai_inline): Full cinematic prompt with kinetic descriptors
- **Kling** (kling_rest): Simplified prompt, separate negative prompt field
- **SeedDance** (fal_ai): Scene-level prompt with per-shot sections
- **Veo** (genai_inline): Duration-aware prompt with camera movement descriptors

## Parallelism

The orchestrator dispatches prompt-gen agents in parallel per scene within an episode (since scenes are independent prompt compilation units).

## Implementation

Primary code: `lib/prompt_engine.py` — all prompt builders
Model profiles: `config/model_profiles.json`
Schema: `lib/render_schema.py` → `PromptData`, `PromptSkeleton`
