Ai video plan

From theSamPadilla/montaj · View interactive version

Ai video plan is an AI agent skill from the GitHub repository theSamPadilla/montaj. Agent-authored director skill for the ai_video workflow: story clarification, storyboard writes, approval gate. Load this when you hit montaj/ai-video-plan in a workflow or encounter a project with projectType: 'ai_video'.

How to use this skill

Skill file

AI Video Director

You are the director for an ai_video project. The workflow file workflows/ai_video.json lists two skill steps: plan (this skill) and generate (montaj/ai-video-generate). You also orchestrate analyze_style (montaj/analyze_media) and generate_ref (montaj/generate_image); the engine doesn't auto-execute anything.

This skill covers what to create (story clarification, storyboard writes, approval gate) and how to do it well (prompt structure, camera vocabulary, character consistency). For generation execution (Phases 6-7: dispatch, clip writing, audio assembly, regenQueue), see skills/ai-video-generate/SKILL.md.

Sub-skills

| Name | Path | When to load |

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

| camera-vocabulary | skills/camera-vocabulary/SKILL.md | Planning scenes in Phase 1 — shot scale + camera move selection |


Status machine

pending → storyboard_ready → draft → final

| Transition | Writer | Precondition |

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

| pending → storyboard_ready | you (agent) | Phase 1 writes complete: imageRefs anchors+images filled, styleAnchor written, scenes[] populated. tracks[0].items still []. |

| storyboard_ready → storyboard_ready | you (agent) in review-phase | User asks for storyboard changes via chat. Mutate project.json; status stays storyboard_ready. |

| (implicit, UI-driven) | UI | User clicks Approve. UI writes storyboard.approval = {approvedAt: <ISO8601>}. Status stays storyboard_ready — the ai-video-generate skill observes the field and starts Phase 6. |

| storyboard_ready → draft | ai-video-generate | Every storyboard.scenes[i] has a matching clip in tracks[0].items (either generation.sceneId === scene.id OR a batchShots[] entry for it). |

| draft → final | human (via UI) | Manual review. Out of scope for this skill. |


Parsing the intake

init.py creates the pending project. The agent-observable state:

Audio intake fields

Two optional fields in storyboard control audio generation:

Both are project-wide, not per-scene. They never appear in scenes[]. If set, they modify how you write scene prompts at Phase 1 — see the "Dialogue rule" below.

The source: "upload" | "text" split on imageRefs:

source is immutable. Never mutate it.


Phase 0 — Story clarification (before any writes)

The story is the most important input. Do not write scenes on a thin brief.

Read project.editingPrompt. Before touching storyboard.scenes, decide whether you have enough signal to plan a coherent story. Check:

If any of these is missing or ambiguous, ask the user before writing any scenes. Examples of good clarifying questions:

Rules for questioning

When the story is clear in your head → proceed to Phase 1.


Phase 1 — Storyboard phase contract (status: `pending`)

Before flipping status to storyboard_ready, all of the following must be true in project.json.

Reference handling — branch on `source`

For each storyboard.imageRefs[i]:

source: "upload" — user uploaded a file. refImages[0] is already set.

Example for a corgi character: "A small playful corgi with short legs, a long body, tan and golden fur with a white chest and belly, a fluffy white-tipped tail that curls upward, small pointed ears with tan fronts and white backs, round dark eyes with a friendly alert expression, a small black nose, bold black outlines with flat solid color fills, slightly exaggerated cartoon proportions with an oversized head relative to body."

source: "text" — user typed a description in anchor. refImages is empty.

Ref images are identity-only, not style. Do NOT fold styleAnchor into generate_image prompts. Refs answer "what does this character/object/place look like"; Kling applies style at scene-generation time. If the user explicitly wants style-baked refs, raise it in Phase 0 as a clarification — don't decide it silently.

Idempotency. Skip any imageRef whose refImages is already populated (from a prior run). Never regenerate silently.

After processing, every imageRefs[i] should have status: "ready".

Style analysis

For each storyboard.styleRefs[i]:

analyze_media --input <path> --prompt "Describe the visual/audio mood, aesthetic, palette, and camera feel of this reference in 1-3 sentences suitable for use as a style anchor for video generation."

Fold all outputs into a SINGLE storyboard.styleAnchor string — one cohesive anchor, not per-ref anchors. If there are no styleRefs, derive styleAnchor from the prompt alone (one concise style sentence) or leave it unset if the scenes don't need one.

Scene plan

Populate storyboard.scenes[] with one entry per intended scene.

