Verified SOP & TutorialAudited Score 98/100

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.

Target Runtimes:codexclaude-codecursorwindsurf
5 min read • Updated for 2026

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

Codex Desktop, Claude Code CLI, Cursor, or Windsurf installed with skill support
Node.js 20+ and npm/pnpm/yarn installed in the local environment
Existing web application project (Vite, Next.js, Nuxt, or standard Webpack setup)
Git 2.40+ initialized with clean workspace working tree

Verified Search Intents & Long-Tail Queries Solved

SEO Audit Score: 98/100

This operational tutorial is engineered to provide deterministic solutions for these developer search queries:

#install theaterjs-cinematic-animation in cursor ide#claude code theaterjs animation rules#theater.js programmatic motion design codex setup#orchestrate animation theaterjs agent skill#deterministic theater.js animation prompt examples#how to fix theater.js studio in production build error#theaterjs-cinematic-animation sandbox permissions and security score#theater.js sheet sequence multi element orchestration cursor

Step-by-Step Execution Playbook

1

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.

Terminal Command
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
.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
---
Production Pro-Tip

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.

Sandbox Gotcha

Ensure `fs_write` is restricted to `workspace`. Granting broader root write permissions exposes your local system during unconstrained agent refactoring loops.

2

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.

Terminal Command
npm install @theater/core && npm install -D @theater/studio
src/motion/orchestrator.ts
import { 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();
  });
}
Production Pro-Tip

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.

Sandbox Gotcha

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.

3

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()`.

Terminal Command
npx tsc --noEmit
src/motion/heroAnimation.ts
import { 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 });
}
Production Pro-Tip

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.

Sandbox Gotcha

Avoid subscribing multiple duplicate `onValuesChange` listeners inside render loops or React `useEffect` hooks without returning an unsubscribe cleanup function.

4

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`.

Terminal Command
npm run build && npx bundle-buddy dist/stats.json || npm test
verify-build.sh
#!/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."
Production Pro-Tip

Always verify that your CI pipeline runs the build script with `NODE_ENV=production` so the dynamic studio import is completely dead-code eliminated.

Sandbox Gotcha

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

Tested Trigger Prompt (Feed directly into Codex, Claude, or Cursor):

“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.”

Deterministic Agent Verification Pipeline:
Detects trigger 'orchestrate animation theaterjs' and invokes the theaterjs-cinematic-animation skill SOP.
Installs @theater/core as dependency and @theater/studio as devDependency.
Creates an orchestrator module with `LandingHero` project and initializes dynamic studio loading wrapped in `process.env.NODE_ENV === 'development'` conditional checks.
Declares Actors for `Navbar`, `Headline`, and `VideoFrame` with constrained types (`opacity`, `translateY`, `scale`).
Subscribes elements via `onValuesChange` to update CSS transform and opacity properties without layout thrashing.
Exports project state to `state.json` and adds sequence auto-playback logic on DOM mount.
Executes `npm run build` and runs verification to confirm `@theater/studio` is omitted from production chunks.

Runtime Troubleshooting & Failure Modes

Error: Error: Project 'LandingCinematics' cannot be initialized because studio is trying to mount to non-existent DOM element or document is undefined (SSR).

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.

Resolution Command / Fix:
if (typeof window !== 'undefined' && process.env.NODE_ENV === 'development') { import('@theater/studio').then(s => s.default.initialize()); }
Error: TypeError: sheet.object(...) is called with existing name 'HeroText' with different prop types.

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.

Resolution Command / Fix:
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.

Get 1-Click Install Spec