/netbox-labs:netbox-data-modelingfrom netbox-labs
Design and manage NetBox data models covering site/location hierarchy, IPAM organization, device modeling, tenant assignment, custom fields vs tags vs config contexts, dependency ordering, and relationship patterns.
Ships in netbox-labs. 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.
Your knowledge of NetBox data models may be outdated. Available model types, field options, and relationship patterns evolve between releases. Prefer retrieval over pre-trained knowledge.
| Source | URL / Method | Use for |
|---|---|---|
| Data model docs | https://netboxlabs.com/docs/netbox/models/ | All model types and fields |
| Custom fields docs | https://netboxlabs.com/docs/netbox/customization/custom-fields/ | Field types, validation, filtering |
| NetBox repo | https://github.com/netbox-community/netbox | Model source code, migrations |
| NetBox MCP server | If configured — explore existing data model, inspect object schemas | Discover current structure |
Load this skill when you need to:
For API mechanics (authentication, pagination, error handling), see netbox-api-integration.
Every NetBox object inherits from one of three base classes:
| Base Class | Purpose | Examples | Key Traits |
|---|---|---|---|
| PrimaryModel | Real infrastructure objects | Device, Site, Prefix, Rack | Has description, comments, owner |
| OrganizationalModel | Categorization/taxonomy | RIR, IPAM Role, ClusterType | Unique name + slug |
| Nested group model | Recursive hierarchies | Region, Location, DeviceRole | parent FK to self; NestedLtreeGroupModel (PostgreSQL ltree) on 4.7+, NestedGroupModel (MPTT) on 4.5–4.6 |
All three inherit from NetBoxModel, which provides: custom fields, tags, export templates, custom links, bookmarks, journaling, change logging, notifications, event rules. Every model you interact with has these features.
NetBox 4.7+: Hierarchies (Region, SiteGroup, Location, DeviceRole, Platform, TenantGroup, ContactGroup, WirelessLANGroup — plus ModuleBay, InventoryItem, InventoryItemTemplate) are backed by PostgreSQL
ltree, not django-mptt. Thelft/rght/tree_id/levelcolumns are gone:levelis a Python property only and cannot be used in a filter ororder_by. Renames/reparents cascade to descendants automatically. TheparentFK, the RESTparent_id/ancestor_idfilters, and descendant-inclusive filters like?region_id=are unchanged, so the modeling advice below applies on every version. Plugin/script code:get_ancestors(),get_descendants(),get_children(),add_related_count()remain;get_root(),get_family(),is_leaf_node(),move_to(),insert_at()are gone. (NestedGroupModelstill exists for plugins but is deprecated.)
NetBox 4.5: DeviceRole and Platform changed from OrganizationalModel to a nested group model — they support parent-child hierarchies on 4.5–4.7.
| App | Scope | Key Models |
|---|---|---|
| dcim | Physical infrastructure | Region, Site, Location, Rack, RackType, Device, DeviceType, Manufacturer, DeviceRole, Platform, Interface, MACAddress, PowerPanel/PowerFeed, CoolingSource/CoolingFeed (4.7), ModuleBayType (4.7) |
| ipam | IP addressing | RIR, Aggregate, Prefix, IPAddress, IPRange, VRF, VLAN, VLANGroup, ASN |
| circuits | Connectivity | Provider, Circuit, CircuitGroup, VirtualCircuit |
| tenancy | Ownership | TenantGroup, Tenant, Contact, ContactAssignment |
| virtualization | VMs | ClusterType, Cluster, VirtualMachine, VMInterface, VirtualDisk |
| vpn | Tunnels/VPNs | Tunnel, TunnelGroup, L2VPN, IKE/IPSec policies |
| wireless | Wireless | WirelessLAN, WirelessLANGroup, WirelessLink |
See references/model-map.md for the complete relationship map.
Region (geographic, recursive) SiteGroup (functional, recursive)
\ /
└──────── Site ──────────────┘
│
Location (recursive, within site)
│
Rack → Device
See references/model-map.md for the complete relationship map and hierarchy design guidance.
RIR → Aggregate (top-level allocation, e.g., 10.0.0.0/8)
└── Prefix (auto-nests by CIDR containment)
├── child Prefixes
├── IPRange
└── IPAddress
VRF ──── scopes Prefixes, IPAddresses, IPRanges
VLAN ←── linked to Prefix (optional)
Key rules:
status=container for summary/aggregate prefixes, status=active for allocatedenforce_unique=True on VRFs to prevent duplicate prefixesport_mappings (["tcp/53", "udp/53"]) — one service can span protocols. protocol + ports are deprecated (removed in 5.0) and read back null for multi-protocol services. On 4.5–4.6 use protocol + ports and create one service per protocol.Scope pattern (4.x): Prefixes and VLANGroups use CachedScopeMixin — a generic FK (scope_type + scope_id) rather than a direct site FK. VLANGroup scope accepts Region, SiteGroup, Site, Location, Rack, ClusterGroup, Cluster (this full set since 4.5), plus RackGroup as of 4.6.
# Setting scope via API
{"prefix": "10.0.1.0/24", "scope_type": "dcim.site", "scope_id": 42}
Manufacturer → DeviceType (template with component templates)
↓ (instantiation)
DeviceRole + Site + DeviceType → Device (with auto-created components)
form_factor, width, outer_width/height/depth/unit fields are deprecated; in 5.0 they are removed and rack_type becomes mandatory. u_height, starting_unit, desc_units, mounting_depth stay on the Rack.MACAddress has been a standalone model (multiple per interface, one primary) since NetBox 4.2 — on all of 4.5–4.7 it is not just a field on Interface. 4.7+: Interface/VMInterface
mac_addressis writable — writing it creates or updates the primary MACAddress in one call;MACAddress.is_primaryis read-only.
NetBox 4.7+ device modeling additions (all optional; ignore on 4.5–4.6):
- ModuleBayType — allow-list of what fits where. M2M
module_bay_typeson ModuleBay, ModuleBayTemplate, and ModuleType. Installation is rejected only when both bay and module type declare types and share none; template types propagate to instantiated bays. Read-onlyModule.is_bay_compatible/ModuleBay.is_module_compatible.- Module relocation — PATCH a Module's
module_bayto move it (device derived from the bay); the module's subtree moves with it. Cross-device moves require no cables, IPs, VLANs, or other topology on the moved components.- Channelized interfaces — set
channels(e.g. 4) on the physical parent; create one subinterface per channel withparent+channel_id(1-based) and typechannel(or the real transceiver type). One cable terminates on the parent; NetBox traces a path per channel. Same fields on InterfaceTemplate. Don't model breakouts as ad-hoc virtual interfaces.end_of_lifedate on DeviceType/ModuleType — use for lifecycle planning instead of a custom field.- Cooling —
cooling_method(air/liquid/hybrid/immersion) on Device/DeviceType/ModuleType (device inherits from its type on create);cooling_capability(air-only/hybrid/liquid-only) +cooling_capacity(kW) on Rack/RackType (rack inherits from type). See §3a for full cooling topology.
PowerPanel (site, location?) → PowerFeed (→ rack?) → PowerPort ⇄ PowerOutlet (device components)
CoolingSource (site, location?) → CoolingFeed (→ rack?) → CoolingIntake ← CoolingOutflow (device components)
site required, location optional, type, status, fluid_type, cooling_capacity (kW)rack (optional); status, cooling_capacity, max_flow/max_flow_unit, tenantcooling_outflow points to the upstream outflow (usually on another device — a CDU); an outflow's cooling_intake points to the intake on the same devicedcim/cooling-sources/, dcim/cooling-feeds/, dcim/cooling-intakes/, dcim/cooling-outflows/, plus -templates/Tenant is an optional FK on nearly every PrimaryModel: Site, Device, Rack, Prefix, VLAN, VRF, Circuit, VM, Cluster, IPAddress, etc.
Pattern: TenantGroup (hierarchy) → Tenant → assign to objects
Use cases:
Anti-pattern: Don't overload Tenant for two dimensions (e.g., both "customer" and "department"). Use Tenant for the primary ownership dimension; use custom fields or tags for secondary dimensions.
Contacts use a generic relation pattern: ContactAssignment links any object to a Contact with a ContactRole.
Contact + ContactRole + any object → ContactAssignment
ContactGroups organize contacts hierarchically. Multiple contacts with different roles can be assigned to the same object.
| Question | → Custom Field | → Tag | → Config Context |
|---|---|---|---|
| Does it have a value beyond yes/no? | ✅ | ❌ | ✅ |
| Applied across many object types? | ❌ (scoped) | ✅ | ❌ (devices/VMs only) |
| Need to filter/search by it? | ✅ | ✅ | ❌ (not directly) |
| Used by automation/config rendering? | ❌ | ❌ | ✅ |
| Inherited/computed from hierarchy? | ❌ | ❌ | ✅ |
| Per-object unique value? | ✅ | ❌ | ❌ (matched by criteria) |
Examples:
See references/custom-field-types.md for all field types and decision guidance.
{"value": "prod", "label": "Production"} objects (REST and GraphQL); still write the raw value. 4.5–4.6 return the raw valueALLOWED_URL_SCHEMES (scheme-less values become https://…); nulls_first controls where empty values sort; read-only status (active/provisioning/deleting) — create-with-default and delete run as a background job above BULK_UPDATE_CHUNK_SIZE objects, and the field is not live until activevalidation_schema (4.6+) to enforce a JSON Schema on valueschoice_colors, 4.6+) — this is what release notes call the "color custom field", not a new field typegroup_name for UI organization?cf_<field_name>=<value>object_types to relevant models (don't let every tag appear everywhere)?tag=<slug>config_context is pre-rendered and cached on the object; ?exclude=config_context is silently ignored on every 4.7.x. On 4.7.0–4.7.2 it is always loaded; on 4.7.3+ ?omit=config_context (or ?fields=/?brief=True) skips the DB annotation again. On 4.5–4.6 trim it with ?omit=config_context (4.5.2+) or ?exclude=config_context when listing devices/VMs — see netbox-api-integrationWhen bulk-importing data, create objects in dependency order. Required FKs must exist before the dependent object.
High-level order:
See references/dependency-order.md for the complete ordered list.
cf_environment=production AND tag production. Pick one.cooling_method, cooling_capability/cooling_capacity, end_of_life, and the cooling models instead of cf_cooling/cf_eol.| Change | Impact |
|---|---|
| Hierarchies on ltree | level not filterable/orderable; renames cascade; NestedGroupModel → NestedLtreeGroupModel for plugins. Restores from a 4.7.0 pg_dump lose cascade triggers — run rebuild_ltree_paths --check (fixed 4.7.1) |
| Cooling models | CoolingSource → CoolingFeed → CoolingIntake/CoolingOutflow (+ templates); cooling_method on Device/DeviceType/ModuleType; cooling_capability/cooling_capacity on Rack/RackType |
| ModuleBayType | M2M module_bay_types on ModuleBay/ModuleBayTemplate/ModuleType; compatibility enforced when both sides declare types; endpoint dcim/module-bay-types/ |
| Channelized interfaces | channels on parent, channel_id + parent on subinterfaces, channel interface type; one cable on the parent, one path per channel |
| Module relocation | PATCH module_bay to move a module (cross-device if no active topology) |
Service port_mappings | Replaces protocol + ports (deprecated, removed 5.0); multi-protocol services |
| Rack fields deprecated | form_factor, width, outer_* on Rack — move to RackType; rack_type mandatory in 5.0 |
end_of_life | Date on DeviceType/ModuleType |
Interface mac_address writable | Creates/updates the primary MACAddress; MACAddress.is_primary |
| Custom field selection values | Returned as {value, label}; raw value on write. URL fields validated against ALLOWED_URL_SCHEMES; nulls_first; read-only status with background provisioning |
| Config context cached | Pre-rendered; ?exclude=config_context ignored on every 4.7.x; ?omit=config_context skips the DB work again on 4.7.3+ |
| Change | Impact |
|---|---|
| DeviceRole → NestedGroupModel | Design role hierarchies (e.g., network → network/router, network/switch) |
| Platform → NestedGroupModel | Design platform hierarchies (e.g., cisco-ios → cisco-ios/xe, cisco-ios/xr) |
| MACAddress standalone model (since 4.2) | MAC addresses are first-class objects, not just interface fields — applies on every supported version |
| VirtualDeviceContext | Model VDCs on multi-tenant devices |
| CachedScopeMixin on Prefix/VLANGroup | Use scope_type/scope_id instead of direct site FK |
| v2 API tokens | Use Bearer nbt_<key>.<secret> format |
| ConfigContextProfile | Validate config context data against JSON Schema |
| VirtualCircuit, CircuitGroup | New circuit modeling options |
| VirtualDisk | Disk modeling for VMs |
| Change | Impact |
|---|---|
| VirtualMachineType | Reusable VM classification (like DeviceType) supplying default platform/vCPUs/memory; endpoint virtualization/virtual-machine-types/. VM gains optional virtual_machine_type FK |
VM cluster now optional | A VM must be tied to at least one of site, cluster, or device — clusterless VMs attached directly to a Device are now first-class |
| CableBundle | Logical grouping of cables (conduit/trunk/harness); Cable.bundle FK, optional, does not affect tracing; endpoint dcim/cable-bundles/ |
| RackGroup (flat) | Secondary, non-hierarchical rack categorization (row/aisle/cage) orthogonal to Location; Rack.group FK; endpoint dcim/rack-groups/. Can scope VLANGroups |
| VLANGroup scope += rackgroup | rackgroup added to the VLANGroup scope types (full set: region/sitegroup/site/location/rackgroup/rack/clustergroup/cluster) |
ASN role | ASNs can now carry an ipam Role (Roles classify prefixes, VLANs, and ASNs) |
JSON CF validation_schema | JSON custom fields can enforce a JSON Schema |
| Choice colors | Per-choice colors on selection/multiselect choice sets (choice_colors) — not a new field type |
| v1 API tokens | Deprecated in 4.6, removed in 5.0; v2 nbt_ tokens return plaintext once at creation (4.6.1) |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub netboxlabs/skills --plugin netbox-labs22 skills in this plugin
/netboxHub skill for the NetBox ecosystem. Routes to specialized skills for data modeling, API integration, plugin development, change management, discovery, assurance, automation, and migration. Load this skill first to find the right specialist.
/netbox-administrationNetBox server administration: configuration, authentication backends (local/LDAP/SAML/OIDC), object permissions, API tokens, performance tuning, backups, upgrades, and housekeeping. Use when managing a NetBox instance rather than consuming its API.
/netbox-api-integrationBest practices for building integrations with NetBox REST and GraphQL APIs. Use when building NetBox API integrations, reviewing integration code, troubleshooting NetBox performance issues, planning automation architecture, writing scripts that interact with NetBox, using pynetbox, configuring Diode for data ingestion, or implementing NetBox webhooks and branching workflows.
/netbox-asset-lifecycleNetBox Asset Lifecycle — a commercial NetBox Labs feature that tracks equipment procurement from plan to install (BOMs, vendors, purchase orders, shipments, receiving) plus spares pools with stock-level allocations. Use when working with the asset-lifecycle REST or GraphQL API, driving greenfield procurement or brownfield sparing workflows over the API (generate BOM, install from shipment or spare, archive), or modeling vendors, purchase orders, shipments, and spares.
/netbox-assuranceNetBox Assurance drift detection and deviation management. Use when working with network state comparison, deviation review/remediation, data source configuration, or understanding how intended vs actual network state is reconciled in NetBox Cloud and Enterprise.
/netbox-automation-patternsEnd-to-end automation patterns with NetBox — event-driven workflows (event rules, webhooks), infrastructure-as-code (Ansible, Terraform), and GitOps integration. Use when building, advising on, or troubleshooting NetBox automation pipelines.Other plugins' skills for the same job