Infrahub Schema Creator
Overview
Expert guidance for designing and building Infrahub
schemas. Schemas are YAML files defining nodes (concrete
types), generics (abstract base types), attributes,
relationships, and extensions.
Project Context
Existing schemas in this project:
!find . -name "*.yml" -path "*/schemas/*" -o -name "*schema*" -name "*.yml" 2>/dev/null | head -20
Infrahub config (if present):
!cat .infrahub.yml 2>/dev/null || echo "No .infrahub.yml found"
If invoked with arguments (e.g., /infrahub:managing-schemas Ipam Vlan VlanGroup),
use the first argument as the namespace and remaining arguments as node names.
When to Use
- Designing new data models or schema nodes
- Adding attributes or relationships to existing schemas
- Setting up hierarchical location trees or component/parent patterns
- Configuring display properties (human_friendly_id, display_label)
- Migrating or refactoring existing schemas
- Debugging schema validation errors
Rule Categories
| Priority |
Category |
Prefix |
Description |
| CRITICAL |
Naming |
naming- |
Namespace, node, attribute naming |
| CRITICAL |
Relationships |
relationship- |
IDs, peers, component/parent |
| HIGH |
Attributes |
attribute- |
Defaults, dropdowns, deprecated |
| HIGH |
Hierarchy |
hierarchy- |
Hierarchical generics, parent/children |
| HIGH |
Display |
display- |
human_friendly_id, order_weight |
| MEDIUM |
Extensions |
extension- |
Cross-file via extensions block |
| MEDIUM |
Uniqueness |
uniqueness- |
Constraint format, __value suffix |
| MEDIUM |
Migration |
migration- |
Add/remove attributes, state: absent |
| LOW |
Validation |
validation- |
Common errors, pre-check checklist |
Schema File Basics
---
# yaml-language-server: $schema=https://schema.infrahub.app/infrahub/schema/latest.json
version: "1.0"
generics: # Abstract base definitions (shared attributes/relationships)
- ...
nodes: # Concrete object types
- ...
extensions: # Add attributes/relationships to existing nodes from other files
nodes:
- ...
Always include the $schema comment for IDE validation.
Only version is required at the top level.
Workflow
Follow these steps when creating or modifying a schema:
- Gather requirements — Identify the node types,
their attributes, and how they relate to each other.
Ask about hierarchies, dropdowns, and display needs.
- Read relevant rules — Read
rules/naming-conventions.md
for naming constraints,
rules/attribute-defaults-and-types.md
for attribute kinds and defaults, and
rules/relationship-identifiers.md
for bidirectional relationship setup.
- Build the schema YAML — Start with the
$schema
comment and version: "1.0". Define generics first
(if any), then nodes. Apply naming, display, and
relationship rules from step 2.
- Configure display properties — Set
human_friendly_id, display_label, and
order_weight per
rules/display-human-friendly-id.md
and rules/display-order-weight.md.
- Validate — Run
infrahubctl schema check per
validation.md. Fix any errors
using rules/validation-common-errors.md.
Supporting References
1---2name: infrahub-managing-schemas3description: Creates, validates, and modifies Infrahub schema YAML files — nodes, generics, attributes, relationships, and extensions. TRIGGER when: designing data models, adding schema nodes, validating schema definitions, planning schema migrations. DO NOT TRIGGER when: populating data objects, writing checks/generators/transforms, querying live data.4---56# Infrahub Schema Creator78## Overview910Expert guidance for designing and building Infrahub11schemas. Schemas are YAML files defining nodes (concrete12types), generics (abstract base types), attributes,13relationships, and extensions.1415## Project Context1617Existing schemas in this project:18!`find . -name "*.yml" -path "*/schemas/*" -o -name "*schema*" -name "*.yml" 2>/dev/null | head -20`1920Infrahub config (if present):21!`cat .infrahub.yml 2>/dev/null || echo "No .infrahub.yml found"`2223If invoked with arguments (e.g., `/infrahub:managing-schemas Ipam Vlan VlanGroup`),24use the first argument as the namespace and remaining arguments as node names.2526## When to Use2728- Designing new data models or schema nodes29- Adding attributes or relationships to existing schemas30- Setting up hierarchical location trees or component/parent patterns31- Configuring display properties (human_friendly_id, display_label)32- Migrating or refactoring existing schemas33- Debugging schema validation errors3435## Rule Categories3637| Priority | Category | Prefix | Description |38| -------- | -------- | ------ | ----------- |39| CRITICAL | Naming | `naming-` | Namespace, node, attribute naming |40| CRITICAL | Relationships | `relationship-` | IDs, peers, component/parent |41| HIGH | Attributes | `attribute-` | Defaults, dropdowns, deprecated |42| HIGH | Hierarchy | `hierarchy-` | Hierarchical generics, parent/children |43| HIGH | Display | `display-` | human_friendly_id, order_weight |44| MEDIUM | Extensions | `extension-` | Cross-file via extensions block |45| MEDIUM | Uniqueness | `uniqueness-` | Constraint format, __value suffix |46| MEDIUM | Migration | `migration-` | Add/remove attributes, state: absent |47| LOW | Validation | `validation-` | Common errors, pre-check checklist |4849## Schema File Basics5051```yaml52---53# yaml-language-server: $schema=https://schema.infrahub.app/infrahub/schema/latest.json54version: "1.0"5556generics: # Abstract base definitions (shared attributes/relationships)57 - ...58nodes: # Concrete object types59 - ...60extensions: # Add attributes/relationships to existing nodes from other files61 nodes:62 - ...63```6465Always include the `$schema` comment for IDE validation.66Only `version` is required at the top level.6768## Workflow6970Follow these steps when creating or modifying a schema:71721. **Gather requirements** — Identify the node types,73 their attributes, and how they relate to each other.74 Ask about hierarchies, dropdowns, and display needs.752. **Read relevant rules** — Read76 [rules/naming-conventions.md](./rules/naming-conventions.md)77 for naming constraints,78 [rules/attribute-defaults-and-types.md](./rules/attribute-defaults-and-types.md)79 for attribute kinds and defaults, and80 [rules/relationship-identifiers.md](./rules/relationship-identifiers.md)81 for bidirectional relationship setup.823. **Build the schema YAML** — Start with the `$schema`83 comment and `version: "1.0"`. Define generics first84 (if any), then nodes. Apply naming, display, and85 relationship rules from step 2.864. **Configure display properties** — Set87 `human_friendly_id`, `display_label`, and88 `order_weight` per89 [rules/display-human-friendly-id.md](./rules/display-human-friendly-id.md)90 and [rules/display-order-weight.md](./rules/display-order-weight.md).915. **Validate** — Run `infrahubctl schema check` per92 [validation.md](./validation.md). Fix any errors93 using [rules/validation-common-errors.md](./rules/validation-common-errors.md).9495## Supporting References9697- **[reference.md](./reference.md)** -- Complete property98 tables for nodes, generics, attributes, relationships99- **[examples.md](./examples.md)** -- Full schema patterns100 from production repos101- **[validation.md](./validation.md)** -- `infrahubctl`102 commands, migration strategies, pre-validation checklist103- **[../infrahub-common/infrahub-yml-reference.md](../infrahub-common/infrahub-yml-reference.md)**104 -- .infrahub.yml project configuration105- **[../infrahub-common/rules/](../infrahub-common/rules/)** -- Shared rules106 (git integration, caching) across all skills107- **[rules/](./rules/)** -- Individual rules by category108 prefix