From infrahub
Creates Infrahub transforms converting infrastructure data to JSON, text, CSV, or device configs using Python classes or Jinja2 templates. For config generation, data exports, and artifact pipelines.
npx claudepluginhub opsmill/claude-marketplace --plugin infrahubThis skill is limited to using the following tools:
Expert guidance for creating Infrahub transforms.
Creates and manages Infrahub YAML files for infrastructure objects like devices, locations, organizations, and modules. Use when populating data instances or defining hierarchies, not schemas or queries.
Generates and debugs tested Bloblang transformation scripts from natural language for mapping fields, parsing JSON/CSV/XML, converting timestamps, and filtering arrays.
Provides guidance, code generation, and best practices for response transformer operations in API integrations including third-party APIs, webhooks, SDKs, and OAuth.
Share bugs, ideas, or general feedback.
Expert guidance for creating Infrahub transforms. Transforms convert Infrahub data into different formats -- JSON, text, CSV, device configs, or any text-based output -- using Python classes or Jinja2 templates.
Infrahub config:
!cat .infrahub.yml 2>/dev/null || echo "No .infrahub.yml found"
Existing transforms:
!find . -name "*.py" -path "*/transforms/*" -o -name "*.j2" -path "*/templates/*" 2>/dev/null | head -20
| Priority | Category | Prefix | Description |
|---|---|---|---|
| CRITICAL | Types | types- | Python vs Jinja2 choice |
| CRITICAL | Python | python- | InfrahubTransform class |
| CRITICAL | Jinja2 | jinja2- | Template syntax, filters |
| HIGH | Hybrid | hybrid- | Python + Jinja2 combined |
| HIGH | Artifacts | artifacts- | Output files, targets |
| HIGH | API Ref | api- | Class attrs, methods |
| MEDIUM | Patterns | patterns- | Utilities, CSV, shared |
| LOW | Testing | testing- | Transform/render commands |
Two types of transforms:
| Type | Output | Entry Point |
|---|---|---|
| Python | JSON/dict or text | InfrahubTransform.transform() |
| Jinja2 | Text | .j2 template file |
from infrahub_sdk.transforms import InfrahubTransform
class MyTransform(InfrahubTransform):
query = "my_query"
async def transform(self, data: dict) -> dict:
device = data["DcimDevice"]["edges"][0]["node"]
return {"hostname": device["name"]["value"]}
Follow these steps when creating a transform:
.gql file
that fetches the data to transform. Read
../infrahub-common/graphql-queries.md
for query patterns.InfrahubTransform and implement transform().
Read rules/python-transform.md.
For Jinja2, create a .j2 template. Read
rules/jinja2-template.md.
For hybrid, read
rules/hybrid-python-jinja2.md.python_transforms or jinja2_transforms. See
rules/api-reference.md.infrahubctl transform or
infrahubctl render. See
rules/testing-commands.md.