This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the 3Blue1Brown video creation repository containing the Python code used to generate the mathematical animations and visualizations for the 3Blue1Brown YouTube channel. The project is built on top of the Manim animation library (specifically the 3b1b version, not the community edition).
manimgl <file_name> <scene_name>- Render a scene to videomanimgl <file_name> <scene_name> -se <line_number>- Drop into interactive mode at a specific line (like a debugger)manimgl <file_name> <scene_name> -p- Preview the scene without rendering to file
checkpoint_paste()- In interactive mode, run code from clipboard with state managementcheckpoint_paste(skip=True)- Run code without animation (zero runtime)checkpoint_paste(record=True)- Record animations while running code
python stage_scenes.py <module_name>- Stage rendered scenes in order for a video module
_YYYY/- Videos organized by year (e.g.,_2025/,_2024/)custom/- Custom Manim extensions and reusable componentsonce_useful_constructs/- Legacy utility classes and functionsoutside_videos/- Content for external collaborations and one-offssublime_custom_commands/- Sublime Text editor integration
manim_imports_ext.py- Universal import file that imports all Manim components plus custom extensionscustom_config.yml- Manim configuration with custom paths and rendering settingsplayground.py- Sandbox file for testing and experimentation
Each video project typically contains:
- Main scene files (e.g.,
main.py,part1.py,part2.py) supplements.py- Additional scenes and helper functions- Helper modules for specific mathematical concepts
custom/characters/- Pi creature animations and scenescustom/backdrops.py- Background elements and visual themescustom/drawings.py- Custom drawing utilitiescustom/end_screen.py- Standard end screen components
- Create scene classes inheriting from
InteractiveSceneorScene - Use
manimglwith-seflag to develop interactively - Use
checkpoint_paste()to iterate on animation code - Preview with
-pflag before final rendering
- Start with
from manim_imports_ext import *for all video files - Organize scenes chronologically within files
- Use descriptive class names that match the video content
- Group related scenes in the same file
- Camera resolution: 4K (3840x2160) at 30fps
- Custom fonts and LaTeX configuration in
custom_config.yml - Dropbox integration for asset management and video output
InteractiveScene- Base class for most scenes with interactive development supportPiCreatureScene- Scenes featuring the Pi creature characterTeacherStudentsScene- For Pi creature classroom interactions- Custom scene classes for specific mathematical contexts
- Use
self.play()for animations self.wait()for pausesself.add()for static elements- Color constants:
BLUE,YELLOW,RED, etc. - Mathematical typesetting with
Tex()(use this instead ofMathTex()which is from ManimCommunity) - Format LaTeX strings with raw strings:
Tex(R"\pi"),Tex(R"\frac{1}{2}"), etc. - Use
lag_ratioparameter for staggered animations:FadeIn(objects, lag_ratio=0.1) - Common sequence:
self.play(Write(equation))followed byself.wait()
NumberPlaneandComplexPlanefor coordinate systemsParametricCurvefor mathematical curvesVGroupfor grouping related objects- When creating multiple similar objects (e.g., multiple
NumberLines), create them within aGrouporVGroupto avoid code duplication - Custom mathematical visualization classes in
once_useful_constructs/
- Place configuration constants at the top of files
- Use class attributes for scene-specific configuration:
initial_positions = [10.5, 8] - Helper methods use
get_*naming pattern:get_spring(),get_mass() - Access frame with
frame = self.framefor camera operations
- Use text-to-color mapping for mathematical expressions:
Tex(formula, t2c={"x": BLUE, "y": RED}) - Consistent color schemes: earth=BLUE, sun=YELLOW, mathematical variables get specific colors
- Set properties with chained methods:
object.set_stroke(color, width).set_fill(color, opacity)
- Use updaters for dynamic positioning:
object.add_updater(lambda m: m.move_to(target.get_center())) - Alternative syntax:
object.f_always.move_to(reference.get_center) - Use
LaggedStart(*animations, lag_ratio=0.1)for sequential overlapping animations
- Do not include indentation spaces on blank lines
- Keep blank lines completely empty (no whitespace)
- Prefer existing utility functions over one-off index math. For example, use
color_gradient(colors, n)to produce a list of interpolated colors rather than callinginterpolate_colormanually inside a loop withi / (n - 1)arithmetic. - Construct VGroups declaratively when possible. If the full meaning of a group can be expressed in one expression, prefer
VGroup(*[...])orVGroup(... for ...)over a for loop that progressively calls.add(). Reserve the progressive style for cases where each iteration has non-trivial side effects. - Use existing layout methods (
.arrange(),.next_to(),.move_to()) instead of manual in-place coordinate logic. A small amount of redundant movement is preferable to bespoke positioning arithmetic that is harder to read and easier to get wrong.
- This repository uses the 3b1b version of Manim, not ManimCommunity
- The project integrates with Sublime Text for enhanced development workflow
- Video assets are managed through Dropbox with custom path configurations
- Each year's videos are self-contained in their respective directories
- No formal testing framework - scenes are tested through visual preview and rendering