/infrahub:infrahub-converting-netbox-device-types [netbox-device-type-path...]from infrahub
Converts NetBox device-type and module-type definitions (devicetype-library/NDX format) into Infrahub object templates using a bundled Python converter with schema mapping profiles.
Ships in infrahub. 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; scripts run unread.
Turns NetBox device-type YAML — the format used by netbox-community/devicetype-library and browsable at the NetBox Data Exchange — into Infrahub object templates: reusable blueprints that create a device with all its ports already in place.
The conversion is done by a bundled Python script, not by hand. Hand-converting a 48-port switch means transcribing 48 near-identical blocks, and the library has thousands of device types. The script is exact and repeatable; this skill is about pointing it at the right schema and reading what it tells you.
Before converting, look at the project with read-only tools:
.yml files with
schema in their path..yml files with
mappings in their path.Not for keeping a live NetBox and Infrahub in sync — that is infrahub-sync, a separate product. This skill converts device-type definitions, from the published library or from a one-off export of a running NetBox.
One NetBox file becomes three Infrahub artifacts, because Infrahub splits what NetBox keeps together:
| NetBox | Infrahub | Why |
|---|---|---|
manufacturer: Cisco | OrganizationManufacturer object | Manufacturers are first-class objects |
model, part_number, u_height, weight | DcimDeviceType object | Templates hold no model data |
interfaces: and other component lists | TemplateDcimDevice + component templates | The reusable blueprint |
The template links to the device type, so creating a device from the template also wires up its model.
Module types are a second input family — line
cards, PSUs, and transceivers, in a sibling
module-types/ directory. They carry no slug, which
is how the converter tells the two apart, so a mixed
tree converts in one pass. They follow the same split
(a module type object, optionally a module template)
and land in 04_module_types.yml /
05_module_templates.yml. Read
extending-your-schema.md
before promising much here: a module's ports convert
only onto a module template, and stock
schema-library's DcimModule does not generate one.
With schema-library-modules.yml they are reported as
skipped; schema-library-module-ports.yml carries them
once DcimModule sets generate_template: true.
Module port names carry NetBox's {module} token, which
no conversion can resolve — the bay position is only
known once the module is installed. Once the ports
import as DcimModulePort declarations on a module
template, the bundled generator resolves the token per
installed module and creates the real device
interfaces from the interface ports. Console ports need
a console interface kind in the schema, and power ports
stay declarations. See
generators-module-ports.md.
Three facts drive almost every surprise in this workflow — explain them rather than assuming them:
Template* kinds are generated, not written.
generate_template: true on a node creates them;
without it they do not exist.Component
relationships. An Attribute relationship keeps
pointing at real objects.New to Infrahub's data model, or explaining it to someone who is? concepts.md covers these with links to the Infrahub docs.
| Priority | Category | Prefix | Description |
|---|---|---|---|
| CRITICAL | Workflow | workflow- | generate_template must be enabled first; the bundled scripts do the work |
| CRITICAL | Mapping | mapping- | Names come from the schema, never guessed; competing fields declare precedence |
| CRITICAL | Format | format- | Envelope, Template<Kind>, nested components |
| HIGH | Naming | naming- | Slug-based, parent-namespaced, unique |
| HIGH | Coverage | coverage- | Report what did not convert |
| MEDIUM | Output | output- | Up to five files, load order, branch-first |
Full index: rules/_sections.md.
Template* kinds exist only where a node declares
generate_template: true. Check the target schema
rather than assuming either way — this is the most
common reason a conversion loads nothing.
In the OpsMill schema-library the answer depends on
the version: v2 and later enable it on DcimDevice
in base/dcim.yml, while pre-v2 shipped the line
commented out. Custom schemas usually have to add it.
Read rules/workflow-schema-prerequisites.md.
If it is not enabled, explain the change rather than
making it silently: the flag generates
TemplateDcimDevice plus a component template for
every Component relationship, it is additive, and the
schema has to be reloaded for the kinds to appear.
Enabling it touches the user's source of truth, so it
is their call — show the one-line diff and let them
decide.
The converter binds NetBox fields to Infrahub attributes through a profile, so it never guesses a name.
scripts/mappings/schema-library.yml, or
scripts/mappings/schema-library-modules.yml if you
also want module types, or
scripts/mappings/schema-library-module-ports.yml if
you want their ports too (see
generators-module-ports.md).scripts/mappings/_template.yml
into the working directory (say
./mappings/my-schema.yml, never inside $SKILL,
which a plugin reinstall wipes) and fill it in by
reading the schema YAML, kind by kind and attribute
by attribute.Read
rules/mapping-profile-driven.md
and reference.md for the full field
inventory on both sides. Where two NetBox fields
compete for one Infrahub attribute — description vs
comments, interface label vs description —
declare precedence with fallback rather than
picking one and losing the other; see
rules/mapping-fallback-sources.md.
Check for a node that already covers a gap before
concluding one is missing. A console port is often
modelled as a node inheriting the interface generic, in
which case it rides the device's existing interfaces
relationship and needs no schema change at all — only
a profile entry. When two lists share one relationship,
read
rules/mapping-shared-relationships.md:
getting that wrong discards the larger list silently.
extending-your-schema.md
lists what schema-library and infrahub-demo-dc already
provide.
Two sources, depending on where the device types live.
From a running NetBox. The catalogue in someone's
own instance is usually what they actually want to
import, and it is not the same set as the published
library. scripts/netbox_export_device_types.py reads
a live instance over its REST API and writes the
library file format. It needs
pynetbox 7.0 or
later, NetBox's Python client, and
PyYAML
in the Python environment that runs it. Install both
the way that environment's package manager documents.
# SKILL is this skill's own directory, wherever it is installed
SKILL=/path/to/infrahub-converting-netbox-device-types
export NETBOX_TOKEN=...
python "$SKILL/scripts/netbox_export_device_types.py" \
--url https://netbox.example.com \
--in-use \
--module-types \
--output-dir ./netbox-export
Stay in the user's working directory and name the
scripts by their full path. $SKILL is wherever this
skill is installed, which for a plugin install is under
~/.claude/plugins/cache/ — a directory reinstalling
the plugin wipes. Running from there puts the export,
the cloned library and the generated YAML inside it, so
the next update deletes the user's data. Everything the
commands below read or write (./netbox-export,
devicetype-library/, ./generated) stays relative to
where the user actually is.
--in-use keeps only device types with at least one
device, and module types with at least one module,
which on a real instance is a much smaller and more
relevant set than the whole catalogue.
It reports anything that did not come across cleanly: fields NetBox holds that the library format cannot carry, fields NetBox left unset that the library format requires, endpoints absent from that NetBox version, file names that collided after sanitising, and a NetBox older than the 4.5 front-port shape. Read that list before converting, the same way you read the conversion coverage report before loading.
This is a one-way snapshot into files, not a sync. Continuous replication is infrahub-sync, a separate product.
From the published library. For seeding vendor
models nobody has yet, use the upstream
netbox-community/devicetype-library
repository. Clone it into a devicetype-library/
directory with the --depth 1, --filter=blob:none and
--sparse options, then set the
sparse checkout
to device-types and module-types. Later steps and
examples.md use devicetype-library/ as a relative
path. A sparse checkout alone still downloads every
file: all three options are needed to keep the download
small.
A full copy is 1.6 GB, almost all of it rack elevation
images the converter never reads. The two definition
directories hold all 11,500+ device types and 2,000+
module types in about 60 MB. Leave out module-types/
if you only want devices.
The converter accepts files, directories (walked recursively), and globs.
Run it — do not reimplement it. Both scripts carry correctness that a hand-rolled equivalent silently loses, and the failure looks like success: valid YAML, no error, no coverage report, wrong data. Read rules/workflow-use-the-bundled-scripts.md. When a schema does not fit, the answer is a mapping profile, not a different script.
python "$SKILL/scripts/netbox_to_infrahub_templates.py" \
devicetype-library/device-types/Cisco/ \
--mapping "$SKILL/scripts/mappings/schema-library.yml" \
--output-dir ./generated \
--report ./generated/coverage-report.md
For a live export, point it at the export directory.
It walks device-types/ and module-types/ together,
which needs the profile that maps both:
python "$SKILL/scripts/netbox_to_infrahub_templates.py" \
./netbox-export/ \
--mapping "$SKILL/scripts/mappings/schema-library-modules.yml" \
--output-dir ./generated \
--report ./generated/coverage-report.md
Exit codes: 0 converted, 1 bad profile or
malformed input, 2 no files matched.
It refuses two device types with the same model and
lists every pair. A template names its device type by
model, so loading both would overwrite one with the
other without an error; the published library has a
handful, shared between vendors. Leave one of each out
of the input.
Before writing or hand-editing any emitted file, read
rules/format-template-objects.md
— the envelope, the Template<Kind> split, and the
{kind, data} component wrapper are what makes the
output loadable — and
rules/naming-template-names.md,
because component names collide across device types
unless they are namespaced by their parent.
Against a typical schema, a large part of each NetBox file has nowhere to go. Open the report and, in the response:
console-ports" is unactionable to someone
who does not know component templates come only from
Component relationships. Give the reason.Offer — do not unilaterally rewrite their schema. It is a migration against their source of truth.
Read rules/coverage-report-unmapped.md.
Two cases worth flagging by name when they apply:
TemplateDcimModuleBay),
which turns an empty template into a useful one; the
schema-library-modules.yml profile maps them. On
pre-v2, or a schema with no bay node, they are still
reported as skipped. See
extending-your-schema.md.interfaces relationship.infrahubctl branch create netbox-import
for file in generated/0*.yml; do
infrahubctl object load "$file" --branch netbox-import
done
Load order is dependency order — manufacturers, then device types, then templates. Read rules/output-load-order.md. Never load a bulk import straight to the default branch.
Reach for the mapping profile first — it covers new kinds, renamed attributes, extra component lists, and conditional values without touching Python. Change the script only for a genuinely new mechanism (a transform kind that does not exist yet). Adding a schema-specific special case to the script is how it stops working for everyone else.
Its tests live at
tests/scripts/test_netbox_to_infrahub_templates.py,
and the module-port generator's at
tests/scripts/test_materialize_module_ports.py. Run
them after any change:
uv run invoke test
| File | Read it when |
|---|---|
| concepts.md | The Infrahub model is unfamiliar, or you need to explain it |
| reference.md § Exporting from a live NetBox | The device types are in a running NetBox: the flags, the auth, and what the export reports |
| extending-your-schema.md | Turning a reported gap into a schema change |
| generators-module-ports.md | Module ports imported as declarations and the {module} token needs resolving into real device interfaces |
| reference.md | Looking up a NetBox field or its Infrahub counterpart |
| examples.md | Needing a worked conversion, profile, or schema patch |
| rules/ | Applying or checking a specific rule |
| ../infrahub-managing-objects/rules/value-profiles-templates.md | Authoring templates by hand, or choosing profiles vs templates |
| ../infrahub-managing-schemas/rules/relationship-component-parent.md | Adding the component relationships templates are generated from |
Link these when explaining a concept — a user who follows one link learns the feature, not just this conversion.
concepts.md (opens in a new tab)examples.md (opens in a new tab)extending-your-schema.md (opens in a new tab)generators-module-ports.md (opens in a new tab)reference.md (opens in a new tab)rules/_sections.md (opens in a new tab)rules/coverage-report-unmapped.md (opens in a new tab)rules/format-template-objects.md (opens in a new tab)rules/mapping-fallback-sources.md (opens in a new tab)rules/mapping-profile-driven.md (opens in a new tab)rules/mapping-shared-relationships.md (opens in a new tab)rules/naming-template-names.md (opens in a new tab)rules/output-load-order.md (opens in a new tab)rules/workflow-schema-prerequisites.md (opens in a new tab)rules/workflow-use-the-bundled-scripts.md (opens in a new tab)scripts/mappings/_template.yml (opens in a new tab)scripts/mappings/schema-library-module-ports.yml (opens in a new tab)scripts/mappings/schema-library-modules.yml (opens in a new tab)scripts/mappings/schema-library.yml (opens in a new tab)scripts/materialize_module_ports.gql (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
18 skills in this plugin
/infrahub-analyzing-dataAnalyzes and correlates live Infrahub data via the MCP server — answers operational questions, detects drift, and investigates impact. TRIGGER when: querying infrastructure data, checking compliance, investigating change impact, producing ad-hoc reports. DO NOT TRIGGER when: writing automated checks, building transforms, designing schemas, populating data files, planning an Infrahub version upgrade (use infrahub-planning-upgrades). ALWAYS pass the user's question verbatim as args — this skill runs in a forked context and cannot see the parent conversation. Invoking without args will fail./infrahub-analyzing-diagnosticsAnalyze an already-collected infrahub-collect diagnostic bundle — traceback and failure triage across service logs, incident correlation, and known-issue matching against opsmill/infrahub GitHub issues. TRIGGER when: the user says they collected a diagnostic bundle, gives you a bundle path, or pastes bundle contents — and asks what's wrong, wants the logs or tracebacks analyzed, asks "what does this bundle say", wants errors triaged/correlated, or asks whether a crash is a known issue. DO NOT TRIGGER when: no bundle exists yet — collect one first (use infrahub-collecting-diagnostics), filing the issue itself (use infrahub-reporting-issues), or querying live data (use infrahub-analyzing-data)./infrahub-auditing-repoAudits an Infrahub repository against best practices and rules, producing a structured compliance report. TRIGGER when: reviewing repo for compliance, onboarding to existing project, pre-deployment validation, catching issues. DO NOT TRIGGER when: creating schemas, writing checks/generators, querying live data, populating objects, planning an Infrahub version upgrade (use infrahub-planning-upgrades). ALWAYS pass the user's request verbatim as args, with any scope, path, or focus they named. This skill runs in a forked context and cannot see the parent conversation./infrahub-collecting-diagnosticsCollect a redacted local diagnostic bundle (logs, config, version, state) for an OpsMill expert hand-off. TRIGGER when: Infrahub is broken/failing/erroring, the user asks for help debugging, wants to collect logs/diagnostics, prepares a hand-off for OpsMill support, or reports a crash/timeout/connection issue (upgrade failure, stuck branch, container CrashLoopBackOff, 500s, OOM). DO NOT TRIGGER when: debugging a check, transform, generator, menu, or schema in the repository (use the infrahub-managing-* skills), a bundle has already been collected and the user wants it analyzed (use infrahub-analyzing-diagnostics), filing a public GitHub issue (use infrahub-reporting-issues), running operational queries (use infrahub-analyzing-data), or planning an upgrade that has not run yet (use infrahub-planning-upgrades)./infrahub-commonShared references and cross-cutting rules for all Infrahub skills — GraphQL syntax, .infrahub.yml format, and common patterns. DO NOT TRIGGER directly — loaded automatically by other Infrahub skills when they need shared references./infrahub-designing-modelsDesigns an Infrahub data model before any schema YAML exists. TRIGGER when: someone has an idea or a problem but no agreed model, asks "what should I model" or "help me design my data model", wants diagrams, spreadsheets or exports turned into a design, has a scope too big for one feature and needs it split, or is updating, extending or fixing an existing design brief. DO NOT TRIGGER when: a design or model sketch already exists and the user wants schema YAML (use infrahub-managing-schemas), wants to load data (use infrahub-managing-objects or infrahub-importing-data), or wants to learn concepts (use infrahub-teaching-concepts).infrahub@opsmill is listed by opsmill/claude-marketplace — review the source before installing
npx claudepluginhub opsmill/claude-marketplace --plugin infrahubOther plugins' skills for the same job