/blender:nodesfrom blender
Use when writing or reviewing Python over a Blender node tree, covering tree structure and reconciliation
Ships in blender. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Covers bpy code over node trees.
[REFERENCES]:
Holders decide how code reaches a tree:
| [INDEX] | [HOLDER] | [TREE] |
|---|---|---|
| [01] | Material, World, Light | Embedded node_tree with built-in nodes, use_nodes ignoring writes |
| [02] | Texture, FreestyleLineStyle | node_tree at None until use_nodes = True builds default nodes |
| [03] | bpy.data.node_groups | new(name, <tree class>.__name__) with empty nodes and interface |
| [04] | Group node, NODES modifier | node_tree, node_group |
| [05] | Compositor effect, strip, strip modifier | node_group of SceneCompositorEffect, CompositorStrip, SequencerCompositorModifierData |
| [06] | Node editor | space.node_tree root, space.edit_tree entered group |
Tree kinds decide node classes and socket types:
__name__ and hold no bl_idname, Python classes state it in bl_idname apart from __name__nodes.new(bl_idname) raises RuntimeError for a class the tree refuses or the build lacksinterface.new_socket raises TypeError listing socket types the tree kind takesTextureNode* classes and Float, Vector, and Color sockets alonenodes.new maps aliased classes to current ones (ShaderNodeBsdfGlossy to ShaderNodeBsdfAnisotropic), and matches read the created bl_idnamebl_idname and state: tree.get_output_node("ALL") in shader trees, NodeGroupOutput with is_active_output in groupsspace.node_tree for the active modifier's tree at next redraw while space.pin is offGroups take picker and tool flags, and host helpers inline a tree or add built-in nodes:
is_modifier, is_strip_modifier, and allow_usage_in_scene_compositor_effect list a group in pickers and asset menusnode_group writes take any tree of the kind whatever its flagsnode_tree writes of another tree kind or a tree containing the node's tree (tree.contains_tree(other)) leave it empty, no raiseis_tool, one is_type_* and one is_mode_* flag, and node_tool_idnamewindow_manager.register_node_group_operators()assets/nodes blends hold Input_<n> and Output_<n> identifiers beside Socket_<n>inline_shader_nodes() on materials, worlds, and lights returns an object with a node_tree that inlines groups, zones, closures, and bundlesbpy_extras.node_shader_utils.PrincipledBSDFWrapper reads and writes Principled and output nodesPrincipledBSDFWrapper *_texture image, projection, and texcoords writes add Image Texture, Mapping, and Normal Map nodesMode writes (data_type, operation) enable sockets or retype them by node:
A_Float, A_Vector, Math Value_002), enabled sockets in input order being the mode's operandsNOT)is_unavailable reads true on disabled sockets, is_inactive on those and sockets the mode leaves unused (Switch True while Switch is false)inputs[key], get, find) match an enabled socket's identifier or name and miss disabled ones (Math Value_001 under SINE)identifier reaches every socket, disabled ones includedCompositor nodes take every option through input sockets, and geometry nodes take some (Merge by Distance Mode, Raycast Interpolation):
MENU sockets (Glare Type, Blur Type, Scale Frame Type), default_value taking the exact item namebl_rna.properties["default_value"].enum_items, and the TypeError of a wrong name lists valid namesSocket values take per-class shapes:
NodeSocketVector2D), colors 4, rotations an Eulersocket.bl_rna.properties["default_value"].array_length reads the live lengthdefault_valueNodeSocketVirtual, identifiers starting __extend__)animation_data at socket.path_from_id("default_value")Geometry tree sockets take single values or fields, and a field computes per element where a geometry node consumes it:
display_shape states what a socket takes: LINE a single value, DIAMOND a field, CIRCLE whatever reaches itinferred_structure_type reads what reaches a socket (SINGLE, FIELD, DYNAMIC) in geometry and compositor trees and DYNAMIC in shader treesPosition) read FIELDCIRCLE sockets (Math, Vector Math) make the node's outputs FIELDtree.links.new(output, input, verify_limits=True, handle_dynamic_sockets=False) links sockets of one tree:
RuntimeErrorverify_limits=True removes links past link_limit on either endpoint, and links.new clears hide on both endpointshandle_dynamic_sockets=True to add an item named and typed after the source, returning None for a refused typeis_valid false and add nothinglink.is_muted mutes a link in place, the target reading its own defaultnodes.remove(node) removes the node's links, a held node raising ReferenceError and a held link reading None endpoints with no raiseMulti-input sockets order their links by multi_input_sort_id, each new link added on top:
socket.links lists top first by descending sort id, up to 4095 linkslinks.new with verify_limits=True replaces matching pairs with a new link; False adds another link from that outputlink.swap_multi_input_sort_id(other) swaps link positions on one socket, keeping both links and their mute stateNodeSocket.links scans tree.links on each read and lists muted links. Graph walks index one tree.links pass by target node:
def upstream(tree: bpy.types.NodeTree, root: bpy.types.Node, /, *, kept: Callable[[bpy.types.NodeLink], bool] = lambda link: link.is_valid and not link.is_muted) -> tuple[bpy.types.Node, ...]:
feeding: defaultdict[bpy.types.Node, dict[bpy.types.Node, None]] = defaultdict(dict)
for link in filter(kept, tree.links):
feeding[link.to_node][link.from_node] = None
reached: dict[bpy.types.Node, dict[bpy.types.Node, None]] = {}
pending = [root]
while pending:
node = pending.pop()
if node not in reached:
reached[node] = feeding[node]
pending.extend(reversed(feeding[node]))
return tuple(TopologicalSorter(reached).static_order())
upstream returns sources first and root last over links kept passes:
kept=lambda link: link.is_valid follows muted linksGeometry and compositor trees convert link values by type pair:
Other tree kinds validate links by their own rules:
Shader input as emission and a Shader output into Shader inputs aloneLinks read is_valid false for:
LINE inputlinks.new sets is_valid at creation, and topology changes recompute it, overwriting Python writes:
tree.links find false links, node_warnings holding no entry for them and the node editor alone drawing whyis_valid, unconvertible pairs leaving targets at the stored default_value and fields handing LINE inputs the type's zeroZone input and output nodes start unpaired:
input.pair_with_output(output) adds item sockets to the input, raising RuntimeError for another zone kind or an output already pairedinput.paired_output names the partner, and an output's input comes from a scan of tree.nodesnode_warnings entryZone outputs hold item collections:
| [INDEX] | [ZONE] | [ITEMS] |
|---|---|---|
| [01] | Repeat | repeat_items |
| [02] | Simulation | state_items |
| [03] | For Each | input_items, main_items, generation_items |
| [04] | Closure | input_items, output_items |
Zone bodies run per kind:
CLOSURE with RuntimeErrordomain, input items taking a field outside and one value inside the zoneGeometry, and generation items join each pass's geometryClosures and bundles match items by exact, case-sensitive name:
ERROR in node_warnings and read the default, and type differences convert with an INFO entryERROR/*&|"^~!,{}()+$#@[];:?<>.-%\= and leading and trailing spaces as _, duplicates taking _001define_signature items sync through bpy.ops.node.sockets_sync(node_name=...) in a node editor context alone, links.new never syncing themItem collections (capture_items, bake_items, bundle_items, index_switch_items, enum_items, file_output_items) define variable sockets:
new(socket_type, name) with socket enums (FLOAT, VECTOR, RGBA, GEOMETRY), an idname raising TypeError that lists themVECTOR read back data_type FLOAT_VECTORremove(item), clear(), and move(from_index, to_index), an index past the range moving nothingenum_items and rasterize_items take new(name), index_switch_items and combine_list_items take new()socket_type, Simulation items add attribute_domain, Bake items attribute_domain and is_attributedomain (Capture Attribute on the node), closure, Evaluate Closure, and bundle items structure_typeItem_<n>, For Each Input_<n>, Main_<n>, Generation_<n>) that clear() keepsValue, Value_1 on inputs and Attribute, Attribute_1 on outputsGeometry item in geometry trees and none in shader trees, Item_0 on both zone nodes once pairedA and B and GEOMETRY data in geometry trees, RGBA in othersItem_<n> in item order on both sides, beside the Menu input and Output valueNodeTree.interface declares a group's parameters as sockets and panels:
new_socket(name, description=, in_out=, socket_type=, parent=) takes a base socket idname (NodeSocketFloat)subtype and vector dimensions follow as separate writes refining the item class items_tree returns (NodeTreeInterfaceSocketFloatDistance)socket_typesubtype enum_items read DEFAULT alone on every item class, and an unknown value's TypeError lists subtypes the socket type takesnew_panel(name, description=, default_closed=) appends at root, and move_to_parent(item, parent, to_position) nests itSocket_<n>, panel <n>) that remove and clear() never rewinditems_tree[key] resolves a socket identifier first, then a socket or panel nameitems_tree walks pre-order with panels among sockets, and filters read item_type and in_outcopy(item) inserts at position + 1 in the same parent under fresh identifiers, panels copying their childrenmove and move_to_parent clamp a request to the nearest legal slot with no errorinterface.root_panel as parent, a nameless panel outside items_treeremove(panel) moves panel contents up one level, and move_content_to_parent=False deletes contents with the panelnew_socket with no socket_type creates a NodeSocketFloat itemsocket_type writes reset default_value, min_value, max_value, and subtype, an equal value includedsocket_type writes reset default_input to VALUE where the new type lacks it, and structure_type to AUTO on types without fields or gridsdefault_value writes clamp to float32 limits, and min_value and max_value writes past them store infinitydefault_value, min_value, and max_value seed group nodes and modifier inputs created after the write, existing ones keeping stored valuesPanel toggles bind a Bool socket to its panel header:
is_panel_toggle = True takes effect on a Bool socket inside a non-root panel alone, and other writes do nothingremove(panel) lifts the toggle into the parent with is_panel_toggle kept, and removal takes the toggle firstInput items shape the values a group takes:
structure_type AUTO items read FIELD while feeding DIAMOND sockets alone and SINGLE once feeding a LINE socketstructure_type = "SINGLE" holds an input to one value wherever it linksstructure_type values past AUTO and SINGLE with TypeErrorstructure_type alone, force_non_field writing it as SINGLE or AUTO and reading stale after a later structure_type writedefault_input feeds an implicit input into an unlinked group node socket, the socket reading hide_value truedefault_input takes INDEX and ID_OR_INDEX on Int, POSITION, NORMAL, and handles on Vector, and INSTANCE_TRANSFORM on MatrixSCENE_FRAME takes Float or Int, SELF_OBJECT Object, and UNIFORM_IMAGE_COORDINATES compositor Vector socketsdefault_input writes outside a socket's set raise a TypeError listing the setdefault_input and evaluate default_valuehide_in_modifier hides the modifier panel row alone, properties.inputs.<identifier> evaluating its valueattribute_domaindefault_attribute_name seeds the modifier's attribute_name on an output and sets type = "ATTRIBUTE" with that name on an inputMenu sockets store an item's integer identifier, keeping each selection across renames:
properties.inputs of every modifier on the groupdefault_value, keeping the stored integer until a definition holding it arrivesnode_warnings entry, equal item names includedInterface writes add and remove sockets on every group node and modifier before the call returns, and users keep values by identifier:
remove followed by new_socket drops every stored value of the removed itemtree.copy() keeps every identifiernode_group writes on modifiers and compositor effects keep input values across groups with coinciding identifiersEvery interface write, an equal value and a move to the held position included, retags the tree and each user for evaluation. Sockets key by name and side, first holder staying, and each record writes differing members onto its held identifier in field order:
class Socket(msgspec.Struct, frozen=True, kw_only=True, omit_defaults=True):
name: str
in_out: Literal["INPUT", "OUTPUT"]
socket_type: type[bpy.types.NodeSocket]
description: str | None = None
default_value: bool | int | float | str | tuple[float, ...] | None = None
min_value: float | None = None
max_value: float | None = None
def interfaced(tree: bpy.types.NodeTree, sockets: Iterable[Socket], /) -> None:
match tree.interface:
case bpy.types.NodeTreeInterface() as interface:
live = tuple(item for item in interface.items_tree if isinstance(item, bpy.types.NodeTreeInterfaceSocket))
case _:
raise TypeError(tree)
held = dict(reversed([((item.name, item.in_out), item.identifier) for item in live]))
wanted = {(socket.name, socket.in_out): socket for socket in sockets}
for item in live:
if (key := (item.name, item.in_out)) not in wanted or held[key] != item.identifier:
interface.remove(item)
for key, socket in wanted.items():
identifier = held.get(key) or interface.new_socket(socket.name, in_out=socket.in_out).identifier
for member, value in msgspec.to_builtins(socket, enc_hook=lambda kind: kind.__name__).items():
if msgspec.to_builtins(getattr(current := interface.items_tree[identifier], member), enc_hook=list) != (np.asarray(value, np.float32).tolist() if isinstance(value, float | tuple) else value):
setattr(current, member, value)
Repeat interfaced calls with the same sockets write and tag nothing:
socket_type before the defaults it resets, retyping a fresh item under its identifierNone fields leave a member at the value the socket type gives it, omit_defaults keeping them out of the writefloat32 precision, and compares round the record's floats through np.float32bpy_prop_array values equal other bpy_prop_array values alone, and compares convert them through enc_hook=listmove(item, len(items_tree)) per socket in record order moves each last on its sideTypeError uncaught, a defect in the recordPython-defined trees, nodes, and sockets subclass bpy.types.NodeTree, Node, and NodeSocket, and Blender evaluates none of them:
NodeTree.update() runs more than once per node addition and link change, and tree evaluation runs once from a deferred step it queuesupdate, and evaluation they change runs from the property's own update= callbackpoll join every tree kind, built-in trees included, and poll(cls, ntree) refusing a tree makes nodes.new raise RuntimeErrorNode.init(self, context) builds sockets through inputs.new(<socket idname>, <name>) and outputs.new, nodes.new passing None as contextNodeSocket subclasses define draw(self, context, layout, node, text), register_class raising AttributeError without itlinks.new calls update on both endpoint nodes and skips insert_linkNodeTree.valid_socket_type(cls, idname) filters interface socket types per interface writeTrees reach a desired state through edits in place and keep nodes a user added:
.001 suffixes breaking name keystree.copy()) hold the mark, and marks dedupe by tree order with the first holder keptWrites follow socket creation, each step adding sockets the next one reads:
node_tree, zone pairs, item collections, and node content, then mode members and parentNode clipboard operators copy whole nodes between trees through a node editor, any screen area serving once its ui_type names the tree class:
def pasted(context: bpy.types.Context, area: bpy.types.Area, nodes: tuple[bpy.types.Node, *tuple[bpy.types.Node, ...]], target: bpy.types.NodeTree, /) -> Outcome[frozenset[bpy.types.Node]]:
match nodes[0].id_data:
case bpy.types.NodeTree() as source:
before = frozenset(target.nodes)
case _:
return Error(Fault.of(Reason.ABSENT, repr(nodes[0]), member=bpy.types.NodeTree.__name__))
with ExitStack() as scope:
scope.callback(setattr, area, "ui_type", area.ui_type)
area.ui_type = source.bl_idname
match area.spaces.active:
case bpy.types.SpaceNodeEditor() as space:
space.node_tree = source
case held:
return Error(Fault.of(Reason.OUTSIDE, f"{area!r}.spaces.active", type(held).__name__, member=bpy.types.SpaceNodeEditor.__name__))
for node in source.nodes:
node.select = node in nodes
with context.temp_override(area=area):
copied = catch(bpy.ops.node.clipboard_copy, exception=RuntimeError)()
area.ui_type, space.node_tree = target.bl_idname, target
with context.temp_override(area=area):
answer = copied.bind(lambda _: catch(bpy.ops.node.clipboard_paste, exception=RuntimeError)())
created = frozenset(target.nodes) - before
for node in created if answer.is_error() else ():
target.nodes.remove(node)
return answer.map(lambda _: created).map_error(partial(Fault.of, Reason.FAILED, target.name_full))
pasted(context, context.screen.areas[0], (ramp, noise), material.node_tree) copies geometry tree nodes into an embedded shader tree:
location, ID property marks, Color Ramp elements, zone pairs, item collections, and inner links, clashing names taking .001space.node_tree writes set edit_tree outside temp_override alone, inside it leaving edit_tree None and clipboard operators failing pollnodes holds at least one node, a copy with no selection keeping the previous clipboard for the paste to repeatRuntimeError naming the refused one, and pasted removes them allNew nodes sit at the canvas origin:
location is relative to a parent frame, location_absolute canvas positionparent writes keep the canvas position and rewrite locationnodes.foreach_set("location_absolute", positions.ravel()) over a numpy float32 buffer shaped (len(nodes), 2)dimensions reads zero until a node editor draws the tree, in interface-scaled units, and layouts before a draw space nodes by widthwidth = group.default_group_node_widthnode.panel_states items (identifier, is_collapsed) open and close node panelstext, shrink, and label_sizesocket_idnamenode.show_preview and space.overlay.show_previews are on, overlay.preview_shape taking FLAT or 3Dbpy.ops.node.preview_toggle toggles show_preview on selected nodesWhat SKILL.md sets; muted values are Claude Code's defaults
7 skills in this plugin
/codingUse when writing or reviewing Python that runs inside Blender, covering bpy code from data references to host boundaries/debuggingUse when Python or native code inside Blender gives a wrong value, raises, hangs, crashes, or never stops at a breakpoint, covering debug endpoints, stops by code kind, extension reloads, stack dumps, crash reports, native frames, and GPU captures/extensionsUse when writing or reviewing a Blender extension's registration, preferences, or manifest, covering lifecycle and packagingOther plugins' skills for the same job
npx claudepluginhub bsamiee/rasm --plugin blender