ClayMotion Stop-Motion Workshop
Create a stop-motion short film from a single sentence. Image generation handles the "look," and code handles the "motion": instead of generating a video directly, it breaks down character sheets and 8-frame action sheets into cells, arranges them on twos or threes timing, and adds camera moves, contact shadows, lighting, and color grading.
When to Use
Use when the user says "make a stop-motion / claymation / clay animation short film" or provides a one-sentence story and wants storyboards and a final film. Not suitable for: animating an existing image, editing existing video, or pure video generation (H3/Sora/Kling full output).
Two Modes
| Mode | Prerequisites | Output |
|---|---|---|
| local (full output) | Python 3.10+, ffmpeg, access to ComfyUI or image API | out/<name>.mp4, contact sheet, review platform |
| pack (prompt pack) | Platform cannot run Python/ffmpeg or cannot access local image services | production-log.md, shot list, full prompts for every image, film.py; user renders locally |
First run python scripts/claymotion.py doctor. If Python or ffmpeg is missing, do not pretend to output a final film. Switch to pack mode and explain this in the delivery.
Input
Ask all at once, default items listed first:
- Style: clay / papercraft / tin / wool felt / cardboard / puppet / crochet / cloth puppet (
python scripts/claymotion.py styleslists ID, Chinese name, English name). - Story: One sentence is enough; if none, ask the user, do not invent a story for them.
- Duration: 20 / 40 / 60 seconds, or 20 seconds–2 minutes; default 40 seconds.
- Aspect ratio: landscape 1920×1080 / portrait 1080×1920 / square 1080×1080.
- Narration: Default none; requires internet access (edge-tts, text sent to Microsoft speech service).
- Title/credits: Default none.
- Preview characters: Default none.
- Other requirements: Character images, reference clips, required props.
If the user writes in Chinese, communicate in Chinese; narration and subtitles are only in Chinese or English.
Workflow
0. Environment
python scripts/claymotion.py doctor
When dependencies are missing:
python scripts/setup.py --install # pip dependencies
python scripts/setup.py --instruments # music samples, ~1.4GB, resumable
python scripts/setup.py --matte # optional: BiRefNet matting model, ~0.97GB
You can also use lemo-animi's scripts/setup.sh (macOS/Linux/WSL).
1. Initialize Project
python scripts/claymotion.py init pancake --style clay --dur 20 --size landscape --name pancake --lang en
cd pancake
2. Director's Plan
Write in production-log.md: logline, story skeleton (20 seconds is one gag: setup→surprise→reaction; 40 seconds is setup→three attempts→low point→turn→payoff), beat sheet, shot list, layered action breakdown, image generation checklist.
Rules:
- Each new event is 1–1.5 seconds apart; 20 seconds = at least 13 events.
- Every shot must have
placeandview; same place and same direction with only size change = zoom cut, not allowed. - Main character occupies: wide ≥ 30%, opening/payoff wide ≥ 33%, medium ≥ 40%, medium-close ≥ 60% of the shorter screen dimension.
- 20 seconds: 2–4 shots, ~10–14 images; 40 seconds: 5–8 shots, ~20–26 images.
3. Build Prompts
python scripts/claymotion.py prompt clay character prompts/char.slots.txt -o prompts/char.txt
python scripts/claymotion.py prompt clay bg prompts/bg_wide.slots.txt -o prompts/bg_wide.txt --size landscape
python scripts/claymotion.py prompt clay sheet8 prompts/sheet_toss.slots.txt -o prompts/sheet_toss.txt
python scripts/claymotion.py prompt clay sheet4 prompts/close_face.slots.txt -o prompts/close_face.txt
Slot files start with [character], [action], [scene], [shot_size], [margin], [prop], [fx]; missing slots will cause an error listing which ones are missing.
4. Generate Images
Default backend is ComfyUI + Qwen-Image 2.1:
python scripts/claymotion.py image --prompt prompts/char.txt --out src/char_hero.png
python scripts/claymotion.py image --prompt prompts/sheet_toss.txt --out src/sheet_toss.png --ref src/char_hero.png
You can also use:
# OpenAI-compatible image API (Doubao/Jimeng/OpenAI/other gateways)
CLAYMOTION_BACKEND=openai IMAGE_API_BASE=https://... IMAGE_API_KEY=... IMAGE_MODEL=... \
python scripts/claymotion.py image --prompt prompts/char.txt --out src/char_hero.png
# MiniMax H3-Image
CLAYMOTION_BACKEND=h3 python scripts/claymotion.py image --prompt prompts/char.txt --out src/char_hero.png
Transparent asset requirements: character sheets, action sheets, close-ups, props, and fx must have transparent backgrounds; backgrounds are opaque and must not contain the main character. Check before slicing – do not proceed with a "looks okay" image.
5. QA, Slice, Anchors
python scripts/claymotion.py check src/sheet_toss.png --n 8 --out work/check_toss.jpg
python scripts/claymotion.py slice src/sheet_toss.png work/cells toss --n 8
python scripts/claymotion.py anchors work/cells --prefix toss --json work/anchors_toss.json --preview work/cells_toss.jpg
For white-background images (generation models without alpha):
python scripts/claymotion.py slice src/sheet_toss.png work/cells toss --n 8 --birefnet
If white edges remain after slicing: use scripts/cut.py to generate a mask for each cell, erode the mask by 1px + blur 0.7px, then write back to alpha.
6. Compositing
Edit tools/film.py in four places: top settings (SKILL, STYLE_ID, SIZE, NAME, HERO_H), load(), SHOTS + build(), render().
python tools/film.py lint
python tools/film.py board
python tools/film.py still 0 40 80
7. Sound
python scripts/claymotion.py sound lint sound.json
python scripts/claymotion.py sound build sound.json
Every landing, collision, toss/catch, open/close must have a foley sound; music follows the emotion; leave 0.8–2 seconds of silence before a turn. If there is no narration, do not write vo and do not include subtitles.
8. Final Output & Self-Check
python tools/film.py
sh scripts/contact.sh out/pancake.mp4 out/contact.jpg
python scripts/selfcheck.py out/pancake.mp4 --style clay
python scripts/claymotion.py sound check out/pancake.mp4
9. Review
python scripts/claymotion.py review add out/pancake.mp4 --id film-v1 --lang en
python scripts/claymotion.py review open --no-browser
Give the printed URL to the user. Wait for user comments or approval; comments are saved in the project folder even if the session times out. After the user says "done," run review notes to read feedback.
Image Backends
| Backend | Environment Variables | Notes |
|---|---|---|
comfy-qwen (default) | COMFYUI_URL, QWEN_UNET, QWEN_CLIP, QWEN_VAE | Local/LAN ComfyUI, Qwen-Image 2.1, native RGBA |
openai | IMAGE_API_BASE, IMAGE_API_KEY, IMAGE_MODEL, IMAGE_SIZE | Any OpenAI-compatible image API; transparent background depends on gateway support |
h3 | COMFYUI_URL | MiniMax H3-Image; falls back to white background + matting when no alpha |
command | IMAGE_CMD | Any local command; contract in references/image-backends.md |
ComfyUI Qwen 2.1 workflow: UNETLoader → CLIPLoader → TextEncodeQwenImage21 → KSampler(25 steps, cfg 1, euler/simple) → VAEDecode → SaveImage; negative uses ConditioningZeroOut; reference image via TextEncodeQwenImage21.images.
Platform Differences
- Doubao: Compress the entire folder into a ZIP, place
SKILL.mdat the ZIP root; ZIP ≤16MB, single file ≤2MB. If the cloud cannot access local ComfyUI, switch to theopenaibackend or pack mode. - Grok Bot: Place
claymotion/under~/agent-data/workflows/claymotion/; or runsh scripts/install_grok.sh. - Kimi: Kimi Work → Skills → Upload ZIP; or send the GitHub repo URL to Kimi to install.
- Codex / Claude: Copy to
~/.agents/skills/claymotionor~/.claude/skills/claymotion.
Details in platforms/.
Error Handling
- Image generation 429 / timeout: Do the parts that don't need this image, retry after a few minutes; never deliver placeholder images.
- Image generation error: Give the raw error to the user, do the parts that don't need the image, ask how to proceed; do not switch models/backends on your own.
- Slice FAIL: Check
work/check_*.jpg. Entire image depicted as a scene → regenerate; semi-transparent fog →--clean; intentional edge crop →--allow-edge; two characters in one cell →--group grid. - Cannot fit into 16MB: Delete large images in
styles/*/ref/andexamples/*.mp4, keep onlystyle.json,STYLE.md,prompts/. - Platform cannot run Python: Switch to pack mode, deliver
production-log.md,prompts/,film.py, and full prompts for every image; do not claim a final film has been produced.
Delivery
- Film title, logline, style, duration, aspect ratio, number of shots.
- Number of images: backgrounds / action sheets / close-ups / props / fx, and how many were regenerated.
- Must-pass: each line marked pass / fixed / known issue / not checked; sound in two lines: what was measured, and "not listened with ears."
- Least satisfactory aspect, and things not done (no network, audio not listened to, etc.).
- Final output path, review platform URL.
License
This skill includes lemo-animi (CC BY-NC 4.0, by Lemomo / LemoLab) scripts, style packs, and documentation, plus new adapters and platform notes provided with this package. Personal non-commercial use is free; commercial use requires a license: [email protected]. Fonts are Source Han Sans subsets (SIL OFL 1.1). Qwen-Image 2.1 and MiniMax H3 weights/services follow their respective licenses.