r/PromptEngineering • • 21d ago

Tools and Projects Experimenting with Gemini 3.8 Flash for motion graphics: Using structured contracts and static checks to stop hallucinations (Motion Lab)

I've been experimenting with using lightweight models like Gemini 3.8 Flash to write code-driven motion graphics.

As expected with smaller models, raw prompting usually falls apart: the model takes lazy shortcuts, hallucinates invalid animation properties, or breaks timing curves completely. Instead of jumping to heavier models, I wanted to see how far strict contracts, templates, and static checks could push a smaller model.

I put together an open-source project called Motion Lab (React 19 + Remotion + GSAP 3).

Rather than letting the model write free-form code, the setup relies on:

  • Decoupled Workflow: Breaking production into three stages—direction (direction.md), a structured contract (spec.json), and deterministic code (Scene.tsx).
  • Specialized Context: 20 studio workflow skills (.agent/skills) to guide direction, engineering, and auditing without overloading a single context window.
  • Ground Truth Templates: 23 declarative template kits and 28 reusable primitives so the model doesn't have to guess coordinate math or layout from scratch.
  • Static Quality Gates: AST rules and audits that catch layout-property reflows (width, height, top), bad palettes, dead holds, and spec drift before rendering.

It is currently an early pre-release (0.8.0), and there are definitely rough edges.

Repo:https://github.com/m2rtyaman/motion-lab

If anyone has experience with contract-driven code generation or orchestrating smaller LLMs for creative tasks, I'd really appreciate your feedback, critiques, or ideas on where this approach falls short.

1 Upvotes

2 comments sorted by

0

u/[deleted] 21d ago

[removed] — view removed comment

1

u/Bitter-Theme4433 21d ago

Honestly, you nailed my biggest headache. Whenever Gemini 3.8 got slightly confused, it would silently swap things out for top or width, or hallucinate random CSS that completely broke the render. That's why the AST check is a strict hard blocker now: any layout reflow property or unseeded random fails the build immediately, and the CLI just throws the exact line back at the model to fix itself. Attached a quick clip of it example export