This repository contains best practices for NetBox integrations, available in multiple formats for different AI coding assistants and human readers. This guide explains the structure, conventions, and maintenance procedures.
netbox-best-practices/
├── CLAUDE.md # This file - maintenance guide
├── AGENTS.md # Cursor/general AI assistant guide
├── HUMAN.md # Human-readable guide (for engineers)
├── README.md # Repository overview
├── .cursor/rules/ # Cursor IDE rules
│ ├── netbox-auth.mdc
│ ├── netbox-rest-api.mdc
│ ├── netbox-graphql.mdc
│ ├── netbox-data-modeling.mdc
│ ├── netbox-integration.mdc
│ └── netbox-performance.mdc
└── skills/
└── netbox-integration-best-practices/
├── SKILL.md # Main skill definition (for Claude Code)
└── references/
├── netbox-integration-guidelines.md # Technical reference
└── rules/
├── _sections.md # Category definitions
├── _template.md # Rule template
└── [individual rule files]
This repository maintains content in three parallel formats:
| Format | Location | Audience | Style |
|---|---|---|---|
| Claude Code Skills | skills/*/SKILL.md, references/ |
Claude Code users | Progressive disclosure, reference files |
| Cursor Rules | .cursor/rules/*.mdc |
Cursor IDE users | Concise (<500 lines), YAML frontmatter |
| Human Documentation | HUMAN.md |
Engineers | Concise orientation, all skills combined |
The authoritative source for all rules is skills/*/references/rules/*.md. The other formats are derived from and must stay aligned with these detailed rule files.
Important: HUMAN.md is a single document covering ALL best practices across all skills. When adding new skills, add their content to this document rather than creating skill-specific human docs.
When adding, updating, or removing rules or guidance, always update all three formats:
-
Authoritative Rules (
skills/*/references/rules/*.md)- This is the source of truth
- Contains full rationale, examples, exceptions
- Update this FIRST
-
Claude Code Skills (
skills/*/SKILL.md)- Progressive disclosure format
- References the detailed rule files
- Update rule tables to match
-
Cursor Rules (
.cursor/rules/*.mdc)- Concise format (<500 lines per file)
- Organized by category (auth, rest, graphql, etc.)
- Include key patterns and examples
- Link to detailed rules for more info
-
Human Documentation (
HUMAN.md)- Single document for ALL skills
- Concise orientation for engineers/reviewers
- Add new skill content as new sections
-
AGENTS.md
- Summary for Cursor/other AI assistants
- Quick reference of key principles
- Update if adding new categories
When making changes:
- Update the authoritative rule file in
references/rules/ - Update
_sections.mdif adding/removing rules or categories - Update
SKILL.mdrule tables - Update relevant
.cursor/rules/*.mdcfile - Update
HUMAN.mdfor significant changes - Update
AGENTS.mdif adding new categories or critical rules
Cursor .mdc files have specific requirements:
---
description: "Brief description for intelligent application"
globs: ["**/*.py"]
alwaysApply: false
---
# Rule content in markdown- Keep each file under 500 lines (ideally much shorter)
- Use
globsto match relevant file types - Include concrete code examples (correct/incorrect patterns)
- Link to detailed rule files for comprehensive information
- Organize by category, not by individual rule
This repository focuses exclusively on NetBox and Diode-specific best practices. Do NOT include generic software development guidance such as:
- Token/secret storage patterns (use environment variables, vaults, etc.)
- Retry strategies and exponential backoff
- Connection pooling
- Generic error handling
- Audit logging patterns
- Rate limiting implementation
These are important topics but are covered extensively elsewhere. Keep rules focused on NetBox API behaviors, Diode ingestion patterns, and NetBox-specific performance considerations.
| Skill | Purpose | Target Audience |
|---|---|---|
netbox-integration-best-practices |
REST/GraphQL API integration patterns | Engineers building integrations |
| Skill | Purpose | Status |
|---|---|---|
netbox-plugin-development |
Plugin architecture and hooks | Planned |
netbox-custom-scripts |
Custom scripts and reports | Planned |
netbox-admin-operations |
Administration and operations | Planned |
All rules follow the template in _template.md:
---
title: Rule Title
impact: CRITICAL | HIGH | MEDIUM | LOW
category: auth | rest | graphql | perf | data | integ
tags: [relevant, tags]
netbox_version: "4.4+"
---Rules are prefixed by category:
auth-- Authentication rulesrest-- REST API rulesgraphql-- GraphQL rulesperf-- Performance rulesdata-- Data modeling rulesinteg-- Integration rules
| Impact | Description | Action Required |
|---|---|---|
| CRITICAL | Security vulnerabilities, data loss risk, breaking changes | Must fix immediately |
| HIGH | Significant performance/reliability impact | Should fix soon |
| MEDIUM | Notable improvements, best practices | Plan to address |
| LOW | Minor improvements, style preferences | Consider when convenient |
- Copy
_template.mdtorules/{category}-{rule-name}.md - Fill in YAML frontmatter with appropriate metadata
- Document the rationale (why this matters)
- Provide incorrect pattern with annotation
- Provide correct pattern with explanation
- Add async example if applicable for high-volume patterns
- List exceptions and edge cases
- Add related rules and references
- Update
_sections.mdif adding a new category - Update
SKILL.mdrule tables - Update the corresponding
.cursor/rules/*.mdcfile - Update
HUMAN.mdif it's a significant rule - Update
AGENTS.mdif it's a critical rule or new category
- requests - Standard synchronous HTTP library (most examples)
- pynetbox - Official NetBox Python client
- httpx - Async HTTP library for high-volume patterns
# Base URL format
NETBOX_URL = "https://netbox.example.com"
API_URL = f"{NETBOX_URL}/api"
# Authentication headers (v2 token format)
headers = {
"Authorization": "Bearer nbt_abc123.xxxxxxxxxxxxxxxx",
"Content-Type": "application/json"
}
# Never include real tokens
# Use descriptive placeholder values- All examples must be syntactically correct Python
- Include error handling in "correct" patterns
- Show both incorrect and correct patterns
- Use type hints where it aids clarity
- Include complexity scores for GraphQL examples
- Test examples where possible
| Version | Support Level | Notes |
|---|---|---|
| 4.4+ | Primary target | General compatibility |
| 4.5+ | v2 tokens | Required for v2 token features |
| 4.7+ | Future | v1 tokens deprecated |
Always note when features require specific versions:
> **NetBox 4.5+**: v2 tokens use `Bearer nbt_<key>.<token>` format.This is critical information for all authentication-related documentation:
| Version | Token Status |
|---|---|
| < 4.5 | v1 tokens only (Token <token>) |
| 4.5.0 | v2 tokens introduced (Bearer nbt_<key>.<token>) |
| 4.7.0 | v1 tokens deprecated (removal planned) |
Bearer nbt_<key>.<token>
nbt_prefix identifies as NetBox token<key>is the public key identifier<token>is the secret portion- Uses HMAC-SHA256 with pepper
- Plaintext never stored in database
- Requires
API_TOKEN_PEPPERSconfiguration
Before committing changes:
- All internal markdown links resolve
- Code examples are syntactically correct
- YAML frontmatter is valid in all rule files
- Rule tables in SKILL.md match actual rule files
- Cursor rules in
.cursor/rules/*.mdcare updated - AGENTS.md reflects any new categories or critical rules
- HUMAN.md is updated for significant changes
- Examples use correct NetBox API behavior
- Version requirements are documented
- Impact levels are appropriate
- All three formats (Claude Skills, Cursor Rules, Human Docs) are aligned
- pynetbox - Official Python client
- netbox-graphql-query-optimizer - Query analysis tool
- Diode - Data ingestion service (for high-volume writes)
- Diode Python SDK - Python client for Diode
- Review for NetBox version updates: Each minor release
- Check community discussions for new performance insights: Monthly
- Validate code examples against latest API: Quarterly
- Update GraphQL optimizer recommendations: As new versions release