Home › Blender (Python add-ons) › Blender Python add-on AGENTS.md

Blender Python add-on AGENTS.md

AGENTS.md for Blender add-ons and extensions in Python (bpy): manifest, operators and panels, register/unregister, properties, and headless tests.

AGENTS.mdBlender (Python add-ons)

How to use

Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

AGENTS.mdDownload  
# AGENTS.md: Blender add-on (bpy)

## Commands
- Build an extension zip: `blender --command extension build` (reads `blender_manifest.toml`)
- Validate: `blender --command extension validate`
- Headless tests: `blender --background --factory-startup --python-exit-code 1 --python tests/run_tests.py`
- Check `blender_version_min` in the manifest and only use bpy APIs available in that version.

## Code map
`blender_manifest.toml` (id, version, `blender_version_min`, permissions) · `__init__.py` (register/unregister only) · `operators/`, `panels/`, `props.py`, `utils/`.

## Rules
- Every class (Operator, Panel, PropertyGroup, Menu) is listed in one `classes` tuple, registered in order in `register()` and unregistered in reverse in `unregister()`. Re-enabling the add-on must not error.
- Operators: `bl_idname = "myaddon.verb_noun"`, `bl_label`, `bl_options = {'REGISTER', 'UNDO'}` for anything that changes data, a `poll()` classmethod, and return `{'FINISHED'}` or `{'CANCELLED'}`. Report problems with `self.report({'ERROR'}, msg)`.
- Panels: `bl_space_type`, `bl_region_type`, `bl_category`; draw only, never modify data in `draw()`.
- Store settings in a `PropertyGroup` attached via `bpy.types.Scene.myaddon = PointerProperty(...)` (remove it in `unregister`). Preferences go in `AddonPreferences` keyed by `__package__`.
- Prefer data API (`bpy.data`, mesh/`bmesh`) over `bpy.ops` inside loops; `bpy.ops` depends on context and is slow. If you need an operator, pass a context with `context.temp_override(...)`.
- Don't store references to `bpy` data blocks across undo or file loads; look them up by name or use handlers with `@persistent`.
- Network access, file writes outside the user's chosen path, and subprocesses must be declared in manifest `permissions` and done only when the user triggers them.
- Third-party Python wheels are bundled via the manifest's `wheels` list, not installed with pip at runtime.

## Done
Validate and build succeed, headless tests pass, and the add-on enables, runs, and disables cleanly in a fresh profile.

More: all Blender (Python add-ons) rules · all AGENTS.md rules

Related rules

Bevy game engine AGENTS.md

AGENTS.md for Bevy (0.16+) games in Rust: ECS systems, plugins, required components, and fast dev builds.

AGENTS.mdBevy (Rust)

Defold game engine AGENTS.md

AGENTS.md for Defold games in Lua: game objects and components, message passing, script lifecycle, and native extensions.

AGENTS.mdDefold

GameMaker GML AGENTS.md

AGENTS.md for GameMaker (2024+ runtime) projects in GML: objects and events, structs and methods, and clean state.

AGENTS.mdGameMaker

Godot 4 GDScript AGENTS.md

AGENTS.md for Godot 4 projects using typed GDScript, signals and scene composition.

AGENTS.mdGodot

MonoGame AGENTS.md

AGENTS.md for 2D/3D games in C# with MonoGame 3.8: game loop, content pipeline, scenes, and allocation-free updates.

AGENTS.mdMonoGame

Pygame (pygame-ce) AGENTS.md

AGENTS.md for 2D games in Python with pygame-ce 2.5+: game loop, scenes, sprites, assets, and testable logic.

AGENTS.mdPygame

Get the best new AI prompts every week

One short email a week: the best new prompts and rules for ChatGPT, Claude, Gemini, Midjourney, Cursor and more, plus what changed in the tools. Free, unsubscribe anytime.

Finishes on our newsletter page at beehiiv (opens in a new tab). Or subscribe directly.