Sections (use these ## headers):

```

## Camera

Shot size + camera motion. One sentence. Kling needs framing context first.

Example: "Wide shot, camera slowly pushes in."

## Subject

Who/what is in the scene. Anchor identity here — name the character,

describe their pose/position. This is the first thing Kling renders.

Example: "Rennie sits at the top of the yellow slide, gripping the railings."

## Action

What happens. EVERY sentence must have a motion verb — describe how

things MOVE, not how they look. Sequential phrasing ("First... then...").

BAD: "Rosie waits at the bottom." (static)

GOOD: "Rosie wags her tail and tilts her head up." (motion)

## Dialogue

Voice-tagged speech lines. Prefix each line with a voice tag:

(gender, ~age, tone) Character says: "line"

Example:

(female, ~8yo, gentle nervous voice) Rennie says: "It looks high."

(female, warm friendly dog voice) Rosie says: "I am right here."

OMIT this section entirely if the scene has no dialogue. Do NOT include

an empty ## Dialogue section — it wastes prompt budget and may cause

Kling to generate gibberish audio trying to fill it.

```

### Dialogue rule (voiceover override)

If storyboard.voiceover is set, OMIT the ## Dialogue section from EVERY scene prompt. Kling-generated speech would compete with the TTS voiceover track. Ambient SFX (generated via sound: "on") is fine and complements the narration.

When storyboard.voiceover is NOT set, you MAY include ## Dialogue in scene prompts as before.

Setting is NOT a section — put environment details in storyboard.styleAnchor once. If a scene needs specific lighting, include it in ## Camera (e.g. "Golden hour lighting, wide shot").

The step parses ## sections, reorders to optimal Kling sequence (Camera → Subject → Action → Dialogue), adds periods between sections, and flattens into flowing prose. The agent can write sections in any order — the step normalizes.

Keep each scene's prompt under ~80 words (excluding headers). Kling's sweet spot is 60-100 words for the scene-specific content. The step adds ~10 words of style prefix on top.

Max 4-5 distinct nouns per scene. Count every character, object, and named prop. If over 5, simplify or split into two scenes.

Scene count and pacing are your call — guided by the prompt structure and camera vocabulary sub-skills.

Duration budgeting (how to reason about total video time)

The final video's length is the sum of per-scene durations. Kling generates each scene at exactly the duration you request; there is no post-hoc stretching or trimming. You are deciding both total length AND pacing.

Three interacting constraints:

  1. Per-scene duration depends on the model. Three models are available:

No floats (8.5 will be rejected or silently clamped). In multi-shot mode (v3-omni only) the floor drops to 1.

  1. Min 1 scene per project, no upper cap from the API. In multi-shot mode, max 6 shots per call — split into multiple batches if the storyboard has more.
  1. storyboard.targetDurationSeconds is a SOFT total, not a hard constraint. Treat as editorial guidance:
Allocation algorithm (reference)

Given T = targetDurationSeconds and N = intended scene count:

  1. Baseline b = round(T / N). Clamp to [3, 15].
  2. Assign b to every scene. Running total: N * b.
  3. Distribute remainder T - N*b (positive or negative) one second at a time.
  4. If you can't hit T without violating [3, 15], land on the closest achievable total and mention the deviation to the user ("Targeting 27s across 4 scenes; closest clean fit is 28s — OK?").
Examples

| targetDurationSeconds | scenes | allocation | total |

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

| 20 | 4 | [5, 5, 5, 5] | 20 |

| 30 | 4 | [7, 8, 7, 8] | 30 |

| 15 | 6 | impossible (min 3x6 = 18). Prefer 5 scenes at [3,3,3,3,3] = 15, OR tell user "closest is 18s at 6 scenes". | |

| 90 | 6 | [15, 15, 15, 15, 15, 15] | 90 (max per-scene) |

| 120 | 6 | impossible (6 x 15 = 90 max). Must split: 8 scenes x 15 = 120. If >=7 scenes doesn't fit the story, tell the user. | |

Tracks + status


Phase 2 — Storyboard review (status: `storyboard_ready`, no `approval` yet)

Wait. The user is reviewing the storyboard in the UI.

If they ask for changes in chat, mutate project.json directly:

Keep status at storyboard_ready throughout. The UI also lets the user:

Neither of those requires agent involvement. You only transition out when the UI writes storyboard.approval (Phase 6).


Handoff to generation

After the user approves the storyboard (storyboard.approval is set), the workflow advances to the ai-video-generate step. Load skills/ai-video-generate/SKILL.md for Phase 6+ execution.


Field path reference

One table of every field you write, grouped by phase.

| Field | When | What |

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

| project.storyboard.imageRefs[i].anchor | pending | Clear text description the image generator / Kling can use. Written for both "upload" and "text" sources. |

| project.storyboard.imageRefs[i].refImages | pending | Append paths from generate_image calls. Leave untouched for source: "upload" entries. |

| project.storyboard.imageRefs[i].status | pending | Flip to "ready" when anchor + refImages are both set. |

| project.storyboard.styleAnchor | pending | One cohesive style-anchor string informed by styleRefs + prompt. |

| project.storyboard.scenes[i].* | pending | Per-scene editorial plan {id, prompt, duration, refImages}. User may edit .prompt directly via the UI. |

| project.status → storyboard_ready | end of Phase 1 | scenes[] populated, refs ready, styleAnchor written, tracks[0].items still []. |


What NOT to do

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.