Communitygithub.com

motion-template

Author or modify an mg Remotion template (a reusable animated graphic driven by props and tokens). Use when no existing template fits or a template's animation must change.

What is motion-template?

motion-template is a Claude Code agent skill that author or modify an mg Remotion template (a reusable animated graphic driven by props and tokens). Use when no existing template fits or a template's animation must change.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ryodeushii/motion-graphics/tree/HEAD/skills/motion-template

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Templates

A template is a reusable design. It reads shot props and resolved tokens and nothing else. Read motion-style before choosing timings or easing. For Remotion API details, use the Remotion skills if installed (npx remotion skills add) or https://www.remotion.dev/docs.

Where it goes

  • Client-specific: start with pnpm mg new-template <client> <name>. It writes a working starter at clients/<client>/templates/<name>/index.tsx (id <client>/<name>) that follows the contract below; replace its design.
  • House (all clients): templates/<name>/index.tsx in the motion-toolkit repository, registered in templates/index.ts, released with a new toolkit version. Do not write into node_modules.

Before writing animation code, propose the schema (the props the user will be able to change without an agent) and confirm it with the user.

Contract

import { interpolate, useCurrentFrame } from "remotion";
import { z } from "zod";
import { color, defineTemplate, font, motion, px, safeArea } from "motion-toolkit/engine";

const schema = z.object({
  headline: z.string().min(1).default("Headline"),
  holdSeconds: z.number().positive().default(3),
  accent: z.string().default("accent").describe("Color token name or #hex"),
});

export const template = defineTemplate({
  title: "Title card",
  schema,
  durationSeconds: ({ props, tokens }) => {
    const m = motion(tokens, 1);
    return m.seconds("enter") + props.holdSeconds + m.seconds("exit");
  },
  check: ({ props, tokens }) => {
    color(tokens, props.accent); // throws on unknown token names; runs in `mg check`
  },
  component: ({ props, tokens, video }) => {
    const frame = useCurrentFrame();
    const m = motion(tokens, video.fps);
    // ...
  },
});

Requirements:

  1. Export template (client templates) built with defineTemplate.
  2. Every schema field has a .default() so new shots and Studio start valid. Add .describe() for the Studio form.
  3. Colors through color(tokens, nameOrHex), fonts through font(tokens, role), durations and easing through motion(tokens, fps), positions inside safeArea(tokens, video), sizes through px(sizeAt1080, video).
  4. Animate only from useCurrentFrame() with interpolate/spring. No CSS transitions, setTimeout, Date.now() or Math.random() (use random(seed) from remotion). Renders must be identical every time.
  5. Leave the background transparent unless the template is full-frame; lower thirds and overlays render with alpha. Every element must be gone on the last frame.
  6. Fail loudly: throw an Error with a fix hint when text cannot fit or a token is missing. Use assertFits/wrapLines from the engine; they measure with the loaded font and throw on overflow.
  7. Props that name tokens (colors, logos, fonts, sounds) are validated in check with checkRefs, so mg check catches typos before rendering.
  8. durationSeconds and check run in Node (mg check) and before fonts load: never measure text there.
  9. Images and logos: <Img src={staticFile(tokens.logos[name])} /> or staticFile(props.someAsset). Sounds: <Html5Audio src={staticFile(file)} /> inside a <Sequence from={frame}>, files from tokens.sounds[name]. The CLI stages the files.

Looks

House templates, and client templates meant to match them, take look: lookSchema and resolve it with resolveLook(props.look, tokens). Build them from the shared helpers so all three looks stay consistent (see motion-style):

  • choreo(tokens, look, fps) gives beat(frame, index, exitStart, steps) → { inP, outP } for each element in entry order; choreoSeconds(...) gives the matching duration.
  • reveal(look, beat, video) is the look's entrance style for an element (wrap it in overflow: hidden for corporate).
  • typo(tokens, look, "display" | "title" | "body" | "label", size) is the look's type style; onColor(hex) picks readable text on a color block; cornerPlacement(corner, inset) positions corner graphics.

Read a house template such as node_modules/motion-toolkit/templates/title-card/index.tsx as a worked example.

Verify

  1. pnpm mg new-shot <client>/<project> <shot> --template <client>/<name> in a test project, plus a second shot with the longest realistic text.
  2. pnpm mg check <client>/<project>.
  3. pnpm mg still <client>/<project> <shot> and look at the frames. Then pnpm mg render.
  4. Follow motion-qa.

Working from a reference clip

When the user supplies a reference video, extract frames before designing. Create renders/reference/ first; the bundled ffmpeg is a minimal build without filters, so use -r for the frame rate:

pnpm mg ffmpeg -i reference.mp4 -r 10 renders/reference/f_%03d.png

Describe from the frames what moves, in which order, how long each phase takes (count frames at 10 fps), and the easing feel. Confirm that breakdown with the user, then map it to tokens: durations to motion.durations, curves to motion.easings.

Individual skills in this repo

This repo contains 3 individual skills — each has its own dedicated page.

Related Skills