motion-canvas
Skill này làm gì
Skill này hướng dẫn agent AI tạo video hoạt hình bằng Motion Canvas, một framework TypeScript. Skill dành cho lập trình viên và người làm nội dung muốn tạo hoạt hình video bằng mã.
Khi nào nên dùng
- ✓Khi bạn muốn thiết lập một dự án Motion Canvas mới từ đầu với cấu hình phù hợp.
- ✓Khi bạn đang xây dựng hoạt hình bằng hàm generator và tín hiệu phản ứng.
- ✓Khi bạn đang sửa lỗi build hoặc import trong một dự án Motion Canvas hiện có.
Liên kết skill
https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/video/motion-canvas/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể thiết lập một dự án Motion Canvas mới và làm một thẻ tiêu đề có hoạt hình đơn giản không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent thiết lập dự án với cấu hình cần thiết, viết các cảnh TypeScript có hoạt hình, rồi dùng bản xem trước trực tiếp để kiểm tra.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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 -y
Step 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 typescript
Step 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 scene
Step 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 ind
Câu hỏi thường gặp
Có vấn đề thiết lập nào đã biết không?
Có. Skill cảnh báo rằng việc import plugin Vite có thể lỗi trong các dự án hiện đại và đưa ra cách sửa.
Có cần kỹ năng lập trình không?
Có. Video được xây dựng bằng mã TypeScript, và agent sẽ viết mã đó cho bạn.
Có thể đồng bộ với lồng tiếng không?
Có. Skill bao gồm việc đồng bộ hoạt hình với âm thanh.
Chi tiết
Mô tả gốc của tác giả
Complete production-ready guide for Motion Canvas with ESM/CommonJS workarounds, full setup templates, and troubleshooting for programmatic video creation using TypeScript
Độ phổ biến
- Sao GitHub
- 33k
- Vị trí xếp hạng
- #9092
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
owasp-security
33kDạy agent hướng dẫn bảo mật OWASP cho ứng dụng web, API, di động, container và agent AI, để nhận ra các điểm yếu phổ biến và gợi ý cách sửa.
agent-management
33kCho phép agent của bạn tạo, liệt kê, cho ngủ đông, đánh thức, đổi tên và xóa các agent AI bằng dòng lệnh AI Maestro, quản lý vòng đời của từng agent.
agent-messaging
33kCho phép agent của bạn gửi, nhận và trả lời tin nhắn có chữ ký giữa các agent AI, dùng Agent Messaging Protocol, chủ yếu trên máy của bạn.
docs-search
33kCho phép agent của bạn tìm trong tài liệu code được tạo tự động, như chữ ký hàm, định nghĩa lớp và chú thích, để kiểm tra API thật trước khi sửa code.
Skill tương tự
blender-motion-state-inspection
280kCho phép kiểm tra chi tiết trong hoạt ảnh 3D. Hữu ích để kiểm tra tư thế, chuyển động và độ thẳng hàng của nhân vật trong hoạt ảnh.
manim-video
280kGiúp agent tạo video giải thích hoạt hình. Dùng Manim để tạo biểu đồ và sơ đồ rõ ràng cho các khái niệm kỹ thuật.
remotion-video-creation
280kHướng dẫn agent tạo video bằng React với thư viện Remotion. Bao gồm các thực hành tốt nhất về hoạt ảnh, âm thanh, phụ đề và các yếu tố hình ảnh khác.