/infrahub:infrahub-managing-checks [check-name] [description...]from infrahub
Creates, modifies and debugs Infrahub check definitions — Python validation logic, GraphQL queries, and YAML-driven tests for proposed change pipelines.
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.
Expert guidance for creating Infrahub checks. Checks are user-defined validation logic (Python + GraphQL) that run as part of a proposed change pipeline. If a check logs any errors, the proposed change cannot be merged.
Before writing a check, look at the project with read-only tools:
.infrahub.yml if it exists..py files under a
checks/ directory..gql files under a
queries/ directory.These steps contact the Infrahub server, so they come after the read-only look at the project:
infrahubctl command, detect the
project's Python environment as
../infrahub-common/rules/connectivity-python-environment.md
describes..gql
file, dry-run the query against the live schema on a
branch as
../infrahub-common/rules/deployment-gql-dry-run.md
describes..py file under checks/, or a .gql file
under queries/ that a check in .infrahub.yml uses,
even when the request does not mention checks| Priority | Category | Prefix | Description |
|---|---|---|---|
| CRITICAL | Architecture | architecture- | Three components, global vs targeted, execution flow |
| CRITICAL | Python Class | python- | InfrahubCheck base class, validate(), log_error/log_info |
| HIGH | API Reference | api- | Class attributes, instance properties, methods, lifecycle, and which API surfaces a rejection (a GraphQL error is a 200) |
| HIGH | Registration | registration- | .infrahub.yml config, query name matching, parameters |
MEDIUM (HIGH for patterns-shared-module) | Patterns | patterns- | Error collection, shared utilities, scoped validation, relationship-traversal validation, sharing a module across artifact types |
| HIGH | Testing | testing- | Resources Testing Framework (YAML-driven tests), infrahubctl check commands, which repository commit a proposed change's checks run |
A check is only useful if it can fetch and validate the right data. Most check failures at deploy time are actually schema-side gaps:
| If the check... | The schema (or .infrahub.yml) must... | See |
|---|---|---|
| Reads an attribute via GraphQL | Expose it on the schema node with the same name (name__value-shaped paths) | ../infrahub-managing-schemas/rules/attribute-defaults-and-types.md |
| Walks a relationship to validate related objects | Have both sides of the relationship defined with matching identifiers; otherwise the traversal returns nothing | ../infrahub-managing-schemas/rules/relationship-identifiers.md |
| Validates a node against a related node's state (child vs parent lifecycle, peer consistency) | Fetch the related node's comparison attribute in the query by traversing the relationship; a check runs one query with no lazy fetch | rules/patterns-relationship-traversal.md |
| Is targeted (per-object) | Register a CoreStandardGroup as targets: in .infrahub.yml and map parameters: to bind GraphQL variables | rules/registration-config.md |
| Needs the GraphQL response keyed to typed nodes | Select id and __typename in the query — the SDK relies on both | ../infrahub-common/graphql-queries.md |
| Should never block a merge but only annotate | Use self.log_info() instead of log_error(); log_warning() does not exist | rules/python-validate.md |
If a cheaper layer can express the constraint, use it.
A schema constraint runs at load time on every write
path; a Python check runs only inside the proposed-
change pipeline, so bad data created via other paths
slips through. Walk this short ladder before reaching
for InfrahubCheck:
| Signal | Cheaper layer | See rule |
|---|---|---|
| Validating uniqueness, presence, allowed values, or regex on a single attribute | Schema constraint (uniqueness_constraints, optional: false, kind: Dropdown choices, regex) | yagni-python-validator-vs-schema-constraint |
Check whose body is a GraphQL query plus a single if len(...) > 0: raise | One .gql file plus 5 lines of Python | yagni-redundant-check-that-graphql-can-answer |
| Enforcing that a relationship is single-peered or non-optional | Schema cardinality: one, kind: Parent / Component, optional: false | yagni-python-validator-vs-schema-constraint |
Only when none of these apply should you write a Python check. The cross-node business rules, out-of-band reconciliations, and stateful assertions in rules/python-validate.md are the legitimate use cases.
When the check reads objects through the SDK (rather than only its GraphQL
query), type those calls with generated protocol classes rather than string
kinds — client.get(DcimDevice, ...), not kind="DcimDevice". Match the
--sync protocol variant to the check's client. See
protocols-adopt-typed-kinds.
Every check has three components:
.gql file) -- fetches the data to
validate, and is registered under the top-level
queries: section of .infrahub.ymlInfrahubCheck,
sets query = "<query_name>", implements
validate().infrahub.yml under
check_definitions (which does not take a
query: field — see below)from infrahub_sdk.checks import InfrahubCheck
class MyCheck(InfrahubCheck):
query = "my_query" # Must match queries[].name in .infrahub.yml
def validate(self, data: dict) -> None:
# Validation logic here
if something_is_wrong:
self.log_error(
message="Problem description"
)
Where the query is bound: the Python class (
query = "..."), notcheck_definitions. The repository config model usesextra="forbid", so puttingquery:undercheck_definitions:makes the whole repo config fail validation. This is the most common confusion vs.generator_definitions:, which does take a top-levelquery:. See rules/registration-config.md.
Follow these steps when creating a check:
.gql file
that fetches the data to validate. Read
../infrahub-common/graphql-queries.md
for query patterns. If the rule compares a node
against a related node's state (child vs parent
lifecycle, peer consistency), the query must fetch
that related attribute by traversing the relationship
now — a check runs one query with no later fetch. See
rules/patterns-relationship-traversal.md.InfrahubCheck, implement validate(). Read
rules/python-validate.md
for the class pattern and
rules/api-reference.md
for available methods. If the check calls back into
Infrahub, read
rules/api-error-surfaces.md
too: a rejected GraphQL request still returns HTTP
200, so branching on a status code makes the check
pass on the failure it exists to catch. If the logic
is shared with a generator or a transform, read
rules/patterns-shared-module.md
before reaching for a relative import.check_definitions. The query name must match the
Python class query attribute. See
rules/registration-config.md.infrahubctl check to validate
against a feature branch. See
rules/testing-commands.md.
To run a changed check against an existing proposed
change, read
rules/testing-proposed-change-commit.md:
the pipeline runs the code at the source branch's
repository commit, not main's, and a branch rebase
does not move it on a branch synced with Git..infrahub.yml registration (with the no-query:
shape that differs from generator_definitions)docs.infrahub.app
on a genuine gap (e.g. deleting nodes)examples.md (opens in a new tab)reference.md (opens in a new tab)rules/_sections.md (opens in a new tab)rules/_template.md (opens in a new tab)rules/api-error-surfaces.md (opens in a new tab)rules/api-reference.md (opens in a new tab)rules/architecture-types.md (opens in a new tab)rules/patterns-common.md (opens in a new tab)rules/patterns-relationship-traversal.md (opens in a new tab)rules/patterns-shared-module.md (opens in a new tab)rules/python-validate.md (opens in a new tab)rules/registration-config.md (opens in a new tab)rules/testing-commands.md (opens in a new tab)rules/testing-proposed-change-commit.md (opens in a new tab)rules/testing-resource-framework.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
infrahub@opsmill is listed by opsmill/claude-marketplace — review the source before installing
npx claudepluginhub opsmill/claude-marketplace --plugin infrahub18 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-converting-netbox-device-typesConverts NetBox device-type and module-type definitions (the netbox-community devicetype-library format, also published via the NetBox Data Exchange / NDX) into Infrahub object templates as Infrahub object YAML, using a bundled Python converter driven by a schema mapping profile. TRIGGER when: importing NetBox device types or module types, exporting device types from a running NetBox instance, building object templates from vendor device models, converting line cards / PSUs / transceivers from NetBox module types into Template* objects, re-running a conversion after changing the mapping profile, debugging a wrong or failed conversion. DO NOT TRIGGER when: importing CSV/TSV data (use infrahub-importing-data), authoring schemas from scratch (use infrahub-managing-schemas), writing ordinary object data files (use infrahub-managing-objects), or setting up continuous two-way replication with a live NetBox (that is infrahub-sync, a separate product; a one-off export of device types is in scope here).Other plugins' skills for the same job