The Complete Production SOP: How to Deploy and Run Theater.js Programmatic Motion Design in Autonomous AI Agents
Step-by-step SOP to install and run Theater.js Programmatic Motion Design in Codex, Claude Code, and Cursor. Includes verified prompts, configs, and troubleshooting.
Technical Overview & Architectural Context
When autonomous coding agents attempt to generate complex web animations, they almost universally default to disjointed CSS transitions, fragmented Web Animations API (WAAPI) calls, or brittle setTimeout sequences. These ad-hoc methods fail when orchestrating synchronized timelines across multiple DOM nodes or 3D canvas objects, resulting in race conditions, dropped frames, uncoordinated entry effects, and unmaintainable state trees. Furthermore, agents frequently leak development tools—such as the Theater.js visual studio GUI—into production bundles, ballooning application weight and degrading runtime performance. The Theater.js Programmatic Motion Design skill establishes deterministic procedural constraints for agent runtimes like Codex Desktop, Claude Code, Cursor, and Windsurf. By enforcing Theater.js structural primitives (Projects, Sheets, Actors, and Values via @theater/core), the skill directs agents to isolate visual timelines into explicit JSON state files, bind element properties using type-safe declarations (`types.number`, `types.rgba`), and conditionally load `@theater/studio` strictly in local development environments. This guarantees synchronized, cinematic web animations with zero bundle bloat in production.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Mount the Theater.js Programmatic Motion Design SKILL.md into the agent workspace skill directory.
Autonomous agent runners detect skills through standard repository or global configuration paths. For project-scoped execution in Claude Code, Cursor, or Windsurf, mount the skill definition into `.agents/skills/theaterjs-cinematic-animation/SKILL.md`. The runtime reads the YAML frontmatter triggers and dynamically injects the SOP into the agent's context whenever animation orchestration tasks are encountered.
mkdir -p .agents/skills/theaterjs-cinematic-animation && curl -fsSL https://askills.dev/api/skills/theaterjs-cinematic-animation/raw -o .agents/skills/theaterjs-cinematic-animation/SKILL.md---
name: "theaterjs-cinematic-animation"
description: "Design and orchestrate complex cinematic web animations with Theater.js visual studio."
metadata:
author: "Theater.js"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "orchestrate animation theaterjs"
- "use theater.js studio"
- "animate multiple objects synchronized"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---Place the SKILL.md in the project-level `.agents/skills/` directory rather than global user configs so all contributors and CI autonomous runners use identical orchestration rules without extra token overhead.
Ensure `fs_write` is restricted to `workspace`. Granting broader root write permissions exposes your local system during unconstrained agent refactoring loops.
Core Package Installation & Studio Isolation
Install @theater/core as a direct dependency and @theater/studio as a development dependency.
Theater.js separates animation timeline evaluation (`@theater/core`) from the visual scrubber and keyframe timeline editor (`@theater/studio`). The agent must install `@theater/core` as a runtime production dependency and `@theater/studio` strictly under `devDependencies`. The agent must also set up dynamic imports for the studio to prevent it from bundling into production builds.
npm install @theater/core && npm install -D @theater/studioimport { getProject, types } from '@theater/core';
import projectState from './state.json';
export const project = getProject('LandingCinematics', { state: projectState });
export const sheet = project.sheet('HeroScene');
if (process.env.NODE_ENV === 'development') {
import('@theater/studio').then((studio) => {
studio.default.initialize();
});
}Keep initial state in a modular `state.json` file. Directing the agent to read and write to this file preserves visual edits made in the studio GUI without code regressions.
Never use top-level static `import studio from '@theater/studio'`. This will bundle the entire Studio UI and monaco editor into production, creating a massive multi-megabyte bundle penalty.
Actor Property Binding & Sequence Execution
Bind DOM elements or Three.js objects to Theater.js sheet objects with typed numeric and color values.
To achieve deterministic animations, the agent must define Theater objects using explicit property types (`types.number`, `types.rgba`, `types.string`). When values update along the timeline, the agent subscribes to changes via `object.onValuesChange` to apply inline transforms or CSS custom properties, followed by calling `sheet.sequence.play()`.
npx tsc --noEmitimport { sheet } from './orchestrator';
import { types } from '@theater/core';
export function setupHeroMotion(heroHeading: HTMLElement, heroBadge: HTMLElement) {
const headingActor = sheet.object('HeadingActor', {
opacity: types.number(0, { range: [0, 1] }),
yOffset: types.number(50, { range: [-200, 200] }),
});
const badgeActor = sheet.object('BadgeActor', {
scale: types.number(0.8, { range: [0, 2] }),
opacity: types.number(0, { range: [0, 1] }),
});
headingActor.onValuesChange((values) => {
heroHeading.style.opacity = `${values.opacity}`;
heroHeading.style.transform = `translateY(${values.yOffset}px)`;
});
badgeActor.onValuesChange((values) => {
heroBadge.style.opacity = `${values.opacity}`;
heroBadge.style.transform = `scale(${values.scale})`;
});
return () => sheet.sequence.play({ iterationCount: 1, rate: 1.0 });
}Instruct the agent to map Theater values directly to CSS Custom Properties (variables) on container elements if animating many child nodes simultaneously to minimize layout thrashing.
Avoid subscribing multiple duplicate `onValuesChange` listeners inside render loops or React `useEffect` hooks without returning an unsubscribe cleanup function.
Trigger Invocation & Production Quality Verification
Invoke the agent using standardized frontmatter triggers and verify deterministic production outputs.
Provide the agent with explicit natural language instructions matching the skill's triggers. After the agent generates or updates motion code, execute build checks and bundle analysis to guarantee zero production leakage of `@theater/studio`.
npm run build && npx bundle-buddy dist/stats.json || npm test#!/usr/bin/env bash
set -euo pipefail
echo "Checking for studio leak in build output..."
if grep -rq "@theater/studio" dist/; then
echo "ERROR: @theater/studio detected in production dist bundle!" >&2
exit 1
fi
echo "Verification Passed: Theater.js production bundle cleanly separated."Always verify that your CI pipeline runs the build script with `NODE_ENV=production` so the dynamic studio import is completely dead-code eliminated.
Failing to check the build output directory allows undetected dynamic import fallback chunks containing studio source code to deploy to static hosting.
Real-World Scenario: Synchronized Cinematic Reveal for SaaS Landing Hero Section
“orchestrate animation theaterjs for our landing page hero. Synchronize the navbar entry, hero heading fade-slide, and demo video frame zoom using Theater.js. Ensure studio is only active in development and export the timeline state.”
Runtime Troubleshooting & Failure Modes
Root Cause: The agent attempted to invoke `@theater/studio` initialization on the server side during Next.js, Remix, or Nuxt SSR rendering before the window object was available.
if (typeof window !== 'undefined' && process.env.NODE_ENV === 'development') { import('@theater/studio').then(s => s.default.initialize()); }Root Cause: Hot Module Replacement (HMR) or re-rendering components re-invoked `sheet.object` with modified schema shapes, causing Theater.js core validation to throw an identity conflict.
Ensure object initialization is housed outside React/Vue render cycles, or invoke `sheet.object('HeroText', props, { reconfigure: true })` to allow dynamic re-configuration during development.Frequently Asked Questions (Theater.js Programmatic Motion Design SOP)
Q:Can I use Theater.js Programmatic Motion Design across Codex, Claude Code, and Cursor simultaneously?
Yes. This skill is built against the universal SKILL.md specification. All four target runtimes (Codex, Claude Code, Cursor, and Windsurf) read the manifest frontmatter triggers, allowing uniform orchestration commands across any supported IDE or CLI agent.
Q:How does Theater.js Programmatic Motion Design prevent context window overflow during long agent sessions?
The skill enforces modularization by storing raw keyframe data in a standalone `state.json` file. Instead of re-reading or dumping thousand-line sequence timelines into the agent's context window, the agent only reasons about actor definitions and property mappings.
Q:Does this skill require escalated root or container permissions?
No. The skill has an audited security score of 98/100. It requires read access and workspace-scoped file writing (`fs_write: workspace`) to modify animation files, but explicitly disables shell execution and external network calls in its security manifest.
Ready to equip your autonomous agent with Theater.js Programmatic Motion Design?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.