motion-canvas
Skill0 starsChanged 24 days agoMITView on GitHub
Complete production-ready guide for Motion Canvas with ESM/CommonJS workarounds, full setup templates, and troubleshooting for programmatic video creation using TypeScript
- Installs packages
2 other projects use a version of this.
Adopted by
Most recently taken up by
- VideoZero/skillstheir own version, first seen Oct 3, 2026
- dracohu2025-cloud/draco-skills-collectiontheir own version, first seen May 6, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- dracohu2025-cloud/draco-skills-collection★ 227same name
- VideoZero/skills★ 77same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository59 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- agent-runtimeSkill
- frontend-designSkill
- architectSkill
- deep-thinkSkill
- design-systemsSkill
- ecosystem-referenceSkill
- fractal-delegationSkill
- harness-reviewSkill
- heartbeatSkill
- integrate-resourcesSkill
- llm-council-critiqueSkill
- loop-createSkill
- mcp-setupSkill
- memory-compressionSkill
- memorySkill
- model-routingSkill
- oss-project-scaffoldSkill
- playwright-cliSkill
- repo-scoutSkill
- self-improveSkill
- skill-creatorSkill
- skill-routingSkill
- sprintSkill
- test-visualSkill
- troubleshootSkill
- ux-auditSkill
- Accessibility AuditorSkill
- artifacts-builderSkill
- brand-guidelinesSkill
- canvas-designSkill
- frontend-patternsSkill
- design-mirrorSkill
- design-system-starterSkill
- design-to-codeSkill
- feature-design-assistantSkill
- figma-implement-designSkill
- frontend-designSkill
- frontend-dev-guidelinesSkill
- mobile-designSkill
- pixel-agent-uiSkill
- pixel-animateSkill
- pixel-anti-slopSkill
- pixel-brain-pageSkill
- pixel-migrate-next16Skill
- pixel-rsc-boundarySkill
- pixel-ship-gateSkill
- premium-web-designSkill
- senior-frontendSkill
- shadcnSkill
- tailwind-design-systemSkill
- tailwind-patternsSkill
- theme-factorySkill
- ui-design-systemSkill
- ui-ux-pro-maxSkill
- ux-researcher-designerSkill
- web-design-guidelinesSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 8 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
Use this skill whenever you are dealing with Motion Canvas code to obtain domain-specific knowledge about:
- Distinctive: line 44
TypeScript-First: Write animations in TypeScript with full IDE support
- Very specific: line 63
CRITICAL: Add "type": "module" to enable ESM imports.
- Very specific: line 80
CRITICAL: Must include @motion-canvas/ui - the plugin will fail without it.
- Very specific: line 102
CRITICAL: Use vite.config.js (NOT .ts) with the createRequire workaround.
- Very specific: line 232
Solution: Use the createRequire workaround in vite.config.js (see Step 5)
- Very specific: line 258
Solution: Add to tsconfig.json:
- Very specific: line 277
Verify vite.config.js has the correct workaround
- Very specific: line 278
Check project path points to correct file: './src/project.ts'
- Very specific: line 279
Ensure scene imports use ?scene suffix: import example from './scenes/example?scene'.
- Very specific: line 284
Verify tsconfig.json includes all required options (see Step 6)
- Very specific: line 285
Check jsxImportSource is set to @motion-canvas/2d/lib
- Distinctive: line 286
Ensure all dependencies are installed
- Distinctive: line 290
Read individual rule files for detailed explanations and code examples:
- Distinctive: line 334
Always use the createRequire workaround: - Don't try standard ESM imports for the Vite plugin
- Very specific: line 336
Include all dependencies: - Don't forget @motion-canvas/ui
- Very specific: line 337
Use generator functions: - All scene animations should use function* and yield* syntax
- Distinctive: line 338
Leverage signals: - Create reactive dependencies between properties
- Distinctive: line 340
Use refs for control: - Create references to nodes for precise animation control
- Distinctive: line 343
Type everything: - Use TypeScript for better IDE support and fewer errors
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- source: davila7/claude-code-templates · MIT · vendored by Armory -->Motion Canvas - Production-Ready Video Creation with TypeScript
Complete production-ready skill for creating programmatic videos using Motion Canvas, including critical ESM/CommonJS workarounds, full configuration templates, and comprehensive troubleshooting.
⚠️ CRITICAL: ESM/CommonJS Interoperability Issue
IMPORTANT: The @motion-canvas/vite-plugin package is distributed as CommonJS, which causes import errors in modern ESM projects. The standard import motionCanvas from '@motion-canvas/vite-plugin' WILL NOT WORK.
You MUST use the createRequire workaround documented in the Setup section below.
When to use
Use this skill whenever you are dealing with Motion Canvas code to obtain domain-specific knowledge about:
- Creating animated videos using TypeScript and generator functions
- Building animations with signals and reactive values
- Working with vector graphics and Canvas API
- Synchronizing animations with voice-overs and audio
- Using the real-time preview editor for instant feedback
- Implementing procedural animations with flow control
- Creating informative visualizations and diagrams
- Animating text, shapes, and custom components
- Setting up Motion Canvas projects from scratch with correct configuration
- Troubleshooting common setup and build errors
Core Concepts
Motion Canvas allows you to create videos using:
- Generator Functions: Describe animations using JavaScript generators with
yield*syntax - Signals: Reactive values that automatically update dependent properties
- Real-time Preview: Live editor with instant preview powered by Vite
- TypeScript-First: Write animations in TypeScript with full IDE support
- Canvas API: Leverage 2D Canvas for high-performance vector rendering
- Audio Synchronization: Sync animations precisely with voice-overs
Complete Setup Guide
Step 1: Initialize Project
# Create project directory
mkdir my-motion-canvas-project
cd my-motion-canvas-project
# Initialize package.json
npm init -yStep 2: Configure package.json for ESM
CRITICAL: Add "type": "module" to enable ESM imports.
{
"name": "my-motion-canvas-project",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
}Step 3: Install ALL Required Dependencies
CRITICAL: Must include @motion-canvas/ui - the plugin will fail without it.
npm install --save-dev @motion-canvas/core @motion-canvas/2d @motion-canvas/vite-plugin @motion-canvas/ui vite typescriptStep 4: Create Project Structure
my-motion-canvas-project/
├── package.json # "type": "module" required
├── vite.config.js # Use .js NOT .ts (see Step 5)
├── tsconfig.json # TypeScript configuration
├── index.html # HTML entry point
└── src/
├── project.ts # Project configuration with scenes
└── scenes/
└── example.tsx # Animation sceneStep 5: Create vite.config.js with ESM/CommonJS Workaround
CRITICAL: Use vite.config.js (NOT .ts) with the createRequire workaround.
File: vite.config.js
import {defineConfig} from 'vite';
import {createRequire} from 'module';
// WORKAROUND: @motion-canvas/vite-plugin is CommonJS, must use require
const require = createRequire(import.meta.url);
const motionCanvasModule = require('@motion-canvas/vite-plugin');
const motionCanvas = motionCanvasModule.default || motionCanvasModule;
export default defineConfig({
plugins: [
motionCanvas({
project: './src/project.ts',
}),
],
});Why .js instead of .ts?
- Vite config runs before TypeScript compilation
- The
createRequireworkaround works reliably in plain JavaScript - Avoids additional type resolution complexity
Step 6: Create tsconfig.json
CRITICAL: Include esModuleInterop and allowSyntheticDefaultImports.
File: tsconfig.json
{
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"lib": ["ES2020", "DOM"],
"jsx": "react-jsx",
"jsxImportSource": "@motion-canvas/2d/lib",
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}Step 7: Create index.html
File: index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Motion Canvas Project</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/project.ts"></script>
</body>
</html>Step 8: Create src/project.ts
File: src/project.ts
import {makeProject} from '@motion-canvas/core';
import example from './scenes/example?scene';
export default makeProject({
scenes: [example],
});Step 9: Create First Animation Scene
File: src/scenes/example.tsx
import {makeScene2D} from '@motion-canvas/2d/lib/scenes';
import {Circle} from '@motion-canvas/2d/lib/components';
import {createRef} from '@motion-canvas/core/lib/utils';
import {all} from '@motion-canvas/core/lib/flow';
export default makeScene2D(function* (view) {
const circleRef = createRef<Circle>();
view.add(
<Circle
ref={circleRef}
size={70}
fill="#e13238"
/>,
);
// Animate circle size and position
yield* circleRef().size(140, 1);
yield* circleRef().position.x(300, 1);
yield* circleRef().fill('#e6a700', 1);
// Parallel animations
yield* all(
circleRef().scale(1.5, 0.5),
circleRef().rotation(360, 1)
);
});Step 10: Run Development Server
npm run devOpen browser at http://localhost:5173 to see the Motion Canvas editor.
Troubleshooting
Error: TypeError: motionCanvas is not a function
Cause: ESM/CommonJS interoperability issue with @motion-canvas/vite-plugin
Solution: Use the createRequire workaround in vite.config.js (see Step 5)
// ❌ WRONG - Will not work
import motionCanvas from '@motion-canvas/vite-plugin';
// ✅ CORRECT - Use createRequire
import {createRequire} from 'module';
const require = createRequire(import.meta.url);
const motionCanvasModule = require('@motion-canvas/vite-plugin');
const motionCanvas = motionCanvasModule.default || motionCanvasModule;Error: Cannot find module '@motion-canvas/ui'
Cause: Missing required dependency
Solution: Install the UI package:
npm install --save-dev @motion-canvas/uiError: Property 'default' does not exist on type ...
Cause: TypeScript configuration missing ESM interop settings
Solution: Add to tsconfig.json:
{
"compilerOptions": {
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
}
}Warning: The CJS build of Vite's Node API is deprecated
Status: This is a known warning and can be safely ignored. It appears because @motion-canvas/vite-plugin is CommonJS. The workaround ensures functionality despite the warning.
Error: Failed to resolve import "*.tsx?scene"
Cause: Vite plugin not properly loaded or configured
Solution:
- Verify
vite.config.jshas the correct workaround - Check
projectpath points to correct file:'./src/project.ts' - Ensure scene imports use
?scenesuffix:import example from './scenes/example?scene';
Build fails with TypeScript errors
Solution:
- Verify
tsconfig.jsonincludes all required options (see Step 6) - Check
jsxImportSourceis set to@motion-canvas/2d/lib - Ensure all dependencies are installed
How to use
Read individual rule files for detailed explanations and code examples:
Core Animation Concepts
- references/generators.md - Generator functions for describing animations
- references/signals.md - Reactive signals for dynamic properties and dependencies
- references/animations.md - Tweening properties and creating smooth animations
For additional topics like scenes, shapes, text rendering, audio synchronization, and advanced features, refer to the comprehensive Motion Canvas official documentation.
Complete Working Example
This is a complete, tested project structure that works out of the box:
my-motion-canvas-project/
├── package.json
│ {
│ "name": "my-motion-canvas-project",
│ "type": "module",
│ "scripts": {
│ "dev": "vite",
│ "build": "vite build"
│ },
│ "devDependencies": {
│ "@motion-canvas/core": "^3.0.0",
│ "@motion-canvas/2d": "^3.0.0",
│ "@motion-canvas/vite-plugin": "^3.0.0",
│ "@motion-canvas/ui": "^3.0.0",
│ "vite": "^5.0.0",
│ "typescript": "^5.0.0"
│ }
│ }
│
├── vite.config.js (with createRequire workaround)
├── tsconfig.json (with esModuleInterop)
├── index.html
└── src/
├── project.ts (makeProject with scenes array)
└── scenes/
└── example.tsx (makeScene2D with animations)Best Practices
- Always use the createRequire workaround - Don't try standard ESM imports for the Vite plugin
- Use vite.config.js not .ts - Avoids additional compilation complexity
- Include all dependencies - Don't forget
@motion-canvas/ui - Use generator functions - All scene animations should use
function*andyield*syntax - Leverage signals - Create reactive dependencies between properties
- Think in durations - Specify animation duration in seconds as the second parameter
- Use refs for control - Create references to nodes for precise animation control
- Preview frequently - Take advantage of the real-time editor for instant feedback
- Organize scenes - Break complex animations into multiple scenes
- Type everything - Use TypeScript for better IDE support and fewer errors
Common Pitfalls to Avoid
- ❌ Forgetting
"type": "module"in package.json - ❌ Using standard import for
@motion-canvas/vite-plugin - ❌ Not installing
@motion-canvas/ui - ❌ Missing
esModuleInteropin tsconfig.json - ❌ Using
vite.config.tsinstead ofvite.config.js - ❌ Forgetting
?scenesuffix in scene imports
Resources
- Documentation: https://motioncanvas.io/docs
- Repository: https://github.com/motion-canvas/motion-canvas
- Examples: https://motioncanvas.io/docs/quickstart
- Community: Discord and GitHub Discussions
- License: MIT
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

