Communitygithub.com

claymotion

用一句话做一支黏土/定格动画短片:写故事和镜头表,生成角色、布景和动作表,在代码里逐格合成,配乐拟音,最后出片。支持本机 ComfyUI(Qwen-Image 2.1)或任意生图工具。

claymotion 是什么?

claymotion is a Claude Code agent skill that 用一句话做一支黏土/定格动画短片:写故事和镜头表,生成角色、布景和动作表,在代码里逐格合成,配乐拟音,最后出片。支持本机 ComfyUI(Qwen-Image 2.1)或任意生图工具。.

兼容平台✓Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/lastfox2000/claymotion/tree/HEAD

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

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

ModePrerequisitesOutput
local (full output)Python 3.10+, ffmpeg, access to ComfyUI or image APIout/<name>.mp4, contact sheet, review platform
pack (prompt pack)Platform cannot run Python/ffmpeg or cannot access local image servicesproduction-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:

  1. Style: clay / papercraft / tin / wool felt / cardboard / puppet / crochet / cloth puppet (python scripts/claymotion.py styles lists ID, Chinese name, English name).
  2. Story: One sentence is enough; if none, ask the user, do not invent a story for them.
  3. Duration: 20 / 40 / 60 seconds, or 20 seconds–2 minutes; default 40 seconds.
  4. Aspect ratio: landscape 1920×1080 / portrait 1080×1920 / square 1080×1080.
  5. Narration: Default none; requires internet access (edge-tts, text sent to Microsoft speech service).
  6. Title/credits: Default none.
  7. Preview characters: Default none.
  8. 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 place and view; 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

BackendEnvironment VariablesNotes
comfy-qwen (default)COMFYUI_URL, QWEN_UNET, QWEN_CLIP, QWEN_VAELocal/LAN ComfyUI, Qwen-Image 2.1, native RGBA
openaiIMAGE_API_BASE, IMAGE_API_KEY, IMAGE_MODEL, IMAGE_SIZEAny OpenAI-compatible image API; transparent background depends on gateway support
h3COMFYUI_URLMiniMax H3-Image; falls back to white background + matting when no alpha
commandIMAGE_CMDAny 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.md at the ZIP root; ZIP ≤16MB, single file ≤2MB. If the cloud cannot access local ComfyUI, switch to the openai backend or pack mode.
  • Grok Bot: Place claymotion/ under ~/agent-data/workflows/claymotion/; or run sh 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/claymotion or ~/.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/ and examples/*.mp4, keep only style.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

  1. Film title, logline, style, duration, aspect ratio, number of shots.
  2. Number of images: backgrounds / action sheets / close-ups / props / fx, and how many were regenerated.
  3. Must-pass: each line marked pass / fixed / known issue / not checked; sound in two lines: what was measured, and "not listened with ears."
  4. Least satisfactory aspect, and things not done (no network, audio not listened to, etc.).
  5. 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.

相关技能