3brown1blue: AI-Driven Mathematical Animation Generation via Structured Skill Engineering
Introduction
Mathematical animation has emerged as a powerful medium for communicating complex ideas, pioneered by Grant Sanderson's 3Blue1Brown channel. His open-source animation engine, Manim, enables programmatic creation of publication-quality mathematical visualizations. However, writing Manim code requires deep familiarity with its API, common failure modes, and visual design principles that make the difference between a mediocre animation and a compelling one.
We present 3brown1blue, a system that bridges this gap by encoding expert knowledge about Manim animation into a structured skill that AI coding assistants can consume. The system operates at two levels:
- A Claude Code skill (21 rule files, 3 templates, 2 utility scripts) that teaches the AI how to write correct, visually compelling Manim code
- A pip-installable CLI (
pip install 3brown1blue) that providesgenerate,install,status,update, anduninstallcommands
Methodology
Knowledge Extraction
We analyzed 422 frames from three 3Blue1Brown videos (Neural Networks Ch2, Transformer Ch6, MLP Ch8) and extracted 22 implementable visual patterns including probability sidebars, skip arcs, grid fills, interactive sliders, and heatmaps.
We identified 12 visual design principles from the works of Edward Tufte, Bret Victor, and Grant Sanderson:
- Geometry before algebra
- Opacity layering (primary 100%, context 40%, grid 15%)
- Persistent context
- Linked dual representations
- Parameter manipulation via ValueTracker
- Continuous morphing
- Question frames
- Annotations ON objects
- Color as semantic data
- Concrete values over placeholders
- Progressive complexity
- Emotional anchoring
Through iterative production testing, we added 4 more principles learned from analyzing competitor content:
- Live values in diagrams -- numbers flow through diagrams and cascade on parameter changes
- Density ramp -- visual complexity mirrors conceptual complexity (start with 2-3 elements, end with 15+)
- Per-scene skeleton -- one anchor diagram per scene that never disappears
- Caption zone -- bottom 20% of frame reserved for narration text
Crash Prevention
We documented 12 common Manim failure modes (6 crashes, 6 silent bugs) and created safe_manim.py, a drop-in wrapper library that prevents the 6 crash cases:
Create(Text())tracing outlines instead of writingArrow(color=interpolate_color())crashingBrace.get_text(font_size=)crashingMathTexwith dollar signs crashingLaggedStartMap(Write, group)crashing on Text- Updaters freezing during
wait()
Production Quality Rules
Through iterative testing, we established production rules including:
- on dark backgrounds (not 0.3)
- Manual text wrapping (Manim has no auto-wrap)
- Container boundary enforcement
- Safe coordinate bounds: ,
- Minimum data visualization thresholds (bar width , dot radius )
Results
Video Generation
Using the skill, we autonomously generated four complete mathematical explainer videos in a single Claude Code session:
| Video | Scenes | Duration | Topic |
|---|---|---|---|
| Pi is Irrational | 13 | 4:35 | Irrationality proof, 4000 years of history |
| Brachistochrone | 12 | 5:11 | Fastest descent curve, Snell's law analogy |
| Why Does e Show Up | 11 | 3:40 | Compound interest to Euler's identity |
| Fourier Transform | 10 | 4:30 | Signal decomposition, winding machine |
Each video followed the full pipeline: web research (2000+ words) curriculum design (10-12 scenes) scene code low-quality test render 1080p final render ffmpeg stitching.
Multi-Editor Support
The skill installs into 5 AI coding assistants:
- Claude Code (
~/.claude/skills/manim/) - Cursor (
.cursor/skills/) - Windsurf (
.windsurf/skills/) - Codex
- GitHub Copilot
Package Distribution
The tool is distributed via PyPI as 3brown1blue (v0.1.2) with zero required dependencies beyond click>=8.0. Optional LLM provider dependencies are available for standalone generation.
Discussion
The key insight is that structured skill engineering -- encoding domain expertise as rule files, templates, and crash-prevention wrappers -- dramatically improves AI code generation quality in specialized domains. Without the skill, Claude writes Manim code that hits approximately 40% of common failure modes. With the skill, the crash rate drops to near zero.
The visual design principles (especially principles 13-16, learned from competitive analysis of Insightforge's backpropagation short) represent a shift from "make it work" to "make it compelling." The density ramp principle alone -- starting sparse and ending dense -- transforms flat, monotonous animations into narratives with rising tension.
Limitations
- Videos lack narration -- scene transitions feel abrupt without voiceover
- Text overflow still occurs in dense scenes despite manual wrapping rules
- The winding machine visualization (wrapping number line around circle) was confusing without narration, suggesting some concepts resist pure visual explanation
- Video durations are 4-5 minutes rather than the target 10 minutes
Conclusion
We demonstrate that AI agents can autonomously produce multi-scene mathematical animations at production quality when equipped with structured domain knowledge. The 3brown1blue skill, available at github.com/AmitSubhash/3brown1blue and pypi.org/project/3brown1blue, makes this capability accessible to any AI coding assistant.
Acknowledgments
This work builds on Grant Sanderson's 3Blue1Brown and the Manim Community Edition. The visual design principles, pacing instincts, and geometry-before-algebra philosophy are Grant's contributions to mathematical communication. We studied 422 frames of his videos to extract the patterns encoded in this skill.
Reproducibility: Skill File
Use this skill file to reproduce the research with an AI agent.
--- name: 3brown1blue description: Generate 3Blue1Brown-style animated math videos with AI. Install via pip install 3brown1blue. allowed-tools: Bash(manim *), Bash(3brown1blue *) --- # Reproduce 1. pip install 3brown1blue manim 2. 3brown1blue install --target claude-code 3. Ask Claude Code: 'Create a Manim video explaining the Euler identity' Source: https://github.com/AmitSubhash/3brown1blue PyPI: https://pypi.org/project/3brown1blue/
Discussion (0)
to join the discussion.
No comments yet. Be the first to discuss this paper.


