---
name: manim-visualizer
description: Create mathematical animations, diagram videos, and still frames with Manim Community Edition. Use when the user wants a math visualization, geometry animation, calculus explainer, animated graph, or rendered scene built with Manim in the current workspace.
---

# Manim Visualizer

Use this skill when the user wants a mathematical visualization rendered with Manim Community Edition.

For exact setup commands and the upstream installation notes verified against the current Manim docs, read `references/setup.md`.
For the isolated container workflow, read `references/docker.md`.

## Default Contract

- Work in the user's current workspace, not inside this plugin.
- If no Manim project exists yet, create one at `<workspace>/manim/` unless the repo already has a better location.
- Keep scene source in `scenes/`.
- Prefer deterministic local projects managed with `uv`.
- Prefer the Docker path when the user wants stronger isolation, reproducibility, or built-in LaTeX support without modifying the host.
- Start with cheap renders first:
  - layout check: `--still --quality low`
  - draft motion: `--quality low` or `--quality medium`
  - final export: `--quality high` or `--quality production`
- If a scene uses `MathTex` or `Tex`, make sure LaTeX is available before committing to that path.

## Helper Scripts

Resolve these paths relative to this skill directory:

- `../../scripts/init_manim_project.sh`
- `../../scripts/render_manim.sh`
- `../../scripts/render_manim_docker.sh`

Use absolute paths when invoking them from the workspace.

## Workflow

1. Lock the output contract:
   - what concept to explain
   - whether the user wants a video or still image
   - any duration, style, or narration constraints
2. Create or reuse a local Manim project in the workspace.
3. Author the scene directly in project files.
4. Choose the render path:
   - host-native: `render_manim.sh`
   - isolated container: `render_manim_docker.sh`
5. Report the actual output path after rendering. If needed, inspect the project's `media/` directory and return the concrete file path.

## Project Layout

Use this layout unless the repo already has an established convention:

```text
manim/
  pyproject.toml
  scenes/
  assets/
  media/
```

## Render Guidance

- Prefer one main `Scene` class per file.
- Match the file name and the scene name when practical.
- Keep scene constants explicit instead of burying meaning in magic numbers.
- Use `Text` for plain labels and `MathTex` only when LaTeX is available.
- Prefer simple scene graphs and explicit animation steps before reaching for heavy updater logic.
- For graphing and coordinate work, prefer built-in primitives like `Axes`, `NumberPlane`, `FunctionGraph`, `ParametricFunction`, and `ValueTracker`.

## Commands

Initialize a project:

```bash
/absolute/path/to/plugins/manim/scripts/init_manim_project.sh /path/to/workspace/manim
```

Render a draft video:

```bash
/absolute/path/to/plugins/manim/scripts/render_manim.sh \
  --project-dir /path/to/workspace/manim \
  --scene-file /path/to/workspace/manim/scenes/example.py \
  --scene-name ExampleScene \
  --quality low
```

Render a still frame:

```bash
/absolute/path/to/plugins/manim/scripts/render_manim.sh \
  --project-dir /path/to/workspace/manim \
  --scene-file /path/to/workspace/manim/scenes/example.py \
  --scene-name ExampleScene \
  --quality low \
  --still
```

Render in Docker:

```bash
/absolute/path/to/plugins/manim/scripts/render_manim_docker.sh \
  --project-dir /path/to/workspace/manim \
  --scene-file /path/to/workspace/manim/scenes/example.py \
  --scene-name ExampleScene \
  --quality low
```

## Failure Handling

- Do not invent system-level fixes.
- If Cairo, Pango, or other native prerequisites are missing, surface the exact install command.
- If LaTeX is missing, either install it intentionally or fall back to `Text` and explain that formula rendering is unavailable.
- If Docker is unavailable, fall back to the host-native path instead of pretending the container workflow is available.
- If the user asks for a GIF, render with Manim first and then convert the resulting video as a separate step.
