Blog
The team6 min read

How an AI writes a demo script from a diff

Our planner reads the pull request and the code on the branch, finds the real labels and test ids, and writes a scene plan you can edit like a text. Here is how.

A diff is a list of changed lines. A demo script is a story: open this page, type this, press that, see this result, and here is why it matters. Getting from one to the other is the part people assume is magic. It is not. It is mostly reading carefully.

This post walks through how our planner turns a pull request into a script, and why we built it the way we did.

What goes in

The script has one source of truth: the pull request. Its title and description, its commits, its diff, the ticket it closes (Linear or GitHub Issues), and the code on the branch. Everything the video says comes from there. Nothing is retyped by hand anywhere else.

That rule shapes everything below. If the video says a button exists, it is because the button is in the code. If it shows the button, it is because we pressed it.

The planner reads the branch, not a summary

The planner is an AI agent, run headless. It does not get a pasted summary of the pull request. It gets a copy of the repository at the head commit, made with git archive, and it works inside that copy.

It runs with read-only tools: read a file, search, list a folder. No shell, no network, no writes. Those three tools are enough to do what a careful person would do before filming:

  • Find the routes. Which page does this change live on? The pages folder answers that, so the scene can open the right URL.
  • Find the exact labels. A button called "Check" in English might be "Vérifier" in French. The planner reads the translation files for the language of the video and copies the exact visible string. It never guesses a label.
  • Find the stable handles. Test ids, aria labels, accessible names, Flutter widget keys. These survive a redesign. Visible text often does not.
  • Find the demo path. A Flutter app with a main_demo.dart runs on demo data with no backend, so the planner uses it. A web app gets example data it accepts in a local or test environment, never anything that writes to production or sends real mail or payments.

The temporary copy is deleted when the job ends. More on what is read and kept in Is it safe to let an AI read your code?.

Targets, most robust first

Every gesture in the script aims at a target. Some targets break the moment someone changes a margin. Others survive a full redesign. The planner is told to pick the most robust one available, in this order:

  1. a test id;
  2. a Flutter key;
  3. a role and an accessible name, like "the Check button";
  4. a label, or a field's placeholder;
  5. a short, exact visible text that is unique on the page;
  6. a CSS selector;
  7. and, as a last resort, a point on the screen.

The planner can only climb that ladder because it read the code. Without the code, all you have is the screen, and the screen only offers the bottom rungs.

The shape of a script

The output is a plan: a structured file with the video's settings and a list of scenes. Each scene has an id, a kind, a voice line, and what appears around the app.

A typical pull request demo looks like this:

  • A title scene. The project, what it is, a headline, and the ticket cards.
  • One demo scene per thing worth seeing, in the order a user meets it. Each has 2 to 6 gestures a viewer can follow: open the page off camera, fill a field with a realistic example, press the main button, check the result appears, scroll to show it, wait long enough to read it.
  • A slide for what cannot be filmed. A migration, a background job, SEO plumbing. These get a few bullets instead of a fake screen.
  • An outro. What is left before it ships, then a short goodbye.

The available gestures are short and literal: go to a page, click or tap, long press, fill, press a key, hover, scroll, wait, check that something is visible, go back. A scene's voice is its only source of timing, so the planner writes each line to last at least as long as its gestures, about 2.5 words per second.

The audience changes the shape. A Code review video names the code paths that changed and ends on how to test by hand. A Management update leads with the outcome, uses no technical words and prefers fewer, larger scenes. Same pull request, different script. We cover that in One pull request, many audiences.

"What's left" is part of the script

Every pull request demo ends on what is left: migrations to run, a deploy, things to test by hand, a translation still missing. It is not a nice-to-have. A demo that only shows what works is a sales pitch. A demo that says what does not work yet is something you can make a decision on.

When a template has no outro slide, like the 10-second ADHD cut, that line moves into the last sentence of the last scene. It can be short. It does not disappear.

The schema is the referee

The model writes the plan as JSON, and that JSON has to match a schema. If the answer is not valid JSON, or a field is missing, or a gesture uses an action that does not exist, the planner gets the exact errors back and tries again. After three failed tries, the job stops and tells you, rather than film something half-understood.

The schema is also what lets three very different pieces agree. The web app edits the plan, the runner executes it, the montage reads it. None of them has to trust the others' interpretation of a paragraph.

Then the screen gets a vote

A plan written from code can still be wrong about the screen. A tips bubble appears that the code makes conditional. A label is still in English on the French page. So before anything is recorded, every scene is rehearsed for real, with a screenshot and the visible text checked at the end.

When a gesture fails, the scene goes back to the planner with what the app actually showed, and it fixes the steps. When the screen contradicts the plan, the voice is rewritten to match the screen, and the gap goes into "what's left". The full loop is in Rehearse before you record.

You edit it like a text

The plan is built to be read by people, not just machines. In the app, you see each scene with its voice line, its slide and its gestures. You can change a word, reorder scenes, or drop one you do not want to show.

Changing a word only regenerates the voice of that scene. Every other line is reused from the cache, so editing is cheap. You do not need to touch the JSON, but it is there if you want it.

Why not just ask for a video?

You could ask a model to "make a demo video of this pull request" and hope. The result would be confident and unverifiable.

Splitting the job into a script you can read, targets that come from the code, a schema that rejects nonsense, and a rehearsal that checks the screen is slower to build. It is also why our Qelka demo, 7 commits told in 1 min 17, and our Proofit demo of pull request #19, 1 min 03 with one automatic fix, shipped without anyone touching the edit.